Compiler-Interpreter.js 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480
  1. smalltalk.addPackage('Compiler-Interpreter');
  2. smalltalk.addClass('AIBlockClosure', smalltalk.BlockClosure, ['node', 'outerContext'], 'Compiler-Interpreter');
  3. smalltalk.AIBlockClosure.comment="I am a special `BlockClosure` subclass used by an interpreter to interpret a block node.\x0a\x0aWhile I am polymorphic with `BlockClosure`, some methods such as `#new` will raise interpretation errors. Unlike a `BlockClosure`, my instance are not JavaScript functions.\x0a\x0aEvaluating an instance will result in interpreting the `node` instance variable (instance of `BlockNode`).";
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "applyTo:arguments:",
  7. category: 'evaluating',
  8. fn: function (anObject,aCollection){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) {
  11. self._interpreterError();
  12. return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},smalltalk.AIBlockClosure)})},
  13. args: ["anObject", "aCollection"],
  14. source: "applyTo: anObject arguments: aCollection\x0a\x09self interpreterError",
  15. messageSends: ["interpreterError"],
  16. referencedClasses: []
  17. }),
  18. smalltalk.AIBlockClosure);
  19. smalltalk.addMethod(
  20. smalltalk.method({
  21. selector: "compiledSource",
  22. category: 'accessing',
  23. fn: function (){
  24. var self=this;
  25. return smalltalk.withContext(function($ctx1) {
  26. return "[ AST Block closure ]";
  27. }, function($ctx1) {$ctx1.fill(self,"compiledSource",{},smalltalk.AIBlockClosure)})},
  28. args: [],
  29. source: "compiledSource\x0a\x09\x22Unlike blocks, the receiver doesn't represent a JS function\x22\x0a\x09\x0a\x09^ '[ AST Block closure ]' ",
  30. messageSends: [],
  31. referencedClasses: []
  32. }),
  33. smalltalk.AIBlockClosure);
  34. smalltalk.addMethod(
  35. smalltalk.method({
  36. selector: "currySelf",
  37. category: 'converting',
  38. fn: function (){
  39. var self=this;
  40. return smalltalk.withContext(function($ctx1) {
  41. self._interpreterError();
  42. return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},smalltalk.AIBlockClosure)})},
  43. args: [],
  44. source: "currySelf\x0a\x09self interpreterError",
  45. messageSends: ["interpreterError"],
  46. referencedClasses: []
  47. }),
  48. smalltalk.AIBlockClosure);
  49. smalltalk.addMethod(
  50. smalltalk.method({
  51. selector: "initializeWithContext:node:",
  52. category: 'initialization',
  53. fn: function (aContext,aNode){
  54. var self=this;
  55. return smalltalk.withContext(function($ctx1) {
  56. self["@node"]=aNode;
  57. self["@outerContext"]=aContext;
  58. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure)})},
  59. args: ["aContext", "aNode"],
  60. source: "initializeWithContext: aContext node: aNode\x0a\x09node := aNode.\x0a\x09outerContext := aContext",
  61. messageSends: [],
  62. referencedClasses: []
  63. }),
  64. smalltalk.AIBlockClosure);
  65. smalltalk.addMethod(
  66. smalltalk.method({
  67. selector: "interpreterError",
  68. category: 'error handling',
  69. fn: function (){
  70. var self=this;
  71. function $AIInterpreterError(){return smalltalk.AIInterpreterError||(typeof AIInterpreterError=="undefined"?nil:AIInterpreterError)}
  72. return smalltalk.withContext(function($ctx1) {
  73. _st($AIInterpreterError())._signal_("Method cannot be interpreted by the interpreter.");
  74. return self}, function($ctx1) {$ctx1.fill(self,"interpreterError",{},smalltalk.AIBlockClosure)})},
  75. args: [],
  76. source: "interpreterError\x0a\x09AIInterpreterError signal: 'Method cannot be interpreted by the interpreter.'",
  77. messageSends: ["signal:"],
  78. referencedClasses: ["AIInterpreterError"]
  79. }),
  80. smalltalk.AIBlockClosure);
  81. smalltalk.addMethod(
  82. smalltalk.method({
  83. selector: "numArgs",
  84. category: 'accessing',
  85. fn: function (){
  86. var self=this;
  87. return smalltalk.withContext(function($ctx1) {
  88. var $1;
  89. $1=_st(_st(self["@node"])._temps())._size();
  90. return $1;
  91. }, function($ctx1) {$ctx1.fill(self,"numArgs",{},smalltalk.AIBlockClosure)})},
  92. args: [],
  93. source: "numArgs\x0a\x09^ node temps size",
  94. messageSends: ["size", "temps"],
  95. referencedClasses: []
  96. }),
  97. smalltalk.AIBlockClosure);
  98. smalltalk.addMethod(
  99. smalltalk.method({
  100. selector: "value",
  101. category: 'evaluating',
  102. fn: function (){
  103. var self=this;
  104. return smalltalk.withContext(function($ctx1) {
  105. var $1;
  106. $1=self._valueWithPossibleArguments_([]);
  107. return $1;
  108. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.AIBlockClosure)})},
  109. args: [],
  110. source: "value\x0a\x09^ self valueWithPossibleArguments: #()",
  111. messageSends: ["valueWithPossibleArguments:"],
  112. referencedClasses: []
  113. }),
  114. smalltalk.AIBlockClosure);
  115. smalltalk.addMethod(
  116. smalltalk.method({
  117. selector: "value:",
  118. category: 'evaluating',
  119. fn: function (anArgument){
  120. var self=this;
  121. return smalltalk.withContext(function($ctx1) {
  122. var $1;
  123. $1=self._valueWithPossibleArguments_([anArgument]);
  124. return $1;
  125. }, function($ctx1) {$ctx1.fill(self,"value:",{anArgument:anArgument},smalltalk.AIBlockClosure)})},
  126. args: ["anArgument"],
  127. source: "value: anArgument\x0a\x09^ self valueWithPossibleArguments: {anArgument}",
  128. messageSends: ["valueWithPossibleArguments:"],
  129. referencedClasses: []
  130. }),
  131. smalltalk.AIBlockClosure);
  132. smalltalk.addMethod(
  133. smalltalk.method({
  134. selector: "value:value:",
  135. category: 'evaluating',
  136. fn: function (firstArgument,secondArgument){
  137. var self=this;
  138. return smalltalk.withContext(function($ctx1) {
  139. var $1;
  140. $1=self._valueWithPossibleArguments_([firstArgument,secondArgument]);
  141. return $1;
  142. }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},smalltalk.AIBlockClosure)})},
  143. args: ["firstArgument", "secondArgument"],
  144. source: "value: firstArgument value: secondArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument}",
  145. messageSends: ["valueWithPossibleArguments:"],
  146. referencedClasses: []
  147. }),
  148. smalltalk.AIBlockClosure);
  149. smalltalk.addMethod(
  150. smalltalk.method({
  151. selector: "value:value:value:",
  152. category: 'evaluating',
  153. fn: function (firstArgument,secondArgument,thirdArgument){
  154. var self=this;
  155. return smalltalk.withContext(function($ctx1) {
  156. var $1;
  157. $1=self._valueWithPossibleArguments_([firstArgument,secondArgument,thirdArgument]);
  158. return $1;
  159. }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},smalltalk.AIBlockClosure)})},
  160. args: ["firstArgument", "secondArgument", "thirdArgument"],
  161. source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument . thirdArgument}",
  162. messageSends: ["valueWithPossibleArguments:"],
  163. referencedClasses: []
  164. }),
  165. smalltalk.AIBlockClosure);
  166. smalltalk.addMethod(
  167. smalltalk.method({
  168. selector: "valueWithPossibleArguments:",
  169. category: 'evaluating',
  170. fn: function (aCollection){
  171. var self=this;
  172. var context,sequenceNode;
  173. return smalltalk.withContext(function($ctx1) {
  174. var $1,$2,$3,$4,$5;
  175. context=_st(self["@outerContext"])._newBlockContext();
  176. $1=_st(_st(_st(self["@node"])._nodes())._first())._copy();
  177. _st($1)._parent_(nil);
  178. $2=_st($1)._yourself();
  179. sequenceNode=$2;
  180. _st(_st(self["@node"])._parameters())._withIndexDo_((function(each,index){
  181. return smalltalk.withContext(function($ctx2) {
  182. return _st(context)._localAt_put_(each,_st(aCollection)._at_ifAbsent_(index,(function(){
  183. return smalltalk.withContext(function($ctx3) {
  184. return nil;
  185. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})));
  186. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
  187. $3=_st(context)._interpreter();
  188. _st($3)._node_(_st(sequenceNode)._nextChild());
  189. $4=_st($3)._proceed();
  190. _st(_st(self["@outerContext"])._interpreter())._returnValue_(_st(_st(context)._interpreter())._returnValue());
  191. _st(console)._log_(_st(_st(context)._interpreter())._returnValue());
  192. $5=_st(_st(context)._interpreter())._pop();
  193. return $5;
  194. }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection,context:context,sequenceNode:sequenceNode},smalltalk.AIBlockClosure)})},
  195. args: ["aCollection"],
  196. source: "valueWithPossibleArguments: aCollection\x0a\x09| context sequenceNode |\x0a\x09context := outerContext newBlockContext.\x0a\x0a\x09\x22Interpret a copy of the sequence node to avoid creating a new AIBlockClosure\x22\x0a\x09sequenceNode := node nodes first copy\x0a\x09\x09parent: nil;\x0a\x09\x09yourself.\x0a\x0a\x09\x22Populate the arguments into the context locals\x22\x09\x0a\x09node parameters withIndexDo: [ :each :index |\x0a\x09\x09context localAt: each put: (aCollection at: index ifAbsent: [ nil ]) ].\x0a\x0a\x09\x22Interpret the first node of the BlockSequenceNode\x22\x0a\x09context interpreter\x0a\x09\x09node: sequenceNode nextChild;\x0a\x09\x09proceed.\x0a\x09\x09\x0a\x09outerContext interpreter\x0a\x09\x09returnValue: context interpreter returnValue.\x0a\x09\x09\x0a\x09console log: context interpreter returnValue.\x0a\x09\x09\x0a\x09^ context interpreter pop",
  197. messageSends: ["newBlockContext", "parent:", "copy", "first", "nodes", "yourself", "withIndexDo:", "parameters", "localAt:put:", "at:ifAbsent:", "node:", "interpreter", "nextChild", "proceed", "returnValue:", "returnValue", "log:", "pop"],
  198. referencedClasses: []
  199. }),
  200. smalltalk.AIBlockClosure);
  201. smalltalk.addMethod(
  202. smalltalk.method({
  203. selector: "forContext:node:",
  204. category: 'instance creation',
  205. fn: function (aContext,aNode){
  206. var self=this;
  207. return smalltalk.withContext(function($ctx1) {
  208. var $2,$3,$1;
  209. $2=self._new();
  210. _st($2)._initializeWithContext_node_(aContext,aNode);
  211. $3=_st($2)._yourself();
  212. $1=$3;
  213. return $1;
  214. }, function($ctx1) {$ctx1.fill(self,"forContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure.klass)})},
  215. args: ["aContext", "aNode"],
  216. source: "forContext: aContext node: aNode\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext node: aNode;\x0a\x09\x09yourself",
  217. messageSends: ["initializeWithContext:node:", "new", "yourself"],
  218. referencedClasses: []
  219. }),
  220. smalltalk.AIBlockClosure.klass);
  221. smalltalk.addClass('AIContext', smalltalk.Object, ['outerContext', 'innerContext', 'pc', 'locals', 'method', 'index', 'ast', 'interpreter'], 'Compiler-Interpreter');
  222. smalltalk.AIContext.comment="I am like a `MethodContext`, used by the `ASTInterpreter`.\x0aUnlike a `MethodContext`, my instances are not read-only.\x0a\x0aWhen debugging, my instances are created by copying the current `MethodContext` (thisContext)";
  223. smalltalk.addMethod(
  224. smalltalk.method({
  225. selector: "arguments",
  226. category: 'interpreting',
  227. fn: function (){
  228. var self=this;
  229. return smalltalk.withContext(function($ctx1) {
  230. var $1;
  231. $1=_st(_st(self._ast())._arguments())._collect_((function(each){
  232. return smalltalk.withContext(function($ctx2) {
  233. return self._localAt_(each);
  234. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  235. return $1;
  236. }, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.AIContext)})},
  237. args: [],
  238. source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ]",
  239. messageSends: ["collect:", "arguments", "ast", "localAt:"],
  240. referencedClasses: []
  241. }),
  242. smalltalk.AIContext);
  243. smalltalk.addMethod(
  244. smalltalk.method({
  245. selector: "asString",
  246. category: 'converting',
  247. fn: function (){
  248. var self=this;
  249. return smalltalk.withContext(function($ctx1) {
  250. var $2,$1;
  251. $2=self._isBlockContext();
  252. if(smalltalk.assert($2)){
  253. $1=_st("a block (in ".__comma(_st(self._methodContext())._asString())).__comma(")");
  254. } else {
  255. $1=_st(_st(_st(_st(self._receiver())._class())._name()).__comma(" >> ")).__comma(self._selector());
  256. };
  257. return $1;
  258. }, function($ctx1) {$ctx1.fill(self,"asString",{},smalltalk.AIContext)})},
  259. args: [],
  260. source: "asString\x0a\x09^self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext asString, ')' ]\x0a\x09\x09ifFalse: [ self receiver class name, ' >> ', self selector ]",
  261. messageSends: ["ifTrue:ifFalse:", "isBlockContext", ",", "asString", "methodContext", "name", "class", "receiver", "selector"],
  262. referencedClasses: []
  263. }),
  264. smalltalk.AIContext);
  265. smalltalk.addMethod(
  266. smalltalk.method({
  267. selector: "ast",
  268. category: 'interpreting',
  269. fn: function (){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx1) {
  272. var $1,$2,$3,$4;
  273. $1=self._isBlockContext();
  274. if(smalltalk.assert($1)){
  275. $2=_st(self._outerContext())._ast();
  276. return $2;
  277. };
  278. $3=self["@ast"];
  279. if(($receiver = $3) == nil || $receiver == undefined){
  280. self._initializeAST();
  281. } else {
  282. $3;
  283. };
  284. $4=self["@ast"];
  285. return $4;
  286. }, function($ctx1) {$ctx1.fill(self,"ast",{},smalltalk.AIContext)})},
  287. args: [],
  288. source: "ast\x0a\x09self isBlockContext ifTrue: [ ^ self outerContext ast ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
  289. messageSends: ["ifTrue:", "isBlockContext", "ast", "outerContext", "ifNil:", "initializeAST"],
  290. referencedClasses: []
  291. }),
  292. smalltalk.AIContext);
  293. smalltalk.addMethod(
  294. smalltalk.method({
  295. selector: "index",
  296. category: 'accessing',
  297. fn: function (){
  298. var self=this;
  299. return smalltalk.withContext(function($ctx1) {
  300. var $2,$1;
  301. $2=self["@index"];
  302. if(($receiver = $2) == nil || $receiver == undefined){
  303. $1=(0);
  304. } else {
  305. $1=$2;
  306. };
  307. return $1;
  308. }, function($ctx1) {$ctx1.fill(self,"index",{},smalltalk.AIContext)})},
  309. args: [],
  310. source: "index\x0a\x09^ index ifNil: [ 0 ]",
  311. messageSends: ["ifNil:"],
  312. referencedClasses: []
  313. }),
  314. smalltalk.AIContext);
  315. smalltalk.addMethod(
  316. smalltalk.method({
  317. selector: "index:",
  318. category: 'accessing',
  319. fn: function (anInteger){
  320. var self=this;
  321. return smalltalk.withContext(function($ctx1) {
  322. self["@index"]=anInteger;
  323. return self}, function($ctx1) {$ctx1.fill(self,"index:",{anInteger:anInteger},smalltalk.AIContext)})},
  324. args: ["anInteger"],
  325. source: "index: anInteger\x0a\x09index := anInteger",
  326. messageSends: [],
  327. referencedClasses: []
  328. }),
  329. smalltalk.AIContext);
  330. smalltalk.addMethod(
  331. smalltalk.method({
  332. selector: "initializeAST",
  333. category: 'initialization',
  334. fn: function (){
  335. var self=this;
  336. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  337. return smalltalk.withContext(function($ctx1) {
  338. self["@ast"]=_st(self._method())._ast();
  339. _st(_st($SemanticAnalyzer())._on_(_st(self._method())._methodClass()))._visit_(self["@ast"]);
  340. return self}, function($ctx1) {$ctx1.fill(self,"initializeAST",{},smalltalk.AIContext)})},
  341. args: [],
  342. source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
  343. messageSends: ["ast", "method", "visit:", "on:", "methodClass"],
  344. referencedClasses: ["SemanticAnalyzer"]
  345. }),
  346. smalltalk.AIContext);
  347. smalltalk.addMethod(
  348. smalltalk.method({
  349. selector: "initializeFromMethodContext:",
  350. category: 'initialization',
  351. fn: function (aMethodContext){
  352. var self=this;
  353. return smalltalk.withContext(function($ctx1) {
  354. var $1,$2,$3,$4;
  355. $1=self;
  356. _st($1)._pc_(_st(aMethodContext)._pc());
  357. _st($1)._index_(_st(aMethodContext)._index());
  358. _st($1)._receiver_(_st(aMethodContext)._receiver());
  359. $2=_st($1)._method_(_st(aMethodContext)._method());
  360. $3=_st(aMethodContext)._outerContext();
  361. if(($receiver = $3) == nil || $receiver == undefined){
  362. $3;
  363. } else {
  364. var outer;
  365. outer=$receiver;
  366. $4=_st(outer)._methodContext();
  367. if(($receiver = $4) == nil || $receiver == undefined){
  368. $4;
  369. } else {
  370. self._outerContext_(_st(self._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
  371. };
  372. _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
  373. return smalltalk.withContext(function($ctx2) {
  374. return _st(self._locals())._at_put_(key,value);
  375. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)})}));
  376. };
  377. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext)})},
  378. args: ["aMethodContext"],
  379. source: "initializeFromMethodContext: aMethodContext\x0a\x0a\x09self \x0a\x09\x09pc: aMethodContext pc;\x0a\x09\x09index: aMethodContext index;\x0a\x09\x09receiver: aMethodContext receiver;\x0a\x09\x09method: aMethodContext method.\x0a\x09\x09\x0a\x09aMethodContext outerContext ifNotNil: [ :outer |\x0a\x09\x09\x22If the method context is nil, the block was defined in JS, so ignore it\x22\x0a\x09\x09outer methodContext ifNotNil: [\x0a\x09\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a\x09\x09\x09aMethodContext locals keysAndValuesDo: [ :key :value |\x0a\x09\x09\x09\x09self locals at: key put: value ] ]",
  380. messageSends: ["pc:", "pc", "index:", "index", "receiver:", "receiver", "method:", "method", "ifNotNil:", "outerContext", "methodContext", "outerContext:", "fromMethodContext:", "class", "keysAndValuesDo:", "locals", "at:put:"],
  381. referencedClasses: []
  382. }),
  383. smalltalk.AIContext);
  384. smalltalk.addMethod(
  385. smalltalk.method({
  386. selector: "initializeInterpreter",
  387. category: 'initialization',
  388. fn: function (){
  389. var self=this;
  390. function $Interpreter(){return smalltalk.Interpreter||(typeof Interpreter=="undefined"?nil:Interpreter)}
  391. return smalltalk.withContext(function($ctx1) {
  392. var $1,$2,$3,$4;
  393. $1=_st($Interpreter())._new();
  394. _st($1)._context_(self);
  395. $2=_st($1)._yourself();
  396. self["@interpreter"]=$2;
  397. $3=self["@ast"];
  398. if(($receiver = $3) == nil || $receiver == undefined){
  399. $3;
  400. } else {
  401. _st(self["@interpreter"])._node_(self._retrieveNode());
  402. };
  403. $4=_st(_st(self._innerContext())._notNil())._and_((function(){
  404. return smalltalk.withContext(function($ctx2) {
  405. return _st(_st(self._innerContext())._isBlockContext())._not();
  406. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  407. if(smalltalk.assert($4)){
  408. self._setupInterpreter_(self["@interpreter"]);
  409. };
  410. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},smalltalk.AIContext)})},
  411. args: [],
  412. source: "initializeInterpreter\x0a\x09interpreter := Interpreter new\x0a\x09\x09context: self;\x0a\x09\x09yourself.\x0a\x09ast ifNotNil: [ interpreter node: self retrieveNode ].\x0a\x09\x0a\x09(self innerContext notNil and: [ \x0a\x09\x09self innerContext isBlockContext not ]) ifTrue: [\x0a\x09\x09\x09self setupInterpreter: interpreter ]",
  413. messageSends: ["context:", "new", "yourself", "ifNotNil:", "node:", "retrieveNode", "ifTrue:", "and:", "notNil", "innerContext", "not", "isBlockContext", "setupInterpreter:"],
  414. referencedClasses: ["Interpreter"]
  415. }),
  416. smalltalk.AIContext);
  417. smalltalk.addMethod(
  418. smalltalk.method({
  419. selector: "initializeLocals",
  420. category: 'initialization',
  421. fn: function (){
  422. var self=this;
  423. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  424. return smalltalk.withContext(function($ctx1) {
  425. self["@locals"]=_st($Dictionary())._new();
  426. _st(self["@locals"])._at_put_("thisContext",self);
  427. return self}, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},smalltalk.AIContext)})},
  428. args: [],
  429. source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
  430. messageSends: ["new", "at:put:"],
  431. referencedClasses: ["Dictionary"]
  432. }),
  433. smalltalk.AIContext);
  434. smalltalk.addMethod(
  435. smalltalk.method({
  436. selector: "innerContext",
  437. category: 'accessing',
  438. fn: function (){
  439. var self=this;
  440. return smalltalk.withContext(function($ctx1) {
  441. var $1;
  442. $1=self["@innerContext"];
  443. return $1;
  444. }, function($ctx1) {$ctx1.fill(self,"innerContext",{},smalltalk.AIContext)})},
  445. args: [],
  446. source: "innerContext\x0a\x09^ innerContext",
  447. messageSends: [],
  448. referencedClasses: []
  449. }),
  450. smalltalk.AIContext);
  451. smalltalk.addMethod(
  452. smalltalk.method({
  453. selector: "innerContext:",
  454. category: 'accessing',
  455. fn: function (anAIContext){
  456. var self=this;
  457. return smalltalk.withContext(function($ctx1) {
  458. self["@innerContext"]=anAIContext;
  459. return self}, function($ctx1) {$ctx1.fill(self,"innerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  460. args: ["anAIContext"],
  461. source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
  462. messageSends: [],
  463. referencedClasses: []
  464. }),
  465. smalltalk.AIContext);
  466. smalltalk.addMethod(
  467. smalltalk.method({
  468. selector: "interpreter",
  469. category: 'interpreting',
  470. fn: function (){
  471. var self=this;
  472. return smalltalk.withContext(function($ctx1) {
  473. var $1,$2;
  474. $1=self["@interpreter"];
  475. if(($receiver = $1) == nil || $receiver == undefined){
  476. self._initializeInterpreter();
  477. } else {
  478. $1;
  479. };
  480. $2=self["@interpreter"];
  481. return $2;
  482. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AIContext)})},
  483. args: [],
  484. source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
  485. messageSends: ["ifNil:", "initializeInterpreter"],
  486. referencedClasses: []
  487. }),
  488. smalltalk.AIContext);
  489. smalltalk.addMethod(
  490. smalltalk.method({
  491. selector: "interpreter:",
  492. category: 'interpreting',
  493. fn: function (anInterpreter){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) {
  496. self["@interpreter"]=anInterpreter;
  497. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
  498. args: ["anInterpreter"],
  499. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  500. messageSends: [],
  501. referencedClasses: []
  502. }),
  503. smalltalk.AIContext);
  504. smalltalk.addMethod(
  505. smalltalk.method({
  506. selector: "isBlockContext",
  507. category: 'testing',
  508. fn: function (){
  509. var self=this;
  510. return smalltalk.withContext(function($ctx1) {
  511. var $1;
  512. $1=_st(self._selector())._isNil();
  513. return $1;
  514. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},smalltalk.AIContext)})},
  515. args: [],
  516. source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
  517. messageSends: ["isNil", "selector"],
  518. referencedClasses: []
  519. }),
  520. smalltalk.AIContext);
  521. smalltalk.addMethod(
  522. smalltalk.method({
  523. selector: "localAt:",
  524. category: 'accessing',
  525. fn: function (aString){
  526. var self=this;
  527. return smalltalk.withContext(function($ctx1) {
  528. var $2,$1;
  529. $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
  530. return smalltalk.withContext(function($ctx2) {
  531. $2=self._isBlockContext();
  532. if(smalltalk.assert($2)){
  533. return nil;
  534. } else {
  535. return _st(self._outerContext())._localAt_(aString);
  536. };
  537. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  538. return $1;
  539. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},smalltalk.AIContext)})},
  540. args: ["aString"],
  541. source: "localAt: aString\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self isBlockContext \x0a\x09\x09\x09ifTrue: [ nil ]\x0a\x09\x09\x09ifFalse: [ self outerContext localAt: aString ] ]",
  542. messageSends: ["at:ifAbsent:", "locals", "ifTrue:ifFalse:", "isBlockContext", "localAt:", "outerContext"],
  543. referencedClasses: []
  544. }),
  545. smalltalk.AIContext);
  546. smalltalk.addMethod(
  547. smalltalk.method({
  548. selector: "localAt:put:",
  549. category: 'accessing',
  550. fn: function (aString,anObject){
  551. var self=this;
  552. return smalltalk.withContext(function($ctx1) {
  553. _st(self._locals())._at_put_(aString,anObject);
  554. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},smalltalk.AIContext)})},
  555. args: ["aString", "anObject"],
  556. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  557. messageSends: ["at:put:", "locals"],
  558. referencedClasses: []
  559. }),
  560. smalltalk.AIContext);
  561. smalltalk.addMethod(
  562. smalltalk.method({
  563. selector: "locals",
  564. category: 'accessing',
  565. fn: function (){
  566. var self=this;
  567. return smalltalk.withContext(function($ctx1) {
  568. var $1,$2;
  569. $1=self["@locals"];
  570. if(($receiver = $1) == nil || $receiver == undefined){
  571. self._initializeLocals();
  572. } else {
  573. $1;
  574. };
  575. $2=self["@locals"];
  576. return $2;
  577. }, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.AIContext)})},
  578. args: [],
  579. source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
  580. messageSends: ["ifNil:", "initializeLocals"],
  581. referencedClasses: []
  582. }),
  583. smalltalk.AIContext);
  584. smalltalk.addMethod(
  585. smalltalk.method({
  586. selector: "method",
  587. category: 'accessing',
  588. fn: function (){
  589. var self=this;
  590. return smalltalk.withContext(function($ctx1) {
  591. var $1;
  592. $1=self["@method"];
  593. return $1;
  594. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.AIContext)})},
  595. args: [],
  596. source: "method\x0a\x09^ method",
  597. messageSends: [],
  598. referencedClasses: []
  599. }),
  600. smalltalk.AIContext);
  601. smalltalk.addMethod(
  602. smalltalk.method({
  603. selector: "method:",
  604. category: 'accessing',
  605. fn: function (aCompiledMethod){
  606. var self=this;
  607. return smalltalk.withContext(function($ctx1) {
  608. self["@method"]=aCompiledMethod;
  609. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod},smalltalk.AIContext)})},
  610. args: ["aCompiledMethod"],
  611. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  612. messageSends: [],
  613. referencedClasses: []
  614. }),
  615. smalltalk.AIContext);
  616. smalltalk.addMethod(
  617. smalltalk.method({
  618. selector: "methodContext",
  619. category: 'accessing',
  620. fn: function (){
  621. var self=this;
  622. return smalltalk.withContext(function($ctx1) {
  623. var $1,$2,$4,$3;
  624. $1=self._isBlockContext();
  625. if(! smalltalk.assert($1)){
  626. $2=self;
  627. return $2;
  628. };
  629. $4=self._outerContext();
  630. if(($receiver = $4) == nil || $receiver == undefined){
  631. $3=$4;
  632. } else {
  633. var outer;
  634. outer=$receiver;
  635. $3=_st(outer)._methodContext();
  636. };
  637. return $3;
  638. }, function($ctx1) {$ctx1.fill(self,"methodContext",{},smalltalk.AIContext)})},
  639. args: [],
  640. source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self outerContext ifNotNil: [ :outer |\x0a\x09\x09outer methodContext ]",
  641. messageSends: ["ifFalse:", "isBlockContext", "ifNotNil:", "outerContext", "methodContext"],
  642. referencedClasses: []
  643. }),
  644. smalltalk.AIContext);
  645. smalltalk.addMethod(
  646. smalltalk.method({
  647. selector: "newBlockContext",
  648. category: 'factory',
  649. fn: function (){
  650. var self=this;
  651. return smalltalk.withContext(function($ctx1) {
  652. var $2,$3,$1;
  653. $2=_st(self._class())._new();
  654. _st($2)._outerContext_(self);
  655. $3=_st($2)._yourself();
  656. $1=$3;
  657. return $1;
  658. }, function($ctx1) {$ctx1.fill(self,"newBlockContext",{},smalltalk.AIContext)})},
  659. args: [],
  660. source: "newBlockContext\x0a\x09^ self class new\x0a\x09\x09outerContext: self;\x0a\x09\x09yourself",
  661. messageSends: ["outerContext:", "new", "class", "yourself"],
  662. referencedClasses: []
  663. }),
  664. smalltalk.AIContext);
  665. smalltalk.addMethod(
  666. smalltalk.method({
  667. selector: "outerContext",
  668. category: 'accessing',
  669. fn: function (){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) {
  672. var $1;
  673. $1=self["@outerContext"];
  674. return $1;
  675. }, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.AIContext)})},
  676. args: [],
  677. source: "outerContext\x0a\x09^ outerContext",
  678. messageSends: [],
  679. referencedClasses: []
  680. }),
  681. smalltalk.AIContext);
  682. smalltalk.addMethod(
  683. smalltalk.method({
  684. selector: "outerContext:",
  685. category: 'accessing',
  686. fn: function (anAIContext){
  687. var self=this;
  688. return smalltalk.withContext(function($ctx1) {
  689. self["@outerContext"]=anAIContext;
  690. _st(self["@outerContext"])._innerContext_(self);
  691. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  692. args: ["anAIContext"],
  693. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext innerContext: self",
  694. messageSends: ["innerContext:"],
  695. referencedClasses: []
  696. }),
  697. smalltalk.AIContext);
  698. smalltalk.addMethod(
  699. smalltalk.method({
  700. selector: "pc",
  701. category: 'interpreting',
  702. fn: function (){
  703. var self=this;
  704. return smalltalk.withContext(function($ctx1) {
  705. var $2,$1;
  706. $2=self["@pc"];
  707. if(($receiver = $2) == nil || $receiver == undefined){
  708. self["@pc"]=(0);
  709. $1=self["@pc"];
  710. } else {
  711. $1=$2;
  712. };
  713. return $1;
  714. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.AIContext)})},
  715. args: [],
  716. source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
  717. messageSends: ["ifNil:"],
  718. referencedClasses: []
  719. }),
  720. smalltalk.AIContext);
  721. smalltalk.addMethod(
  722. smalltalk.method({
  723. selector: "pc:",
  724. category: 'interpreting',
  725. fn: function (anInteger){
  726. var self=this;
  727. return smalltalk.withContext(function($ctx1) {
  728. self["@pc"]=anInteger;
  729. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.AIContext)})},
  730. args: ["anInteger"],
  731. source: "pc: anInteger\x0a\x09pc := anInteger",
  732. messageSends: [],
  733. referencedClasses: []
  734. }),
  735. smalltalk.AIContext);
  736. smalltalk.addMethod(
  737. smalltalk.method({
  738. selector: "receiver",
  739. category: 'interpreting',
  740. fn: function (){
  741. var self=this;
  742. return smalltalk.withContext(function($ctx1) {
  743. var $1;
  744. $1=self._localAt_("self");
  745. return $1;
  746. }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AIContext)})},
  747. args: [],
  748. source: "receiver\x0a\x09^ self localAt: 'self'",
  749. messageSends: ["localAt:"],
  750. referencedClasses: []
  751. }),
  752. smalltalk.AIContext);
  753. smalltalk.addMethod(
  754. smalltalk.method({
  755. selector: "receiver:",
  756. category: 'interpreting',
  757. fn: function (anObject){
  758. var self=this;
  759. return smalltalk.withContext(function($ctx1) {
  760. self._localAt_put_("self",anObject);
  761. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},smalltalk.AIContext)})},
  762. args: ["anObject"],
  763. source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
  764. messageSends: ["localAt:put:"],
  765. referencedClasses: []
  766. }),
  767. smalltalk.AIContext);
  768. smalltalk.addMethod(
  769. smalltalk.method({
  770. selector: "retrieveNode",
  771. category: 'interpreting',
  772. fn: function (){
  773. var self=this;
  774. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  775. return smalltalk.withContext(function($ctx1) {
  776. var $2,$3,$1;
  777. $2=_st($ASTPCNodeVisitor())._new();
  778. _st($2)._context_(self);
  779. _st($2)._visit_(self._ast());
  780. $3=_st($2)._currentNode();
  781. $1=$3;
  782. return $1;
  783. }, function($ctx1) {$ctx1.fill(self,"retrieveNode",{},smalltalk.AIContext)})},
  784. args: [],
  785. source: "retrieveNode\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09context: self;\x0a\x09\x09visit: self ast;\x0a\x09\x09currentNode",
  786. messageSends: ["context:", "new", "visit:", "ast", "currentNode"],
  787. referencedClasses: ["ASTPCNodeVisitor"]
  788. }),
  789. smalltalk.AIContext);
  790. smalltalk.addMethod(
  791. smalltalk.method({
  792. selector: "selector",
  793. category: 'accessing',
  794. fn: function (){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) {
  797. var $2,$1;
  798. $2=self._method();
  799. if(($receiver = $2) == nil || $receiver == undefined){
  800. $1=$2;
  801. } else {
  802. $1=_st(self._method())._selector();
  803. };
  804. return $1;
  805. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.AIContext)})},
  806. args: [],
  807. source: "selector\x0a\x09^ self method ifNotNil: [ \x0a\x09\x09self method selector ]",
  808. messageSends: ["ifNotNil:", "method", "selector"],
  809. referencedClasses: []
  810. }),
  811. smalltalk.AIContext);
  812. smalltalk.addMethod(
  813. smalltalk.method({
  814. selector: "setupInterpreter:",
  815. category: 'interpreting',
  816. fn: function (anInterpreter){
  817. var self=this;
  818. return smalltalk.withContext(function($ctx1) {
  819. _st(_st(_st(self._innerContext())._arguments())._reversed())._do_((function(each){
  820. return smalltalk.withContext(function($ctx2) {
  821. return _st(anInterpreter)._push_(each);
  822. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  823. _st(anInterpreter)._push_(_st(self._innerContext())._receiver());
  824. return self}, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
  825. args: ["anInterpreter"],
  826. source: "setupInterpreter: anInterpreter\x0a\x09\x22Push the send args and receiver to the interpreter stack\x22\x0a\x09\x0a\x09self innerContext arguments reversed do: [ :each | \x0a\x09\x09anInterpreter push: each ].\x0a\x09\x09\x0a\x09anInterpreter push: (self innerContext receiver)",
  827. messageSends: ["do:", "reversed", "arguments", "innerContext", "push:", "receiver"],
  828. referencedClasses: []
  829. }),
  830. smalltalk.AIContext);
  831. smalltalk.addMethod(
  832. smalltalk.method({
  833. selector: "fromMethodContext:",
  834. category: 'instance creation',
  835. fn: function (aMethodContext){
  836. var self=this;
  837. return smalltalk.withContext(function($ctx1) {
  838. var $2,$3,$1;
  839. $2=self._new();
  840. _st($2)._initializeFromMethodContext_(aMethodContext);
  841. $3=_st($2)._yourself();
  842. $1=$3;
  843. return $1;
  844. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext.klass)})},
  845. args: ["aMethodContext"],
  846. source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
  847. messageSends: ["initializeFromMethodContext:", "new", "yourself"],
  848. referencedClasses: []
  849. }),
  850. smalltalk.AIContext.klass);
  851. smalltalk.addClass('AIInterpreterError', smalltalk.Error, [], 'Compiler-Interpreter');
  852. smalltalk.AIInterpreterError.comment="I get signaled when an AST interpreter is unable to interpret a node.";
  853. smalltalk.addClass('ASTDebugger', smalltalk.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
  854. smalltalk.ASTDebugger.comment="I am a stepping debugger interface for Amber code.\x0aI internally use an instance of `ASTSteppingInterpreter` to actually step through node and interpret them.\x0a\x0aMy instances are created from a `MethodContext` with `ASTDebugger class >> context:`.\x0aThey hold an `AIContext` instance internally, recursive copy of the `MethodContext`.\x0a\x0a## API\x0a\x0aUse the methods of the `'stepping'` protocol to do stepping.";
  855. smalltalk.addMethod(
  856. smalltalk.method({
  857. selector: "atEnd",
  858. category: 'testing',
  859. fn: function (){
  860. var self=this;
  861. return smalltalk.withContext(function($ctx1) {
  862. var $1;
  863. $1=_st(self._interpreter())._atEnd();
  864. return $1;
  865. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTDebugger)})},
  866. args: [],
  867. source: "atEnd\x0a\x09^ self interpreter atEnd",
  868. messageSends: ["atEnd", "interpreter"],
  869. referencedClasses: []
  870. }),
  871. smalltalk.ASTDebugger);
  872. smalltalk.addMethod(
  873. smalltalk.method({
  874. selector: "buildAST",
  875. category: 'initialization',
  876. fn: function (){
  877. var self=this;
  878. var ast;
  879. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  880. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  881. return smalltalk.withContext(function($ctx1) {
  882. var $1;
  883. ast=_st(_st($Smalltalk())._current())._parse_(_st(self._method())._source());
  884. _st(_st($SemanticAnalyzer())._on_(_st(_st(self._context())._receiver())._class()))._visit_(ast);
  885. $1=ast;
  886. return $1;
  887. }, function($ctx1) {$ctx1.fill(self,"buildAST",{ast:ast},smalltalk.ASTDebugger)})},
  888. args: [],
  889. source: "buildAST\x0a\x09\x22Build the AST tree from the method source code.\x0a\x09The AST is annotated with a SemanticAnalyzer,\x0a\x09to know the semantics and bindings of each node needed for later debugging\x22\x0a\x09\x0a\x09| ast |\x0a\x09\x0a\x09ast := Smalltalk current parse: self method source.\x0a\x09(SemanticAnalyzer on: self context receiver class)\x0a\x09\x09visit: ast.\x0a\x09\x0a\x09^ ast",
  890. messageSends: ["parse:", "current", "source", "method", "visit:", "on:", "class", "receiver", "context"],
  891. referencedClasses: ["Smalltalk", "SemanticAnalyzer"]
  892. }),
  893. smalltalk.ASTDebugger);
  894. smalltalk.addMethod(
  895. smalltalk.method({
  896. selector: "context",
  897. category: 'accessing',
  898. fn: function (){
  899. var self=this;
  900. return smalltalk.withContext(function($ctx1) {
  901. var $1;
  902. $1=self["@context"];
  903. return $1;
  904. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTDebugger)})},
  905. args: [],
  906. source: "context\x0a\x09^ context",
  907. messageSends: [],
  908. referencedClasses: []
  909. }),
  910. smalltalk.ASTDebugger);
  911. smalltalk.addMethod(
  912. smalltalk.method({
  913. selector: "context:",
  914. category: 'accessing',
  915. fn: function (aContext){
  916. var self=this;
  917. return smalltalk.withContext(function($ctx1) {
  918. self["@context"]=aContext;
  919. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger)})},
  920. args: ["aContext"],
  921. source: "context: aContext\x0a\x09context := aContext",
  922. messageSends: [],
  923. referencedClasses: []
  924. }),
  925. smalltalk.ASTDebugger);
  926. smalltalk.addMethod(
  927. smalltalk.method({
  928. selector: "defaultInterpreterClass",
  929. category: 'defaults',
  930. fn: function (){
  931. var self=this;
  932. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  933. return smalltalk.withContext(function($ctx1) {
  934. var $1;
  935. $1=$ASTSteppingInterpreter();
  936. return $1;
  937. }, function($ctx1) {$ctx1.fill(self,"defaultInterpreterClass",{},smalltalk.ASTDebugger)})},
  938. args: [],
  939. source: "defaultInterpreterClass\x0a\x09^ ASTSteppingInterpreter",
  940. messageSends: [],
  941. referencedClasses: ["ASTSteppingInterpreter"]
  942. }),
  943. smalltalk.ASTDebugger);
  944. smalltalk.addMethod(
  945. smalltalk.method({
  946. selector: "initializeInterpreter",
  947. category: 'initialization',
  948. fn: function (){
  949. var self=this;
  950. var ast,next;
  951. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  952. return smalltalk.withContext(function($ctx1) {
  953. var $1,$2;
  954. ast=self._buildAST();
  955. $1=_st($ASTPCNodeVisitor())._new();
  956. _st($1)._context_(self._context());
  957. _st($1)._visit_(ast);
  958. $2=_st($1)._currentNode();
  959. next=$2;
  960. _st(self._interpreter())._interpret_(next);
  961. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{ast:ast,next:next},smalltalk.ASTDebugger)})},
  962. args: [],
  963. source: "initializeInterpreter\x0a\x09| ast next |\x0a\x09ast := self buildAST.\x0a\x09next := ASTPCNodeVisitor new\x0a\x09\x09context: self context;\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode.\x0a\x09self interpreter interpret: next",
  964. messageSends: ["buildAST", "context:", "new", "context", "visit:", "currentNode", "interpret:", "interpreter"],
  965. referencedClasses: ["ASTPCNodeVisitor"]
  966. }),
  967. smalltalk.ASTDebugger);
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "initializeWithContext:",
  971. category: 'initialization',
  972. fn: function (aContext){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. self._context_(aContext);
  976. self._initializeInterpreter();
  977. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:",{aContext:aContext},smalltalk.ASTDebugger)})},
  978. args: ["aContext"],
  979. source: "initializeWithContext: aContext\x0a\x09\x22TODO: do we need to handle block contexts?\x22\x0a\x09\x0a\x09self context: aContext.\x0a\x09self initializeInterpreter",
  980. messageSends: ["context:", "initializeInterpreter"],
  981. referencedClasses: []
  982. }),
  983. smalltalk.ASTDebugger);
  984. smalltalk.addMethod(
  985. smalltalk.method({
  986. selector: "interpreter",
  987. category: 'accessing',
  988. fn: function (){
  989. var self=this;
  990. return smalltalk.withContext(function($ctx1) {
  991. var $2,$1;
  992. $2=self["@interpreter"];
  993. if(($receiver = $2) == nil || $receiver == undefined){
  994. self["@interpreter"]=_st(self._defaultInterpreterClass())._new();
  995. $1=self["@interpreter"];
  996. } else {
  997. $1=$2;
  998. };
  999. return $1;
  1000. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTDebugger)})},
  1001. args: [],
  1002. source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := self defaultInterpreterClass new ]",
  1003. messageSends: ["ifNil:", "new", "defaultInterpreterClass"],
  1004. referencedClasses: []
  1005. }),
  1006. smalltalk.ASTDebugger);
  1007. smalltalk.addMethod(
  1008. smalltalk.method({
  1009. selector: "interpreter:",
  1010. category: 'accessing',
  1011. fn: function (anInterpreter){
  1012. var self=this;
  1013. return smalltalk.withContext(function($ctx1) {
  1014. self["@interpreter"]=anInterpreter;
  1015. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.ASTDebugger)})},
  1016. args: ["anInterpreter"],
  1017. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  1018. messageSends: [],
  1019. referencedClasses: []
  1020. }),
  1021. smalltalk.ASTDebugger);
  1022. smalltalk.addMethod(
  1023. smalltalk.method({
  1024. selector: "method",
  1025. category: 'accessing',
  1026. fn: function (){
  1027. var self=this;
  1028. return smalltalk.withContext(function($ctx1) {
  1029. var $1;
  1030. $1=_st(self._context())._method();
  1031. return $1;
  1032. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.ASTDebugger)})},
  1033. args: [],
  1034. source: "method\x0a\x09^ self context method",
  1035. messageSends: ["method", "context"],
  1036. referencedClasses: []
  1037. }),
  1038. smalltalk.ASTDebugger);
  1039. smalltalk.addMethod(
  1040. smalltalk.method({
  1041. selector: "nextNode",
  1042. category: 'accessing',
  1043. fn: function (){
  1044. var self=this;
  1045. return smalltalk.withContext(function($ctx1) {
  1046. var $1;
  1047. $1=_st(self._interpreter())._nextNode();
  1048. return $1;
  1049. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTDebugger)})},
  1050. args: [],
  1051. source: "nextNode\x0a\x09^ self interpreter nextNode",
  1052. messageSends: ["nextNode", "interpreter"],
  1053. referencedClasses: []
  1054. }),
  1055. smalltalk.ASTDebugger);
  1056. smalltalk.addMethod(
  1057. smalltalk.method({
  1058. selector: "proceed",
  1059. category: 'stepping',
  1060. fn: function (){
  1061. var self=this;
  1062. return smalltalk.withContext(function($ctx1) {
  1063. self._shouldBeImplemented();
  1064. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTDebugger)})},
  1065. args: [],
  1066. source: "proceed\x0a\x09self shouldBeImplemented",
  1067. messageSends: ["shouldBeImplemented"],
  1068. referencedClasses: []
  1069. }),
  1070. smalltalk.ASTDebugger);
  1071. smalltalk.addMethod(
  1072. smalltalk.method({
  1073. selector: "restart",
  1074. category: 'stepping',
  1075. fn: function (){
  1076. var self=this;
  1077. return smalltalk.withContext(function($ctx1) {
  1078. self._shouldBeImplemented();
  1079. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTDebugger)})},
  1080. args: [],
  1081. source: "restart\x0a\x09self shouldBeImplemented",
  1082. messageSends: ["shouldBeImplemented"],
  1083. referencedClasses: []
  1084. }),
  1085. smalltalk.ASTDebugger);
  1086. smalltalk.addMethod(
  1087. smalltalk.method({
  1088. selector: "step",
  1089. category: 'stepping',
  1090. fn: function (){
  1091. var self=this;
  1092. return smalltalk.withContext(function($ctx1) {
  1093. _st((function(){
  1094. return smalltalk.withContext(function($ctx2) {
  1095. return _st(_st(_st(_st(self._interpreter())._nextNode())._notNil())._and_((function(){
  1096. return smalltalk.withContext(function($ctx3) {
  1097. return _st(_st(self._interpreter())._nextNode())._stopOnStepping();
  1098. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})))._or_((function(){
  1099. return smalltalk.withContext(function($ctx3) {
  1100. return _st(_st(self._interpreter())._atEnd())._not();
  1101. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1102. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1103. return smalltalk.withContext(function($ctx2) {
  1104. _st(self._interpreter())._step();
  1105. return self._step();
  1106. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
  1107. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTDebugger)})},
  1108. args: [],
  1109. source: "step\x0a\x09\x22The ASTSteppingInterpreter stops at each node interpretation.\x0a\x09One step will interpret nodes until:\x0a\x09- we get at the end\x0a\x09- the next node is a stepping node (send, assignment, etc.)\x22\x0a\x09\x0a\x09[ (self interpreter nextNode notNil and: [ self interpreter nextNode stopOnStepping ])\x0a\x09\x09or: [ self interpreter atEnd not ] ]\x0a\x09\x09\x09whileFalse: [\x0a\x09\x09\x09\x09self interpreter step.\x0a\x09\x09\x09\x09self step ]",
  1110. messageSends: ["whileFalse:", "or:", "and:", "notNil", "nextNode", "interpreter", "stopOnStepping", "not", "atEnd", "step"],
  1111. referencedClasses: []
  1112. }),
  1113. smalltalk.ASTDebugger);
  1114. smalltalk.addMethod(
  1115. smalltalk.method({
  1116. selector: "stepInto",
  1117. category: 'stepping',
  1118. fn: function (){
  1119. var self=this;
  1120. return smalltalk.withContext(function($ctx1) {
  1121. self._shouldBeImplemented();
  1122. return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},smalltalk.ASTDebugger)})},
  1123. args: [],
  1124. source: "stepInto\x0a\x09self shouldBeImplemented",
  1125. messageSends: ["shouldBeImplemented"],
  1126. referencedClasses: []
  1127. }),
  1128. smalltalk.ASTDebugger);
  1129. smalltalk.addMethod(
  1130. smalltalk.method({
  1131. selector: "stepOver",
  1132. category: 'stepping',
  1133. fn: function (){
  1134. var self=this;
  1135. return smalltalk.withContext(function($ctx1) {
  1136. self._step();
  1137. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTDebugger)})},
  1138. args: [],
  1139. source: "stepOver\x0a\x09self step",
  1140. messageSends: ["step"],
  1141. referencedClasses: []
  1142. }),
  1143. smalltalk.ASTDebugger);
  1144. smalltalk.addMethod(
  1145. smalltalk.method({
  1146. selector: "context:",
  1147. category: 'instance creation',
  1148. fn: function (aContext){
  1149. var self=this;
  1150. return smalltalk.withContext(function($ctx1) {
  1151. var $2,$3,$1;
  1152. $2=self._new();
  1153. _st($2)._initializeWithContext_(aContext);
  1154. $3=_st($2)._yourself();
  1155. $1=$3;
  1156. return $1;
  1157. }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger.klass)})},
  1158. args: ["aContext"],
  1159. source: "context: aContext\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext;\x0a\x09\x09yourself",
  1160. messageSends: ["initializeWithContext:", "new", "yourself"],
  1161. referencedClasses: []
  1162. }),
  1163. smalltalk.ASTDebugger.klass);
  1164. smalltalk.addClass('ASTInterpreter', smalltalk.Object, ['currentNode', 'nextNode', 'context', 'shouldReturn', 'result'], 'Compiler-Interpreter');
  1165. smalltalk.ASTInterpreter.comment="I am like a `NodeVisitor`, interpreting nodes one after each other.\x0aI am built using Continuation Passing Style for stepping purposes.\x0a\x0a## Usage example:\x0a\x0a\x09| ast interpreter |\x0a\x09ast := Smalltalk current parse: 'foo 1+2+4'.\x0a\x09(SemanticAnalyzer on: Object) visit: ast.\x0a\x0a\x09ASTInterpreter new\x0a\x09\x09interpret: ast nodes first;\x0a\x09\x09result \x22Answers 7\x22";
  1166. smalltalk.addMethod(
  1167. smalltalk.method({
  1168. selector: "assign:to:",
  1169. category: 'private',
  1170. fn: function (aNode,anObject){
  1171. var self=this;
  1172. return smalltalk.withContext(function($ctx1) {
  1173. var $2,$1;
  1174. $2=_st(_st(aNode)._binding())._isInstanceVar();
  1175. if(smalltalk.assert($2)){
  1176. $1=_st(_st(self._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  1177. } else {
  1178. $1=_st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
  1179. };
  1180. return $1;
  1181. }, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.ASTInterpreter)})},
  1182. args: ["aNode", "anObject"],
  1183. source: "assign: aNode to: anObject\x0a\x09^ aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value put: anObject ]",
  1184. messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
  1185. referencedClasses: []
  1186. }),
  1187. smalltalk.ASTInterpreter);
  1188. smalltalk.addMethod(
  1189. smalltalk.method({
  1190. selector: "context",
  1191. category: 'accessing',
  1192. fn: function (){
  1193. var self=this;
  1194. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  1195. return smalltalk.withContext(function($ctx1) {
  1196. var $2,$1;
  1197. $2=self["@context"];
  1198. if(($receiver = $2) == nil || $receiver == undefined){
  1199. self["@context"]=_st($AIContext())._new();
  1200. $1=self["@context"];
  1201. } else {
  1202. $1=$2;
  1203. };
  1204. return $1;
  1205. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTInterpreter)})},
  1206. args: [],
  1207. source: "context\x0a\x09^ context ifNil: [ context := AIContext new ]",
  1208. messageSends: ["ifNil:", "new"],
  1209. referencedClasses: ["AIContext"]
  1210. }),
  1211. smalltalk.ASTInterpreter);
  1212. smalltalk.addMethod(
  1213. smalltalk.method({
  1214. selector: "context:",
  1215. category: 'accessing',
  1216. fn: function (anAIContext){
  1217. var self=this;
  1218. return smalltalk.withContext(function($ctx1) {
  1219. self["@context"]=anAIContext;
  1220. return self}, function($ctx1) {$ctx1.fill(self,"context:",{anAIContext:anAIContext},smalltalk.ASTInterpreter)})},
  1221. args: ["anAIContext"],
  1222. source: "context: anAIContext\x0a\x09context := anAIContext",
  1223. messageSends: [],
  1224. referencedClasses: []
  1225. }),
  1226. smalltalk.ASTInterpreter);
  1227. smalltalk.addMethod(
  1228. smalltalk.method({
  1229. selector: "continue:value:",
  1230. category: 'private',
  1231. fn: function (aBlock,anObject){
  1232. var self=this;
  1233. return smalltalk.withContext(function($ctx1) {
  1234. self["@result"]=anObject;
  1235. _st(aBlock)._value_(anObject);
  1236. return self}, function($ctx1) {$ctx1.fill(self,"continue:value:",{aBlock:aBlock,anObject:anObject},smalltalk.ASTInterpreter)})},
  1237. args: ["aBlock", "anObject"],
  1238. source: "continue: aBlock value: anObject\x0a\x09result := anObject.\x0a\x09aBlock value: anObject",
  1239. messageSends: ["value:"],
  1240. referencedClasses: []
  1241. }),
  1242. smalltalk.ASTInterpreter);
  1243. smalltalk.addMethod(
  1244. smalltalk.method({
  1245. selector: "currentNode",
  1246. category: 'accessing',
  1247. fn: function (){
  1248. var self=this;
  1249. return smalltalk.withContext(function($ctx1) {
  1250. var $1;
  1251. $1=self["@currentNode"];
  1252. return $1;
  1253. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTInterpreter)})},
  1254. args: [],
  1255. source: "currentNode\x0a\x09^ currentNode",
  1256. messageSends: [],
  1257. referencedClasses: []
  1258. }),
  1259. smalltalk.ASTInterpreter);
  1260. smalltalk.addMethod(
  1261. smalltalk.method({
  1262. selector: "eval:",
  1263. category: 'private',
  1264. fn: function (aString){
  1265. var self=this;
  1266. var source,function_;
  1267. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1268. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1269. return smalltalk.withContext(function($ctx1) {
  1270. var $1,$2,$3;
  1271. source=_st($String())._streamContents_((function(str){
  1272. return smalltalk.withContext(function($ctx2) {
  1273. _st(str)._nextPutAll_("(function(");
  1274. _st(_st(_st(self._context())._locals())._keys())._do_separatedBy_((function(each){
  1275. return smalltalk.withContext(function($ctx3) {
  1276. return _st(str)._nextPutAll_(each);
  1277. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
  1278. return smalltalk.withContext(function($ctx3) {
  1279. return _st(str)._nextPutAll_(",");
  1280. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1281. $1=str;
  1282. _st($1)._nextPutAll_("){ return (function() {");
  1283. _st($1)._nextPutAll_(aString);
  1284. $2=_st($1)._nextPutAll_("})() })");
  1285. return $2;
  1286. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
  1287. function_=_st(_st($Compiler())._new())._eval_(source);
  1288. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
  1289. return $3;
  1290. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.ASTInterpreter)})},
  1291. args: ["aString"],
  1292. source: "eval: aString\x0a\x09\x22Evaluate aString as JS source inside an JS function.\x0a\x09aString is not sandboxed.\x22\x0a\x09\x0a\x09| source function |\x0a\x09\x0a\x09source := String streamContents: [ :str |\x0a\x09\x09str nextPutAll: '(function('.\x0a\x09\x09self context locals keys\x0a\x09\x09\x09do: [ :each | str nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ str nextPutAll: ',' ].\x0a\x09\x09str\x0a\x09\x09\x09nextPutAll: '){ return (function() {';\x0a\x09\x09\x09nextPutAll: aString;\x0a\x09\x09\x09nextPutAll: '})() })' ].\x0a\x09\x09\x09\x0a\x09function := Compiler new eval: source.\x0a\x09\x0a\x09^ function valueWithPossibleArguments: self context locals values",
  1293. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  1294. referencedClasses: ["String", "Compiler"]
  1295. }),
  1296. smalltalk.ASTInterpreter);
  1297. smalltalk.addMethod(
  1298. smalltalk.method({
  1299. selector: "initialize",
  1300. category: 'initialization',
  1301. fn: function (){
  1302. var self=this;
  1303. return smalltalk.withContext(function($ctx1) {
  1304. smalltalk.ASTInterpreter.superclass.fn.prototype._initialize.apply(_st(self), []);
  1305. self["@shouldReturn"]=false;
  1306. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ASTInterpreter)})},
  1307. args: [],
  1308. source: "initialize\x0a\x09super initialize.\x0a\x09shouldReturn := false",
  1309. messageSends: ["initialize"],
  1310. referencedClasses: []
  1311. }),
  1312. smalltalk.ASTInterpreter);
  1313. smalltalk.addMethod(
  1314. smalltalk.method({
  1315. selector: "interpret:",
  1316. category: 'interpreting',
  1317. fn: function (aNode){
  1318. var self=this;
  1319. return smalltalk.withContext(function($ctx1) {
  1320. self["@shouldReturn"]=false;
  1321. self._interpret_continue_(aNode,(function(value){
  1322. return smalltalk.withContext(function($ctx2) {
  1323. self["@result"]=value;
  1324. return self["@result"];
  1325. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}));
  1326. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1327. args: ["aNode"],
  1328. source: "interpret: aNode\x0a\x09shouldReturn := false.\x0a\x09self interpret: aNode continue: [ :value |\x0a\x09\x09result := value ]",
  1329. messageSends: ["interpret:continue:"],
  1330. referencedClasses: []
  1331. }),
  1332. smalltalk.ASTInterpreter);
  1333. smalltalk.addMethod(
  1334. smalltalk.method({
  1335. selector: "interpret:continue:",
  1336. category: 'interpreting',
  1337. fn: function (aNode,aBlock){
  1338. var self=this;
  1339. return smalltalk.withContext(function($ctx1) {
  1340. var $1,$2,$3;
  1341. $1=self["@shouldReturn"];
  1342. if(smalltalk.assert($1)){
  1343. $2=self;
  1344. return $2;
  1345. };
  1346. $3=_st(aNode)._isNode();
  1347. if(smalltalk.assert($3)){
  1348. self["@currentNode"]=aNode;
  1349. self["@currentNode"];
  1350. self._interpretNode_continue_(aNode,(function(value){
  1351. return smalltalk.withContext(function($ctx2) {
  1352. return self._continue_value_(aBlock,value);
  1353. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,3)})}));
  1354. } else {
  1355. self._continue_value_(aBlock,aNode);
  1356. };
  1357. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1358. args: ["aNode", "aBlock"],
  1359. source: "interpret: aNode continue: aBlock\x0a\x09shouldReturn ifTrue: [ ^ self ].\x0a\x0a\x09aNode isNode\x0a\x09\x09ifTrue: [\x0a\x09\x09\x09currentNode := aNode.\x0a\x09\x09\x09self interpretNode: aNode continue: [ :value |\x0a\x09\x09\x09\x09self continue: aBlock value: value ] ]\x0a\x09\x09ifFalse: [ self continue: aBlock value: aNode ]",
  1360. messageSends: ["ifTrue:", "ifTrue:ifFalse:", "isNode", "interpretNode:continue:", "continue:value:"],
  1361. referencedClasses: []
  1362. }),
  1363. smalltalk.ASTInterpreter);
  1364. smalltalk.addMethod(
  1365. smalltalk.method({
  1366. selector: "interpretAll:continue:",
  1367. category: 'private',
  1368. fn: function (aCollection,aBlock){
  1369. var self=this;
  1370. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1371. return smalltalk.withContext(function($ctx1) {
  1372. self._interpretAll_continue_result_(aCollection,aBlock,_st($OrderedCollection())._new());
  1373. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:",{aCollection:aCollection,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1374. args: ["aCollection", "aBlock"],
  1375. source: "interpretAll: aCollection continue: aBlock\x0a\x09self\x0a\x09\x09interpretAll: aCollection\x0a\x09\x09continue: aBlock\x0a\x09\x09result: OrderedCollection new",
  1376. messageSends: ["interpretAll:continue:result:", "new"],
  1377. referencedClasses: ["OrderedCollection"]
  1378. }),
  1379. smalltalk.ASTInterpreter);
  1380. smalltalk.addMethod(
  1381. smalltalk.method({
  1382. selector: "interpretAll:continue:result:",
  1383. category: 'private',
  1384. fn: function (nodes,aBlock,aCollection){
  1385. var self=this;
  1386. return smalltalk.withContext(function($ctx1) {
  1387. var $1;
  1388. $1=_st(nodes)._isEmpty();
  1389. if(smalltalk.assert($1)){
  1390. self._continue_value_(aBlock,aCollection);
  1391. } else {
  1392. self._interpret_continue_(_st(nodes)._first(),(function(value){
  1393. return smalltalk.withContext(function($ctx2) {
  1394. return self._interpretAll_continue_result_(_st(nodes)._allButFirst(),aBlock,_st(aCollection).__comma([value]));
  1395. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,3)})}));
  1396. };
  1397. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:result:",{nodes:nodes,aBlock:aBlock,aCollection:aCollection},smalltalk.ASTInterpreter)})},
  1398. args: ["nodes", "aBlock", "aCollection"],
  1399. source: "interpretAll: nodes continue: aBlock result: aCollection\x0a\x09nodes isEmpty\x0a\x09\x09ifTrue: [ self continue: aBlock value: aCollection ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09self interpret: nodes first continue: [:value |\x0a\x09\x09\x09\x09self\x0a\x09\x09\x09\x09\x09interpretAll: nodes allButFirst\x0a\x09\x09\x09\x09\x09continue: aBlock\x0a\x09\x09\x09\x09\x09result: aCollection, { value } ] ]",
  1400. messageSends: ["ifTrue:ifFalse:", "isEmpty", "continue:value:", "interpret:continue:", "first", "interpretAll:continue:result:", "allButFirst", ","],
  1401. referencedClasses: []
  1402. }),
  1403. smalltalk.ASTInterpreter);
  1404. smalltalk.addMethod(
  1405. smalltalk.method({
  1406. selector: "interpretAssignmentNode:continue:",
  1407. category: 'interpreting',
  1408. fn: function (aNode,aBlock){
  1409. var self=this;
  1410. return smalltalk.withContext(function($ctx1) {
  1411. self._interpret_continue_(_st(aNode)._right(),(function(value){
  1412. return smalltalk.withContext(function($ctx2) {
  1413. return self._continue_value_(aBlock,self._assign_to_(_st(aNode)._left(),value));
  1414. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}));
  1415. return self}, function($ctx1) {$ctx1.fill(self,"interpretAssignmentNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1416. args: ["aNode", "aBlock"],
  1417. source: "interpretAssignmentNode: aNode continue: aBlock\x0a\x09self interpret: aNode right continue: [ :value |\x0a\x09\x09self\x0a\x09\x09\x09continue: aBlock\x0a\x09\x09\x09value: (self assign: aNode left to: value) ]",
  1418. messageSends: ["interpret:continue:", "right", "continue:value:", "assign:to:", "left"],
  1419. referencedClasses: []
  1420. }),
  1421. smalltalk.ASTInterpreter);
  1422. smalltalk.addMethod(
  1423. smalltalk.method({
  1424. selector: "interpretBlockNode:continue:",
  1425. category: 'interpreting',
  1426. fn: function (aNode,aBlock){
  1427. var self=this;
  1428. return smalltalk.withContext(function($ctx1) {
  1429. var $1,$2;
  1430. self._continue_value_(aBlock,(function(){
  1431. return smalltalk.withContext(function($ctx2) {
  1432. return self._withBlockContext_((function(){
  1433. return smalltalk.withContext(function($ctx3) {
  1434. $1=self;
  1435. _st($1)._interpret_(_st(_st(aNode)._nodes())._first());
  1436. $2=_st($1)._result();
  1437. return $2;
  1438. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  1439. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1440. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1441. args: ["aNode", "aBlock"],
  1442. source: "interpretBlockNode: aNode continue: aBlock\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: [ \x0a\x09\x09\x09self withBlockContext: [ \x0a\x09\x09\x09\x09self interpret: aNode nodes first; result ] ]",
  1443. messageSends: ["continue:value:", "withBlockContext:", "interpret:", "first", "nodes", "result"],
  1444. referencedClasses: []
  1445. }),
  1446. smalltalk.ASTInterpreter);
  1447. smalltalk.addMethod(
  1448. smalltalk.method({
  1449. selector: "interpretBlockSequenceNode:continue:",
  1450. category: 'interpreting',
  1451. fn: function (aNode,aBlock){
  1452. var self=this;
  1453. return smalltalk.withContext(function($ctx1) {
  1454. self._interpretSequenceNode_continue_(aNode,aBlock);
  1455. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockSequenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1456. args: ["aNode", "aBlock"],
  1457. source: "interpretBlockSequenceNode: aNode continue: aBlock\x0a\x09self interpretSequenceNode: aNode continue: aBlock",
  1458. messageSends: ["interpretSequenceNode:continue:"],
  1459. referencedClasses: []
  1460. }),
  1461. smalltalk.ASTInterpreter);
  1462. smalltalk.addMethod(
  1463. smalltalk.method({
  1464. selector: "interpretCascadeNode:continue:",
  1465. category: 'interpreting',
  1466. fn: function (aNode,aBlock){
  1467. var self=this;
  1468. return smalltalk.withContext(function($ctx1) {
  1469. self._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  1470. return smalltalk.withContext(function($ctx2) {
  1471. _st(_st(aNode)._nodes())._do_((function(each){
  1472. return smalltalk.withContext(function($ctx3) {
  1473. return _st(each)._receiver_(receiver);
  1474. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}));
  1475. return self._interpretAll_continue_(_st(_st(aNode)._nodes())._allButLast(),(function(){
  1476. return smalltalk.withContext(function($ctx3) {
  1477. return self._interpret_continue_(_st(_st(aNode)._nodes())._last(),(function(val){
  1478. return smalltalk.withContext(function($ctx4) {
  1479. return self._continue_value_(aBlock,val);
  1480. }, function($ctx4) {$ctx4.fillBlock({val:val},$ctx3,4)})}));
  1481. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1482. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1,1)})}));
  1483. return self}, function($ctx1) {$ctx1.fill(self,"interpretCascadeNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1484. args: ["aNode", "aBlock"],
  1485. source: "interpretCascadeNode: aNode continue: aBlock\x0a\x09\x22TODO: Handle super sends\x22\x0a\x09\x0a\x09self interpret: aNode receiver continue: [ :receiver |\x0a\x09\x09\x22Only interpret the receiver once\x22\x0a\x09\x09aNode nodes do: [ :each | each receiver: receiver ].\x0a\x0a\x09\x09self\x0a\x09\x09\x09interpretAll: aNode nodes allButLast\x0a\x09\x09\x09continue: [\x0a\x09\x09\x09\x09self\x0a\x09\x09\x09\x09\x09interpret: aNode nodes last\x0a\x09\x09\x09\x09\x09continue: [ :val | self continue: aBlock value: val ] ] ]",
  1486. messageSends: ["interpret:continue:", "receiver", "do:", "nodes", "receiver:", "interpretAll:continue:", "allButLast", "last", "continue:value:"],
  1487. referencedClasses: []
  1488. }),
  1489. smalltalk.ASTInterpreter);
  1490. smalltalk.addMethod(
  1491. smalltalk.method({
  1492. selector: "interpretClassReferenceNode:continue:",
  1493. category: 'interpreting',
  1494. fn: function (aNode,aBlock){
  1495. var self=this;
  1496. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1497. return smalltalk.withContext(function($ctx1) {
  1498. self._continue_value_(aBlock,_st(_st($Smalltalk())._current())._at_(_st(aNode)._value()));
  1499. return self}, function($ctx1) {$ctx1.fill(self,"interpretClassReferenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1500. args: ["aNode", "aBlock"],
  1501. source: "interpretClassReferenceNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: (Smalltalk current at: aNode value)",
  1502. messageSends: ["continue:value:", "at:", "current", "value"],
  1503. referencedClasses: ["Smalltalk"]
  1504. }),
  1505. smalltalk.ASTInterpreter);
  1506. smalltalk.addMethod(
  1507. smalltalk.method({
  1508. selector: "interpretDynamicArrayNode:continue:",
  1509. category: 'interpreting',
  1510. fn: function (aNode,aBlock){
  1511. var self=this;
  1512. return smalltalk.withContext(function($ctx1) {
  1513. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1514. return smalltalk.withContext(function($ctx2) {
  1515. return self._continue_value_(aBlock,array);
  1516. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1,1)})}));
  1517. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicArrayNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1518. args: ["aNode", "aBlock"],
  1519. source: "interpretDynamicArrayNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self\x0a\x09\x09\x09continue: aBlock\x0a\x09\x09\x09value: array ]",
  1520. messageSends: ["interpretAll:continue:", "nodes", "continue:value:"],
  1521. referencedClasses: []
  1522. }),
  1523. smalltalk.ASTInterpreter);
  1524. smalltalk.addMethod(
  1525. smalltalk.method({
  1526. selector: "interpretDynamicDictionaryNode:continue:",
  1527. category: 'interpreting',
  1528. fn: function (aNode,aBlock){
  1529. var self=this;
  1530. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1531. return smalltalk.withContext(function($ctx1) {
  1532. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1533. var hashedCollection;
  1534. return smalltalk.withContext(function($ctx2) {
  1535. hashedCollection=_st($HashedCollection())._new();
  1536. hashedCollection;
  1537. _st(array)._do_((function(each){
  1538. return smalltalk.withContext(function($ctx3) {
  1539. return _st(hashedCollection)._add_(each);
  1540. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}));
  1541. return self._continue_value_(aBlock,hashedCollection);
  1542. }, function($ctx2) {$ctx2.fillBlock({array:array,hashedCollection:hashedCollection},$ctx1,1)})}));
  1543. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicDictionaryNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1544. args: ["aNode", "aBlock"],
  1545. source: "interpretDynamicDictionaryNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array | | hashedCollection |\x0a\x09\x09hashedCollection := HashedCollection new.\x0a\x09\x09array do: [ :each | hashedCollection add: each ].\x0a\x09\x09self\x0a\x09\x09\x09continue: aBlock\x0a\x09\x09\x09value: hashedCollection ]",
  1546. messageSends: ["interpretAll:continue:", "nodes", "new", "do:", "add:", "continue:value:"],
  1547. referencedClasses: ["HashedCollection"]
  1548. }),
  1549. smalltalk.ASTInterpreter);
  1550. smalltalk.addMethod(
  1551. smalltalk.method({
  1552. selector: "interpretJSStatementNode:continue:",
  1553. category: 'interpreting',
  1554. fn: function (aNode,aBlock){
  1555. var self=this;
  1556. return smalltalk.withContext(function($ctx1) {
  1557. self["@shouldReturn"]=true;
  1558. self._continue_value_(aBlock,self._eval_(_st(aNode)._source()));
  1559. return self}, function($ctx1) {$ctx1.fill(self,"interpretJSStatementNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1560. args: ["aNode", "aBlock"],
  1561. source: "interpretJSStatementNode: aNode continue: aBlock\x0a\x09shouldReturn := true.\x0a\x09self continue: aBlock value: (self eval: aNode source)",
  1562. messageSends: ["continue:value:", "eval:", "source"],
  1563. referencedClasses: []
  1564. }),
  1565. smalltalk.ASTInterpreter);
  1566. smalltalk.addMethod(
  1567. smalltalk.method({
  1568. selector: "interpretMethodNode:continue:",
  1569. category: 'interpreting',
  1570. fn: function (aNode,aBlock){
  1571. var self=this;
  1572. return smalltalk.withContext(function($ctx1) {
  1573. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1574. return smalltalk.withContext(function($ctx2) {
  1575. return self._continue_value_(aBlock,_st(array)._first());
  1576. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1,1)})}));
  1577. return self}, function($ctx1) {$ctx1.fill(self,"interpretMethodNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1578. args: ["aNode", "aBlock"],
  1579. source: "interpretMethodNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self continue: aBlock value: array first ]",
  1580. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "first"],
  1581. referencedClasses: []
  1582. }),
  1583. smalltalk.ASTInterpreter);
  1584. smalltalk.addMethod(
  1585. smalltalk.method({
  1586. selector: "interpretNode:continue:",
  1587. category: 'interpreting',
  1588. fn: function (aNode,aBlock){
  1589. var self=this;
  1590. return smalltalk.withContext(function($ctx1) {
  1591. _st(aNode)._interpreter_continue_(self,aBlock);
  1592. return self}, function($ctx1) {$ctx1.fill(self,"interpretNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1593. args: ["aNode", "aBlock"],
  1594. source: "interpretNode: aNode continue: aBlock\x0a\x09aNode interpreter: self continue: aBlock",
  1595. messageSends: ["interpreter:continue:"],
  1596. referencedClasses: []
  1597. }),
  1598. smalltalk.ASTInterpreter);
  1599. smalltalk.addMethod(
  1600. smalltalk.method({
  1601. selector: "interpretReturnNode:continue:",
  1602. category: 'interpreting',
  1603. fn: function (aNode,aBlock){
  1604. var self=this;
  1605. return smalltalk.withContext(function($ctx1) {
  1606. self._interpret_continue_(_st(_st(aNode)._nodes())._first(),(function(value){
  1607. return smalltalk.withContext(function($ctx2) {
  1608. self["@shouldReturn"]=true;
  1609. self["@shouldReturn"];
  1610. return self._continue_value_(aBlock,value);
  1611. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}));
  1612. return self}, function($ctx1) {$ctx1.fill(self,"interpretReturnNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1613. args: ["aNode", "aBlock"],
  1614. source: "interpretReturnNode: aNode continue: aBlock\x0a\x09self interpret: aNode nodes first continue: [ :value |\x0a\x09\x09shouldReturn := true.\x0a\x09\x09self continue: aBlock value: value ]",
  1615. messageSends: ["interpret:continue:", "first", "nodes", "continue:value:"],
  1616. referencedClasses: []
  1617. }),
  1618. smalltalk.ASTInterpreter);
  1619. smalltalk.addMethod(
  1620. smalltalk.method({
  1621. selector: "interpretSendNode:continue:",
  1622. category: 'interpreting',
  1623. fn: function (aNode,aBlock){
  1624. var self=this;
  1625. return smalltalk.withContext(function($ctx1) {
  1626. self._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  1627. return smalltalk.withContext(function($ctx2) {
  1628. return self._interpretAll_continue_(_st(aNode)._arguments(),(function(args){
  1629. return smalltalk.withContext(function($ctx3) {
  1630. return self._messageFromSendNode_arguments_do_(aNode,args,(function(message){
  1631. return smalltalk.withContext(function($ctx4) {
  1632. _st(self._context())._pc_(_st(_st(self._context())._pc()).__plus((1)));
  1633. return self._continue_value_(aBlock,self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend()));
  1634. }, function($ctx4) {$ctx4.fillBlock({message:message},$ctx3,3)})}));
  1635. }, function($ctx3) {$ctx3.fillBlock({args:args},$ctx2,2)})}));
  1636. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1,1)})}));
  1637. return self}, function($ctx1) {$ctx1.fill(self,"interpretSendNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1638. args: ["aNode", "aBlock"],
  1639. source: "interpretSendNode: aNode continue: aBlock\x0a\x09self interpret: aNode receiver continue: [ :receiver |\x0a\x09\x09self interpretAll: aNode arguments continue: [ :args |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09messageFromSendNode: aNode\x0a\x09\x09\x09\x09arguments: args\x0a\x09\x09\x09\x09do: [ :message |\x0a\x09\x09\x09\x09\x09self context pc: self context pc + 1.\x0a\x09\x09\x09\x09\x09self\x0a\x09\x09\x09\x09\x09\x09continue: aBlock\x0a\x09\x09\x09\x09\x09\x09value: (self sendMessage: message to: receiver superSend: aNode superSend) ] ] ]",
  1640. messageSends: ["interpret:continue:", "receiver", "interpretAll:continue:", "arguments", "messageFromSendNode:arguments:do:", "pc:", "context", "+", "pc", "continue:value:", "sendMessage:to:superSend:", "superSend"],
  1641. referencedClasses: []
  1642. }),
  1643. smalltalk.ASTInterpreter);
  1644. smalltalk.addMethod(
  1645. smalltalk.method({
  1646. selector: "interpretSequenceNode:continue:",
  1647. category: 'interpreting',
  1648. fn: function (aNode,aBlock){
  1649. var self=this;
  1650. return smalltalk.withContext(function($ctx1) {
  1651. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1652. return smalltalk.withContext(function($ctx2) {
  1653. return self._continue_value_(aBlock,_st(array)._last());
  1654. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1,1)})}));
  1655. return self}, function($ctx1) {$ctx1.fill(self,"interpretSequenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1656. args: ["aNode", "aBlock"],
  1657. source: "interpretSequenceNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self continue: aBlock value: array last ]",
  1658. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "last"],
  1659. referencedClasses: []
  1660. }),
  1661. smalltalk.ASTInterpreter);
  1662. smalltalk.addMethod(
  1663. smalltalk.method({
  1664. selector: "interpretValueNode:continue:",
  1665. category: 'interpreting',
  1666. fn: function (aNode,aBlock){
  1667. var self=this;
  1668. return smalltalk.withContext(function($ctx1) {
  1669. self._continue_value_(aBlock,_st(aNode)._value());
  1670. return self}, function($ctx1) {$ctx1.fill(self,"interpretValueNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1671. args: ["aNode", "aBlock"],
  1672. source: "interpretValueNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: aNode value",
  1673. messageSends: ["continue:value:", "value"],
  1674. referencedClasses: []
  1675. }),
  1676. smalltalk.ASTInterpreter);
  1677. smalltalk.addMethod(
  1678. smalltalk.method({
  1679. selector: "interpretVariableNode:continue:",
  1680. category: 'interpreting',
  1681. fn: function (aNode,aBlock){
  1682. var self=this;
  1683. return smalltalk.withContext(function($ctx1) {
  1684. var $1,$2,$4,$3;
  1685. $1=self;
  1686. $2=aBlock;
  1687. $4=_st(_st(aNode)._binding())._isInstanceVar();
  1688. if(smalltalk.assert($4)){
  1689. $3=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
  1690. } else {
  1691. $3=_st(self._context())._localAt_(_st(aNode)._value());
  1692. };
  1693. _st($1)._continue_value_($2,$3);
  1694. return self}, function($ctx1) {$ctx1.fill(self,"interpretVariableNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1695. args: ["aNode", "aBlock"],
  1696. source: "interpretVariableNode: aNode continue: aBlock\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: (aNode binding isInstanceVar\x0a\x09\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09\x09ifFalse: [ self context localAt: aNode value ])",
  1697. messageSends: ["continue:value:", "ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:", "receiver", "context", "value", "localAt:"],
  1698. referencedClasses: []
  1699. }),
  1700. smalltalk.ASTInterpreter);
  1701. smalltalk.addMethod(
  1702. smalltalk.method({
  1703. selector: "messageFromSendNode:arguments:do:",
  1704. category: 'private',
  1705. fn: function (aSendNode,aCollection,aBlock){
  1706. var self=this;
  1707. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  1708. return smalltalk.withContext(function($ctx1) {
  1709. var $1,$2;
  1710. $1=_st($Message())._new();
  1711. _st($1)._selector_(_st(aSendNode)._selector());
  1712. _st($1)._arguments_(aCollection);
  1713. $2=_st($1)._yourself();
  1714. self._continue_value_(aBlock,$2);
  1715. return self}, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:do:",{aSendNode:aSendNode,aCollection:aCollection,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1716. args: ["aSendNode", "aCollection", "aBlock"],
  1717. source: "messageFromSendNode: aSendNode arguments: aCollection do: aBlock\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: (Message new\x0a\x09\x09\x09selector: aSendNode selector;\x0a\x09\x09\x09arguments: aCollection;\x0a\x09\x09\x09yourself)",
  1718. messageSends: ["continue:value:", "selector:", "new", "selector", "arguments:", "yourself"],
  1719. referencedClasses: ["Message"]
  1720. }),
  1721. smalltalk.ASTInterpreter);
  1722. smalltalk.addMethod(
  1723. smalltalk.method({
  1724. selector: "nextNode",
  1725. category: 'accessing',
  1726. fn: function (){
  1727. var self=this;
  1728. return smalltalk.withContext(function($ctx1) {
  1729. var $2,$1;
  1730. $2=self["@nextNode"];
  1731. if(($receiver = $2) == nil || $receiver == undefined){
  1732. $1=self._currentNode();
  1733. } else {
  1734. $1=$2;
  1735. };
  1736. return $1;
  1737. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTInterpreter)})},
  1738. args: [],
  1739. source: "nextNode\x0a\x09^ nextNode ifNil: [ self currentNode ]",
  1740. messageSends: ["ifNil:", "currentNode"],
  1741. referencedClasses: []
  1742. }),
  1743. smalltalk.ASTInterpreter);
  1744. smalltalk.addMethod(
  1745. smalltalk.method({
  1746. selector: "nextNode:",
  1747. category: 'accessing',
  1748. fn: function (aNode){
  1749. var self=this;
  1750. return smalltalk.withContext(function($ctx1) {
  1751. self["@nextNode"]=aNode;
  1752. return self}, function($ctx1) {$ctx1.fill(self,"nextNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1753. args: ["aNode"],
  1754. source: "nextNode: aNode\x0a\x09nextNode := aNode",
  1755. messageSends: [],
  1756. referencedClasses: []
  1757. }),
  1758. smalltalk.ASTInterpreter);
  1759. smalltalk.addMethod(
  1760. smalltalk.method({
  1761. selector: "result",
  1762. category: 'accessing',
  1763. fn: function (){
  1764. var self=this;
  1765. return smalltalk.withContext(function($ctx1) {
  1766. var $1;
  1767. $1=self["@result"];
  1768. return $1;
  1769. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ASTInterpreter)})},
  1770. args: [],
  1771. source: "result\x0a\x09^ result",
  1772. messageSends: [],
  1773. referencedClasses: []
  1774. }),
  1775. smalltalk.ASTInterpreter);
  1776. smalltalk.addMethod(
  1777. smalltalk.method({
  1778. selector: "sendMessage:to:superSend:",
  1779. category: 'private',
  1780. fn: function (aMessage,anObject,aBoolean){
  1781. var self=this;
  1782. var method;
  1783. return smalltalk.withContext(function($ctx1) {
  1784. var $1,$2,$3,$4,$5,$6;
  1785. var $early={};
  1786. try {
  1787. $1=aBoolean;
  1788. if(! smalltalk.assert($1)){
  1789. $2=_st(aMessage)._sendTo_(anObject);
  1790. return $2;
  1791. };
  1792. $3=_st(_st(anObject)._class())._superclass();
  1793. if(($receiver = $3) == nil || $receiver == undefined){
  1794. $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1795. return $4;
  1796. } else {
  1797. $3;
  1798. };
  1799. method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
  1800. return smalltalk.withContext(function($ctx2) {
  1801. $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1802. throw $early=[$5];
  1803. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  1804. $6=_st(_st(method)._fn())._applyTo_arguments_(anObject,_st(aMessage)._arguments());
  1805. return $6;
  1806. }
  1807. catch(e) {if(e===$early)return e[0]; throw e}
  1808. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.ASTInterpreter)})},
  1809. args: ["aMessage", "anObject", "aBoolean"],
  1810. source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method fn applyTo: anObject arguments: aMessage arguments\x0a\x09\x09\x0a\x09\x0a\x09",
  1811. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "applyTo:arguments:", "fn", "arguments"],
  1812. referencedClasses: []
  1813. }),
  1814. smalltalk.ASTInterpreter);
  1815. smalltalk.addMethod(
  1816. smalltalk.method({
  1817. selector: "shouldReturn",
  1818. category: 'testing',
  1819. fn: function (){
  1820. var self=this;
  1821. return smalltalk.withContext(function($ctx1) {
  1822. var $2,$1;
  1823. $2=self["@shouldReturn"];
  1824. if(($receiver = $2) == nil || $receiver == undefined){
  1825. $1=false;
  1826. } else {
  1827. $1=$2;
  1828. };
  1829. return $1;
  1830. }, function($ctx1) {$ctx1.fill(self,"shouldReturn",{},smalltalk.ASTInterpreter)})},
  1831. args: [],
  1832. source: "shouldReturn\x0a\x09^ shouldReturn ifNil: [ false ]",
  1833. messageSends: ["ifNil:"],
  1834. referencedClasses: []
  1835. }),
  1836. smalltalk.ASTInterpreter);
  1837. smalltalk.addMethod(
  1838. smalltalk.method({
  1839. selector: "withBlockContext:",
  1840. category: 'private',
  1841. fn: function (aBlock){
  1842. var self=this;
  1843. var blockResult;
  1844. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  1845. return smalltalk.withContext(function($ctx1) {
  1846. var $1,$2,$3;
  1847. $1=_st($AIContext())._new();
  1848. _st($1)._outerContext_(self._context());
  1849. $2=_st($1)._yourself();
  1850. self._context_($2);
  1851. blockResult=_st(aBlock)._value();
  1852. self._context_(_st(self._context())._outerContext());
  1853. $3=blockResult;
  1854. return $3;
  1855. }, function($ctx1) {$ctx1.fill(self,"withBlockContext:",{aBlock:aBlock,blockResult:blockResult},smalltalk.ASTInterpreter)})},
  1856. args: ["aBlock"],
  1857. source: "withBlockContext: aBlock\x0a\x09\x22Evaluate aBlock with a BlockContext:\x0a\x09- a context is pushed before aBlock evaluation.\x0a\x09- the context is poped after aBlock evaluation\x0a\x09- the result of aBlock evaluation is answered\x22\x0a\x09\x0a\x09| blockResult |\x0a\x09\x09\x09\x0a\x09self context: (AIContext new\x0a\x09\x09outerContext: self context;\x0a\x09\x09yourself).\x0a\x09\x0a\x09blockResult := aBlock value.\x0a\x09\x0a\x09self context: self context outerContext.\x0a\x09^ blockResult",
  1858. messageSends: ["context:", "outerContext:", "new", "context", "yourself", "value", "outerContext"],
  1859. referencedClasses: ["AIContext"]
  1860. }),
  1861. smalltalk.ASTInterpreter);
  1862. smalltalk.addClass('ASTSteppingInterpreter', smalltalk.ASTInterpreter, ['continuation', 'nextNode'], 'Compiler-Interpreter');
  1863. smalltalk.ASTSteppingInterpreter.comment="I am an interpreter with stepping capabilities. The higher level `ASTDebugger` class should be used as a debugger model, as it provides convenience methods for debugging.\x0a\x0a## API\x0a\x0aUse `#step` to actually interpret the next node. Interpretation stops at each node evaluation, weither it's a message node or not.\x0a\x0a\x0a## Usage example:\x0a\x0a\x09| ast interpreter |\x0a\x09ast := Smalltalk current parse: 'foo 1+2+4'.\x0a\x09(SemanticAnalyzer on: Object) visit: ast.\x0a\x0a\x09interpreter := ASTSteppingInterpreter new\x0a\x09\x09interpret: ast nodes first;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09interpreter step; step.\x0a\x09interpreter step; step.\x0a\x09interpreter result.\x22Answers 1\x22\x0a\x09interpreter step.\x0a\x09interpreter result. \x22Answers 3\x22\x0a\x09interpreter step.\x0a\x09interpreter result. \x22Answers 7\x22";
  1864. smalltalk.addMethod(
  1865. smalltalk.method({
  1866. selector: "atEnd",
  1867. category: 'testing',
  1868. fn: function (){
  1869. var self=this;
  1870. return smalltalk.withContext(function($ctx1) {
  1871. var $1;
  1872. $1=_st(self._shouldReturn())._or_((function(){
  1873. return smalltalk.withContext(function($ctx2) {
  1874. return _st(self._nextNode()).__eq_eq(self._currentNode());
  1875. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1876. return $1;
  1877. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTSteppingInterpreter)})},
  1878. args: [],
  1879. source: "atEnd\x0a\x09^ self shouldReturn or: [ self nextNode == self currentNode ]",
  1880. messageSends: ["or:", "shouldReturn", "==", "nextNode", "currentNode"],
  1881. referencedClasses: []
  1882. }),
  1883. smalltalk.ASTSteppingInterpreter);
  1884. smalltalk.addMethod(
  1885. smalltalk.method({
  1886. selector: "initialize",
  1887. category: 'initialization',
  1888. fn: function (){
  1889. var self=this;
  1890. return smalltalk.withContext(function($ctx1) {
  1891. smalltalk.ASTSteppingInterpreter.superclass.fn.prototype._initialize.apply(_st(self), []);
  1892. self["@continuation"]=(function(){
  1893. return smalltalk.withContext(function($ctx2) {
  1894. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})});
  1895. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ASTSteppingInterpreter)})},
  1896. args: [],
  1897. source: "initialize\x0a\x09super initialize.\x0a\x09continuation := []",
  1898. messageSends: ["initialize"],
  1899. referencedClasses: []
  1900. }),
  1901. smalltalk.ASTSteppingInterpreter);
  1902. smalltalk.addMethod(
  1903. smalltalk.method({
  1904. selector: "interpret:continue:",
  1905. category: 'interpreting',
  1906. fn: function (aNode,aBlock){
  1907. var self=this;
  1908. return smalltalk.withContext(function($ctx1) {
  1909. self["@nextNode"]=aNode;
  1910. self["@continuation"]=(function(){
  1911. return smalltalk.withContext(function($ctx2) {
  1912. return smalltalk.ASTSteppingInterpreter.superclass.fn.prototype._interpret_continue_.apply(_st(self), [aNode,aBlock]);
  1913. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})});
  1914. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTSteppingInterpreter)})},
  1915. args: ["aNode", "aBlock"],
  1916. source: "interpret: aNode continue: aBlock\x0a\x09nextNode := aNode.\x0a\x09continuation := [\x0a\x09\x09super interpret: aNode continue: aBlock ]",
  1917. messageSends: ["interpret:continue:"],
  1918. referencedClasses: []
  1919. }),
  1920. smalltalk.ASTSteppingInterpreter);
  1921. smalltalk.addMethod(
  1922. smalltalk.method({
  1923. selector: "nextNode",
  1924. category: 'accessing',
  1925. fn: function (){
  1926. var self=this;
  1927. return smalltalk.withContext(function($ctx1) {
  1928. var $1;
  1929. $1=self["@nextNode"];
  1930. return $1;
  1931. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTSteppingInterpreter)})},
  1932. args: [],
  1933. source: "nextNode\x0a\x09^ nextNode",
  1934. messageSends: [],
  1935. referencedClasses: []
  1936. }),
  1937. smalltalk.ASTSteppingInterpreter);
  1938. smalltalk.addMethod(
  1939. smalltalk.method({
  1940. selector: "step",
  1941. category: 'stepping',
  1942. fn: function (){
  1943. var self=this;
  1944. return smalltalk.withContext(function($ctx1) {
  1945. _st(self["@continuation"])._value();
  1946. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTSteppingInterpreter)})},
  1947. args: [],
  1948. source: "step\x0a\x09continuation value",
  1949. messageSends: ["value"],
  1950. referencedClasses: []
  1951. }),
  1952. smalltalk.ASTSteppingInterpreter);
  1953. smalltalk.addClass('ASTPCNodeVisitor', smalltalk.NodeVisitor, ['useInlinings', 'pc', 'context', 'blockIndex', 'currentNode'], 'Compiler-Interpreter');
  1954. smalltalk.ASTPCNodeVisitor.comment="I visit an AST until I get to the current pc node and answer it.\x0a\x0a## API\x0a\x0aMy instances must be filled with a context object using `#context:`.\x0a\x0aAfter visiting the AST the current node corresponding to the `pc` is answered by `#currentNode`";
  1955. smalltalk.addMethod(
  1956. smalltalk.method({
  1957. selector: "blockIndex",
  1958. category: 'accessing',
  1959. fn: function (){
  1960. var self=this;
  1961. return smalltalk.withContext(function($ctx1) {
  1962. var $2,$1;
  1963. $2=self["@blockIndex"];
  1964. if(($receiver = $2) == nil || $receiver == undefined){
  1965. self["@blockIndex"]=(0);
  1966. $1=self["@blockIndex"];
  1967. } else {
  1968. $1=$2;
  1969. };
  1970. return $1;
  1971. }, function($ctx1) {$ctx1.fill(self,"blockIndex",{},smalltalk.ASTPCNodeVisitor)})},
  1972. args: [],
  1973. source: "blockIndex\x0a\x09^ blockIndex ifNil: [ blockIndex := 0 ]",
  1974. messageSends: ["ifNil:"],
  1975. referencedClasses: []
  1976. }),
  1977. smalltalk.ASTPCNodeVisitor);
  1978. smalltalk.addMethod(
  1979. smalltalk.method({
  1980. selector: "context",
  1981. category: 'accessing',
  1982. fn: function (){
  1983. var self=this;
  1984. return smalltalk.withContext(function($ctx1) {
  1985. var $1;
  1986. $1=self["@context"];
  1987. return $1;
  1988. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTPCNodeVisitor)})},
  1989. args: [],
  1990. source: "context\x0a\x09^ context",
  1991. messageSends: [],
  1992. referencedClasses: []
  1993. }),
  1994. smalltalk.ASTPCNodeVisitor);
  1995. smalltalk.addMethod(
  1996. smalltalk.method({
  1997. selector: "context:",
  1998. category: 'accessing',
  1999. fn: function (aContext){
  2000. var self=this;
  2001. return smalltalk.withContext(function($ctx1) {
  2002. self["@context"]=aContext;
  2003. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTPCNodeVisitor)})},
  2004. args: ["aContext"],
  2005. source: "context: aContext\x0a\x09context := aContext",
  2006. messageSends: [],
  2007. referencedClasses: []
  2008. }),
  2009. smalltalk.ASTPCNodeVisitor);
  2010. smalltalk.addMethod(
  2011. smalltalk.method({
  2012. selector: "currentNode",
  2013. category: 'accessing',
  2014. fn: function (){
  2015. var self=this;
  2016. return smalltalk.withContext(function($ctx1) {
  2017. var $1;
  2018. $1=self["@currentNode"];
  2019. return $1;
  2020. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTPCNodeVisitor)})},
  2021. args: [],
  2022. source: "currentNode\x0a\x09^ currentNode",
  2023. messageSends: [],
  2024. referencedClasses: []
  2025. }),
  2026. smalltalk.ASTPCNodeVisitor);
  2027. smalltalk.addMethod(
  2028. smalltalk.method({
  2029. selector: "increaseBlockIndex",
  2030. category: 'accessing',
  2031. fn: function (){
  2032. var self=this;
  2033. return smalltalk.withContext(function($ctx1) {
  2034. self["@blockIndex"]=_st(self._blockIndex()).__plus((1));
  2035. return self}, function($ctx1) {$ctx1.fill(self,"increaseBlockIndex",{},smalltalk.ASTPCNodeVisitor)})},
  2036. args: [],
  2037. source: "increaseBlockIndex\x0a\x09blockIndex := self blockIndex + 1",
  2038. messageSends: ["+", "blockIndex"],
  2039. referencedClasses: []
  2040. }),
  2041. smalltalk.ASTPCNodeVisitor);
  2042. smalltalk.addMethod(
  2043. smalltalk.method({
  2044. selector: "pc",
  2045. category: 'accessing',
  2046. fn: function (){
  2047. var self=this;
  2048. return smalltalk.withContext(function($ctx1) {
  2049. var $2,$1;
  2050. $2=self["@pc"];
  2051. if(($receiver = $2) == nil || $receiver == undefined){
  2052. $1=(0);
  2053. } else {
  2054. $1=$2;
  2055. };
  2056. return $1;
  2057. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.ASTPCNodeVisitor)})},
  2058. args: [],
  2059. source: "pc\x0a\x09^ pc ifNil: [ 0 ]",
  2060. messageSends: ["ifNil:"],
  2061. referencedClasses: []
  2062. }),
  2063. smalltalk.ASTPCNodeVisitor);
  2064. smalltalk.addMethod(
  2065. smalltalk.method({
  2066. selector: "pc:",
  2067. category: 'accessing',
  2068. fn: function (anInteger){
  2069. var self=this;
  2070. return smalltalk.withContext(function($ctx1) {
  2071. self["@pc"]=anInteger;
  2072. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitor)})},
  2073. args: ["anInteger"],
  2074. source: "pc: anInteger\x0a\x09pc := anInteger",
  2075. messageSends: [],
  2076. referencedClasses: []
  2077. }),
  2078. smalltalk.ASTPCNodeVisitor);
  2079. smalltalk.addMethod(
  2080. smalltalk.method({
  2081. selector: "useInlinings",
  2082. category: 'accessing',
  2083. fn: function (){
  2084. var self=this;
  2085. return smalltalk.withContext(function($ctx1) {
  2086. var $2,$1;
  2087. $2=self["@useInlinings"];
  2088. if(($receiver = $2) == nil || $receiver == undefined){
  2089. $1=true;
  2090. } else {
  2091. $1=$2;
  2092. };
  2093. return $1;
  2094. }, function($ctx1) {$ctx1.fill(self,"useInlinings",{},smalltalk.ASTPCNodeVisitor)})},
  2095. args: [],
  2096. source: "useInlinings\x0a\x09^ useInlinings ifNil: [ true ]",
  2097. messageSends: ["ifNil:"],
  2098. referencedClasses: []
  2099. }),
  2100. smalltalk.ASTPCNodeVisitor);
  2101. smalltalk.addMethod(
  2102. smalltalk.method({
  2103. selector: "useInlinings:",
  2104. category: 'accessing',
  2105. fn: function (aBoolean){
  2106. var self=this;
  2107. return smalltalk.withContext(function($ctx1) {
  2108. self["@useInlinings"]=aBoolean;
  2109. return self}, function($ctx1) {$ctx1.fill(self,"useInlinings:",{aBoolean:aBoolean},smalltalk.ASTPCNodeVisitor)})},
  2110. args: ["aBoolean"],
  2111. source: "useInlinings: aBoolean\x0a\x09useInlinings := aBoolean",
  2112. messageSends: [],
  2113. referencedClasses: []
  2114. }),
  2115. smalltalk.ASTPCNodeVisitor);
  2116. smalltalk.addMethod(
  2117. smalltalk.method({
  2118. selector: "visitBlockNode:",
  2119. category: 'visiting',
  2120. fn: function (aNode){
  2121. var self=this;
  2122. return smalltalk.withContext(function($ctx1) {
  2123. var $1;
  2124. $1=_st(self._blockIndex()).__gt_eq(_st(self._context())._index());
  2125. if(! smalltalk.assert($1)){
  2126. self._increaseBlockIndex();
  2127. smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  2128. };
  2129. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2130. args: ["aNode"],
  2131. source: "visitBlockNode: aNode\x0a\x09self blockIndex >= self context index ifFalse: [\x0a\x09\x09self increaseBlockIndex.\x0a\x09\x09super visitBlockNode: aNode ]",
  2132. messageSends: ["ifFalse:", ">=", "blockIndex", "index", "context", "increaseBlockIndex", "visitBlockNode:"],
  2133. referencedClasses: []
  2134. }),
  2135. smalltalk.ASTPCNodeVisitor);
  2136. smalltalk.addMethod(
  2137. smalltalk.method({
  2138. selector: "visitJSStatementNode:",
  2139. category: 'visiting',
  2140. fn: function (aNode){
  2141. var self=this;
  2142. return smalltalk.withContext(function($ctx1) {
  2143. self["@currentNode"]=aNode;
  2144. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2145. args: ["aNode"],
  2146. source: "visitJSStatementNode: aNode\x0a\x09currentNode := aNode",
  2147. messageSends: [],
  2148. referencedClasses: []
  2149. }),
  2150. smalltalk.ASTPCNodeVisitor);
  2151. smalltalk.addMethod(
  2152. smalltalk.method({
  2153. selector: "visitSendNode:",
  2154. category: 'visiting',
  2155. fn: function (aNode){
  2156. var self=this;
  2157. return smalltalk.withContext(function($ctx1) {
  2158. var $1,$2,$3;
  2159. smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  2160. $1=_st(self._pc()).__eq(_st(self._context())._pc());
  2161. if(! smalltalk.assert($1)){
  2162. $2=_st(aNode)._shouldBeInlined();
  2163. if(! smalltalk.assert($2)){
  2164. $3=_st(self._blockIndex()).__eq(_st(self._context())._index());
  2165. if(smalltalk.assert($3)){
  2166. self._pc_(_st(self._pc()).__plus((1)));
  2167. self["@currentNode"]=aNode;
  2168. self["@currentNode"];
  2169. };
  2170. };
  2171. };
  2172. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2173. args: ["aNode"],
  2174. source: "visitSendNode: aNode\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self pc = self context pc ifFalse: [\x0a\x09\x09aNode shouldBeInlined ifFalse: [\x0a\x09\x09\x09self blockIndex = self context index ifTrue: [\x0a\x09\x09\x09\x09self pc: self pc + 1.\x0a\x09\x09\x09\x09currentNode := aNode ] ] ]",
  2175. messageSends: ["visitSendNode:", "ifFalse:", "=", "pc", "context", "shouldBeInlined", "ifTrue:", "blockIndex", "index", "pc:", "+"],
  2176. referencedClasses: []
  2177. }),
  2178. smalltalk.ASTPCNodeVisitor);
  2179. smalltalk.addClass('Interpreter', smalltalk.NodeVisitor, ['node', 'context', 'stack', 'returnValue'], 'Compiler-Interpreter');
  2180. smalltalk.addMethod(
  2181. smalltalk.method({
  2182. selector: "assign:to:",
  2183. category: 'private',
  2184. fn: function (aNode,anObject){
  2185. var self=this;
  2186. return smalltalk.withContext(function($ctx1) {
  2187. var $1;
  2188. $1=_st(_st(aNode)._binding())._isInstanceVar();
  2189. if(smalltalk.assert($1)){
  2190. _st(_st(self._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  2191. } else {
  2192. _st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
  2193. };
  2194. return self}, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.Interpreter)})},
  2195. args: ["aNode", "anObject"],
  2196. source: "assign: aNode to: anObject\x0a\x09aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value put: anObject ]",
  2197. messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
  2198. referencedClasses: []
  2199. }),
  2200. smalltalk.Interpreter);
  2201. smalltalk.addMethod(
  2202. smalltalk.method({
  2203. selector: "atEnd",
  2204. category: 'testing',
  2205. fn: function (){
  2206. var self=this;
  2207. return smalltalk.withContext(function($ctx1) {
  2208. var $1;
  2209. $1=_st(self._shouldReturn())._or_((function(){
  2210. return smalltalk.withContext(function($ctx2) {
  2211. return _st(self._node())._isNil();
  2212. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2213. return $1;
  2214. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.Interpreter)})},
  2215. args: [],
  2216. source: "atEnd\x0a\x09^ self shouldReturn or: [ self node isNil ]",
  2217. messageSends: ["or:", "shouldReturn", "isNil", "node"],
  2218. referencedClasses: []
  2219. }),
  2220. smalltalk.Interpreter);
  2221. smalltalk.addMethod(
  2222. smalltalk.method({
  2223. selector: "context",
  2224. category: 'accessing',
  2225. fn: function (){
  2226. var self=this;
  2227. return smalltalk.withContext(function($ctx1) {
  2228. var $1;
  2229. $1=self["@context"];
  2230. return $1;
  2231. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.Interpreter)})},
  2232. args: [],
  2233. source: "context\x0a\x09^ context",
  2234. messageSends: [],
  2235. referencedClasses: []
  2236. }),
  2237. smalltalk.Interpreter);
  2238. smalltalk.addMethod(
  2239. smalltalk.method({
  2240. selector: "context:",
  2241. category: 'accessing',
  2242. fn: function (aContext){
  2243. var self=this;
  2244. return smalltalk.withContext(function($ctx1) {
  2245. self["@context"]=aContext;
  2246. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.Interpreter)})},
  2247. args: ["aContext"],
  2248. source: "context: aContext\x0a\x09context := aContext",
  2249. messageSends: [],
  2250. referencedClasses: []
  2251. }),
  2252. smalltalk.Interpreter);
  2253. smalltalk.addMethod(
  2254. smalltalk.method({
  2255. selector: "eval:",
  2256. category: 'private',
  2257. fn: function (aString){
  2258. var self=this;
  2259. var source,function_;
  2260. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2261. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  2262. return smalltalk.withContext(function($ctx1) {
  2263. var $1,$2,$3;
  2264. source=_st($String())._streamContents_((function(str){
  2265. return smalltalk.withContext(function($ctx2) {
  2266. _st(str)._nextPutAll_("(function(");
  2267. _st(_st(_st(self._context())._locals())._keys())._do_separatedBy_((function(each){
  2268. return smalltalk.withContext(function($ctx3) {
  2269. return _st(str)._nextPutAll_(each);
  2270. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
  2271. return smalltalk.withContext(function($ctx3) {
  2272. return _st(str)._nextPutAll_(",");
  2273. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  2274. $1=str;
  2275. _st($1)._nextPutAll_("){ return (function() {");
  2276. _st($1)._nextPutAll_(aString);
  2277. $2=_st($1)._nextPutAll_("})() })");
  2278. return $2;
  2279. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
  2280. function_=_st(_st($Compiler())._new())._eval_(source);
  2281. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
  2282. return $3;
  2283. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.Interpreter)})},
  2284. args: ["aString"],
  2285. source: "eval: aString\x0a\x09\x22Evaluate aString as JS source inside an JS function.\x0a\x09aString is not sandboxed.\x22\x0a\x09\x0a\x09| source function |\x0a\x09\x0a\x09source := String streamContents: [ :str |\x0a\x09\x09str nextPutAll: '(function('.\x0a\x09\x09self context locals keys\x0a\x09\x09\x09do: [ :each | str nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ str nextPutAll: ',' ].\x0a\x09\x09str\x0a\x09\x09\x09nextPutAll: '){ return (function() {';\x0a\x09\x09\x09nextPutAll: aString;\x0a\x09\x09\x09nextPutAll: '})() })' ].\x0a\x09\x09\x09\x0a\x09function := Compiler new eval: source.\x0a\x09\x0a\x09^ function valueWithPossibleArguments: self context locals values",
  2286. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  2287. referencedClasses: ["String", "Compiler"]
  2288. }),
  2289. smalltalk.Interpreter);
  2290. smalltalk.addMethod(
  2291. smalltalk.method({
  2292. selector: "interpret",
  2293. category: 'interpreting',
  2294. fn: function (){
  2295. var self=this;
  2296. return smalltalk.withContext(function($ctx1) {
  2297. self._visit_(self._node());
  2298. return self}, function($ctx1) {$ctx1.fill(self,"interpret",{},smalltalk.Interpreter)})},
  2299. args: [],
  2300. source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
  2301. messageSends: ["visit:", "node"],
  2302. referencedClasses: []
  2303. }),
  2304. smalltalk.Interpreter);
  2305. smalltalk.addMethod(
  2306. smalltalk.method({
  2307. selector: "interpret:",
  2308. category: 'interpreting',
  2309. fn: function (aNode){
  2310. var self=this;
  2311. return smalltalk.withContext(function($ctx1) {
  2312. self._node_(aNode);
  2313. self._interpret();
  2314. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.Interpreter)})},
  2315. args: ["aNode"],
  2316. source: "interpret: aNode\x0a\x09self node: aNode.\x0a\x09self interpret",
  2317. messageSends: ["node:", "interpret"],
  2318. referencedClasses: []
  2319. }),
  2320. smalltalk.Interpreter);
  2321. smalltalk.addMethod(
  2322. smalltalk.method({
  2323. selector: "messageFromSendNode:arguments:",
  2324. category: 'private',
  2325. fn: function (aSendNode,aCollection){
  2326. var self=this;
  2327. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  2328. return smalltalk.withContext(function($ctx1) {
  2329. var $2,$3,$1;
  2330. $2=_st($Message())._new();
  2331. _st($2)._selector_(_st(aSendNode)._selector());
  2332. _st($2)._arguments_(aCollection);
  2333. $3=_st($2)._yourself();
  2334. $1=$3;
  2335. return $1;
  2336. }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},smalltalk.Interpreter)})},
  2337. args: ["aSendNode", "aCollection"],
  2338. source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
  2339. messageSends: ["selector:", "new", "selector", "arguments:", "yourself"],
  2340. referencedClasses: ["Message"]
  2341. }),
  2342. smalltalk.Interpreter);
  2343. smalltalk.addMethod(
  2344. smalltalk.method({
  2345. selector: "messageNotUnderstood:receiver:",
  2346. category: 'private',
  2347. fn: function (aMessage,anObject){
  2348. var self=this;
  2349. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2350. return smalltalk.withContext(function($ctx1) {
  2351. var $1,$2;
  2352. $1=_st($MessageNotUnderstood())._new();
  2353. _st($1)._meesage_(aMessage);
  2354. _st($1)._receiver_(anObject);
  2355. $2=_st($1)._signal();
  2356. return self}, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},smalltalk.Interpreter)})},
  2357. args: ["aMessage", "anObject"],
  2358. source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09meesage: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
  2359. messageSends: ["meesage:", "new", "receiver:", "signal"],
  2360. referencedClasses: ["MessageNotUnderstood"]
  2361. }),
  2362. smalltalk.Interpreter);
  2363. smalltalk.addMethod(
  2364. smalltalk.method({
  2365. selector: "next",
  2366. category: 'interpreting',
  2367. fn: function (){
  2368. var self=this;
  2369. return smalltalk.withContext(function($ctx1) {
  2370. self._node_(_st(self._node())._nextNode());
  2371. return self}, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.Interpreter)})},
  2372. args: [],
  2373. source: "next\x0a\x09self node: self node nextNode",
  2374. messageSends: ["node:", "nextNode", "node"],
  2375. referencedClasses: []
  2376. }),
  2377. smalltalk.Interpreter);
  2378. smalltalk.addMethod(
  2379. smalltalk.method({
  2380. selector: "node",
  2381. category: 'accessing',
  2382. fn: function (){
  2383. var self=this;
  2384. return smalltalk.withContext(function($ctx1) {
  2385. var $1;
  2386. $1=self["@node"];
  2387. return $1;
  2388. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.Interpreter)})},
  2389. args: [],
  2390. source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
  2391. messageSends: [],
  2392. referencedClasses: []
  2393. }),
  2394. smalltalk.Interpreter);
  2395. smalltalk.addMethod(
  2396. smalltalk.method({
  2397. selector: "node:",
  2398. category: 'accessing',
  2399. fn: function (aNode){
  2400. var self=this;
  2401. return smalltalk.withContext(function($ctx1) {
  2402. self["@node"]=aNode;
  2403. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.Interpreter)})},
  2404. args: ["aNode"],
  2405. source: "node: aNode\x0a\x09node := aNode",
  2406. messageSends: [],
  2407. referencedClasses: []
  2408. }),
  2409. smalltalk.Interpreter);
  2410. smalltalk.addMethod(
  2411. smalltalk.method({
  2412. selector: "peek",
  2413. category: 'stack',
  2414. fn: function (){
  2415. var self=this;
  2416. return smalltalk.withContext(function($ctx1) {
  2417. var $1;
  2418. var $early={};
  2419. try {
  2420. _st(self._stack())._ifEmpty_((function(){
  2421. return smalltalk.withContext(function($ctx2) {
  2422. throw $early=[nil];
  2423. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2424. $1=_st(self._stack())._last();
  2425. return $1;
  2426. }
  2427. catch(e) {if(e===$early)return e[0]; throw e}
  2428. }, function($ctx1) {$ctx1.fill(self,"peek",{},smalltalk.Interpreter)})},
  2429. args: [],
  2430. source: "peek\x0a\x09\x22Peek the top object of the context stack\x22\x0a\x09\x0a\x09self stack ifEmpty: [ ^ nil ].\x0a\x09\x0a\x09^ self stack last",
  2431. messageSends: ["ifEmpty:", "stack", "last"],
  2432. referencedClasses: []
  2433. }),
  2434. smalltalk.Interpreter);
  2435. smalltalk.addMethod(
  2436. smalltalk.method({
  2437. selector: "pop",
  2438. category: 'stack',
  2439. fn: function (){
  2440. var self=this;
  2441. var peekedValue;
  2442. return smalltalk.withContext(function($ctx1) {
  2443. var $1;
  2444. peekedValue=self._peek();
  2445. _st(self._stack())._removeLast();
  2446. $1=peekedValue;
  2447. return $1;
  2448. }, function($ctx1) {$ctx1.fill(self,"pop",{peekedValue:peekedValue},smalltalk.Interpreter)})},
  2449. args: [],
  2450. source: "pop\x0a\x09\x22Pop an object from the context stack\x22\x0a\x09\x0a\x09| peekedValue |\x0a\x09\x0a\x09peekedValue := self peek.\x0a\x09self stack removeLast.\x0a\x09^ peekedValue",
  2451. messageSends: ["peek", "removeLast", "stack"],
  2452. referencedClasses: []
  2453. }),
  2454. smalltalk.Interpreter);
  2455. smalltalk.addMethod(
  2456. smalltalk.method({
  2457. selector: "proceed",
  2458. category: 'interpreting',
  2459. fn: function (){
  2460. var self=this;
  2461. return smalltalk.withContext(function($ctx1) {
  2462. _st((function(){
  2463. return smalltalk.withContext(function($ctx2) {
  2464. return self._atEnd();
  2465. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  2466. return smalltalk.withContext(function($ctx2) {
  2467. return self._step();
  2468. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  2469. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.Interpreter)})},
  2470. args: [],
  2471. source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] whileFalse: [ \x0a\x09\x09self step ]",
  2472. messageSends: ["whileFalse:", "atEnd", "step"],
  2473. referencedClasses: []
  2474. }),
  2475. smalltalk.Interpreter);
  2476. smalltalk.addMethod(
  2477. smalltalk.method({
  2478. selector: "push:",
  2479. category: 'stack',
  2480. fn: function (anObject){
  2481. var self=this;
  2482. return smalltalk.withContext(function($ctx1) {
  2483. var $1;
  2484. $1=_st(self._stack())._add_(anObject);
  2485. return $1;
  2486. }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},smalltalk.Interpreter)})},
  2487. args: ["anObject"],
  2488. source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
  2489. messageSends: ["add:", "stack"],
  2490. referencedClasses: []
  2491. }),
  2492. smalltalk.Interpreter);
  2493. smalltalk.addMethod(
  2494. smalltalk.method({
  2495. selector: "restart",
  2496. category: 'interpreting',
  2497. fn: function (){
  2498. var self=this;
  2499. return smalltalk.withContext(function($ctx1) {
  2500. self._node_(_st(_st(self._context())._ast())._nextChild());
  2501. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.Interpreter)})},
  2502. args: [],
  2503. source: "restart\x0a\x09self node: self context ast nextChild",
  2504. messageSends: ["node:", "nextChild", "ast", "context"],
  2505. referencedClasses: []
  2506. }),
  2507. smalltalk.Interpreter);
  2508. smalltalk.addMethod(
  2509. smalltalk.method({
  2510. selector: "result",
  2511. category: 'accessing',
  2512. fn: function (){
  2513. var self=this;
  2514. return smalltalk.withContext(function($ctx1) {
  2515. var $2,$1;
  2516. $2=self._returnValue();
  2517. if(($receiver = $2) == nil || $receiver == undefined){
  2518. $1=_st(self._context())._receiver();
  2519. } else {
  2520. $1=$2;
  2521. };
  2522. return $1;
  2523. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.Interpreter)})},
  2524. args: [],
  2525. source: "result\x0a\x09^ self returnValue ifNil: [ self context receiver ]",
  2526. messageSends: ["ifNil:", "returnValue", "receiver", "context"],
  2527. referencedClasses: []
  2528. }),
  2529. smalltalk.Interpreter);
  2530. smalltalk.addMethod(
  2531. smalltalk.method({
  2532. selector: "returnValue",
  2533. category: 'accessing',
  2534. fn: function (){
  2535. var self=this;
  2536. return smalltalk.withContext(function($ctx1) {
  2537. var $1;
  2538. $1=self["@returnValue"];
  2539. return $1;
  2540. }, function($ctx1) {$ctx1.fill(self,"returnValue",{},smalltalk.Interpreter)})},
  2541. args: [],
  2542. source: "returnValue\x0a\x09^ returnValue",
  2543. messageSends: [],
  2544. referencedClasses: []
  2545. }),
  2546. smalltalk.Interpreter);
  2547. smalltalk.addMethod(
  2548. smalltalk.method({
  2549. selector: "returnValue:",
  2550. category: 'accessing',
  2551. fn: function (anObject){
  2552. var self=this;
  2553. return smalltalk.withContext(function($ctx1) {
  2554. self["@returnValue"]=anObject;
  2555. return self}, function($ctx1) {$ctx1.fill(self,"returnValue:",{anObject:anObject},smalltalk.Interpreter)})},
  2556. args: ["anObject"],
  2557. source: "returnValue: anObject\x0a\x09returnValue := anObject",
  2558. messageSends: [],
  2559. referencedClasses: []
  2560. }),
  2561. smalltalk.Interpreter);
  2562. smalltalk.addMethod(
  2563. smalltalk.method({
  2564. selector: "sendMessage:to:superSend:",
  2565. category: 'private',
  2566. fn: function (aMessage,anObject,aBoolean){
  2567. var self=this;
  2568. var method;
  2569. return smalltalk.withContext(function($ctx1) {
  2570. var $1,$2,$3,$4,$5,$6;
  2571. var $early={};
  2572. try {
  2573. $1=aBoolean;
  2574. if(! smalltalk.assert($1)){
  2575. $2=_st(aMessage)._sendTo_(anObject);
  2576. return $2;
  2577. };
  2578. $3=_st(_st(anObject)._class())._superclass();
  2579. if(($receiver = $3) == nil || $receiver == undefined){
  2580. $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
  2581. return $4;
  2582. } else {
  2583. $3;
  2584. };
  2585. method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
  2586. return smalltalk.withContext(function($ctx2) {
  2587. $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
  2588. throw $early=[$5];
  2589. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  2590. $6=_st(method)._sendTo_arguments_(anObject,_st(aMessage)._arguments());
  2591. return $6;
  2592. }
  2593. catch(e) {if(e===$early)return e[0]; throw e}
  2594. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.Interpreter)})},
  2595. args: ["aMessage", "anObject", "aBoolean"],
  2596. source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method sendTo: anObject arguments: aMessage arguments",
  2597. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "sendTo:arguments:", "arguments"],
  2598. referencedClasses: []
  2599. }),
  2600. smalltalk.Interpreter);
  2601. smalltalk.addMethod(
  2602. smalltalk.method({
  2603. selector: "shouldReturn",
  2604. category: 'testing',
  2605. fn: function (){
  2606. var self=this;
  2607. return smalltalk.withContext(function($ctx1) {
  2608. var $1;
  2609. $1=_st(self._returnValue())._notNil();
  2610. return $1;
  2611. }, function($ctx1) {$ctx1.fill(self,"shouldReturn",{},smalltalk.Interpreter)})},
  2612. args: [],
  2613. source: "shouldReturn\x0a\x09^ self returnValue notNil",
  2614. messageSends: ["notNil", "returnValue"],
  2615. referencedClasses: []
  2616. }),
  2617. smalltalk.Interpreter);
  2618. smalltalk.addMethod(
  2619. smalltalk.method({
  2620. selector: "skip",
  2621. category: 'interpreting',
  2622. fn: function (){
  2623. var self=this;
  2624. return smalltalk.withContext(function($ctx1) {
  2625. self._next();
  2626. return self}, function($ctx1) {$ctx1.fill(self,"skip",{},smalltalk.Interpreter)})},
  2627. args: [],
  2628. source: "skip\x0a\x09self next",
  2629. messageSends: ["next"],
  2630. referencedClasses: []
  2631. }),
  2632. smalltalk.Interpreter);
  2633. smalltalk.addMethod(
  2634. smalltalk.method({
  2635. selector: "stack",
  2636. category: 'accessing',
  2637. fn: function (){
  2638. var self=this;
  2639. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  2640. return smalltalk.withContext(function($ctx1) {
  2641. var $2,$1;
  2642. $2=self["@stack"];
  2643. if(($receiver = $2) == nil || $receiver == undefined){
  2644. self["@stack"]=_st($OrderedCollection())._new();
  2645. $1=self["@stack"];
  2646. } else {
  2647. $1=$2;
  2648. };
  2649. return $1;
  2650. }, function($ctx1) {$ctx1.fill(self,"stack",{},smalltalk.Interpreter)})},
  2651. args: [],
  2652. source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
  2653. messageSends: ["ifNil:", "new"],
  2654. referencedClasses: ["OrderedCollection"]
  2655. }),
  2656. smalltalk.Interpreter);
  2657. smalltalk.addMethod(
  2658. smalltalk.method({
  2659. selector: "step",
  2660. category: 'interpreting',
  2661. fn: function (){
  2662. var self=this;
  2663. return smalltalk.withContext(function($ctx1) {
  2664. var $1,$2;
  2665. $1=self;
  2666. _st($1)._interpret();
  2667. $2=_st($1)._next();
  2668. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.Interpreter)})},
  2669. args: [],
  2670. source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
  2671. messageSends: ["interpret", "next"],
  2672. referencedClasses: []
  2673. }),
  2674. smalltalk.Interpreter);
  2675. smalltalk.addMethod(
  2676. smalltalk.method({
  2677. selector: "stepOver",
  2678. category: 'interpreting',
  2679. fn: function (){
  2680. var self=this;
  2681. return smalltalk.withContext(function($ctx1) {
  2682. self._step();
  2683. _st((function(){
  2684. return smalltalk.withContext(function($ctx2) {
  2685. return _st(self._node())._isSteppingNode();
  2686. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  2687. return smalltalk.withContext(function($ctx2) {
  2688. return self._step();
  2689. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  2690. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.Interpreter)})},
  2691. args: [],
  2692. source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isSteppingNode ] whileFalse: [ \x0a\x09\x09self step ]",
  2693. messageSends: ["step", "whileFalse:", "isSteppingNode", "node"],
  2694. referencedClasses: []
  2695. }),
  2696. smalltalk.Interpreter);
  2697. smalltalk.addMethod(
  2698. smalltalk.method({
  2699. selector: "visit:",
  2700. category: 'visiting',
  2701. fn: function (aNode){
  2702. var self=this;
  2703. return smalltalk.withContext(function($ctx1) {
  2704. var $1;
  2705. $1=self._shouldReturn();
  2706. if(! smalltalk.assert($1)){
  2707. smalltalk.Interpreter.superclass.fn.prototype._visit_.apply(_st(self), [aNode]);
  2708. };
  2709. return self}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},smalltalk.Interpreter)})},
  2710. args: ["aNode"],
  2711. source: "visit: aNode\x0a\x09self shouldReturn ifFalse: [ super visit: aNode ]",
  2712. messageSends: ["ifFalse:", "shouldReturn", "visit:"],
  2713. referencedClasses: []
  2714. }),
  2715. smalltalk.Interpreter);
  2716. smalltalk.addMethod(
  2717. smalltalk.method({
  2718. selector: "visitAssignmentNode:",
  2719. category: 'visiting',
  2720. fn: function (aNode){
  2721. var self=this;
  2722. var poppedValue;
  2723. return smalltalk.withContext(function($ctx1) {
  2724. poppedValue=self._pop();
  2725. self._pop();
  2726. self._push_(poppedValue);
  2727. self._assign_to_(_st(aNode)._left(),poppedValue);
  2728. return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,poppedValue:poppedValue},smalltalk.Interpreter)})},
  2729. args: ["aNode"],
  2730. source: "visitAssignmentNode: aNode\x0a\x09| poppedValue |\x0a\x09\x0a\x09poppedValue := self pop.\x0a\x09\x0a\x09\x22Pop the left side of the assignment.\x0a\x09It already has been visited, and we don't need its value.\x22\x0a\x09self pop.\x0a\x09\x0a\x09self push: poppedValue.\x0a\x09self assign: aNode left to: poppedValue",
  2731. messageSends: ["pop", "push:", "assign:to:", "left"],
  2732. referencedClasses: []
  2733. }),
  2734. smalltalk.Interpreter);
  2735. smalltalk.addMethod(
  2736. smalltalk.method({
  2737. selector: "visitBlockNode:",
  2738. category: 'visiting',
  2739. fn: function (aNode){
  2740. var self=this;
  2741. var block;
  2742. function $AIBlockClosure(){return smalltalk.AIBlockClosure||(typeof AIBlockClosure=="undefined"?nil:AIBlockClosure)}
  2743. return smalltalk.withContext(function($ctx1) {
  2744. block=_st($AIBlockClosure())._forContext_node_(self._context(),aNode);
  2745. self._push_(block);
  2746. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,block:block},smalltalk.Interpreter)})},
  2747. args: ["aNode"],
  2748. source: "visitBlockNode: aNode\x0a\x09\x22Do not evaluate the block node.\x0a\x09Instead, put all instructions into a block that we push to the stack for later evaluation\x22\x0a\x09\x0a\x09| block |\x0a\x09\x0a\x09block := AIBlockClosure forContext: self context node: aNode.\x0a\x09\x0a\x09self push: block",
  2749. messageSends: ["forContext:node:", "context", "push:"],
  2750. referencedClasses: ["AIBlockClosure"]
  2751. }),
  2752. smalltalk.Interpreter);
  2753. smalltalk.addMethod(
  2754. smalltalk.method({
  2755. selector: "visitClassReferenceNode:",
  2756. category: 'visiting',
  2757. fn: function (aNode){
  2758. var self=this;
  2759. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  2760. return smalltalk.withContext(function($ctx1) {
  2761. self._push_(_st(_st($Smalltalk())._current())._at_(_st(aNode)._value()));
  2762. return self}, function($ctx1) {$ctx1.fill(self,"visitClassReferenceNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2763. args: ["aNode"],
  2764. source: "visitClassReferenceNode: aNode\x0a\x09self push: (Smalltalk current at: aNode value)",
  2765. messageSends: ["push:", "at:", "current", "value"],
  2766. referencedClasses: ["Smalltalk"]
  2767. }),
  2768. smalltalk.Interpreter);
  2769. smalltalk.addMethod(
  2770. smalltalk.method({
  2771. selector: "visitDynamicArrayNode:",
  2772. category: 'visiting',
  2773. fn: function (aNode){
  2774. var self=this;
  2775. var array;
  2776. return smalltalk.withContext(function($ctx1) {
  2777. array=[];
  2778. _st(_st(aNode)._nodes())._do_((function(each){
  2779. return smalltalk.withContext(function($ctx2) {
  2780. return _st(array)._addFirst_(self._pop());
  2781. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  2782. self._push_(array);
  2783. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},smalltalk.Interpreter)})},
  2784. args: ["aNode"],
  2785. source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09\x0a\x09array := #().\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09array addFirst: self pop ].\x0a\x09\x0a\x09self push: array",
  2786. messageSends: ["do:", "nodes", "addFirst:", "pop", "push:"],
  2787. referencedClasses: []
  2788. }),
  2789. smalltalk.Interpreter);
  2790. smalltalk.addMethod(
  2791. smalltalk.method({
  2792. selector: "visitDynamicDictionaryNode:",
  2793. category: 'visiting',
  2794. fn: function (aNode){
  2795. var self=this;
  2796. var hashedCollection;
  2797. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  2798. return smalltalk.withContext(function($ctx1) {
  2799. hashedCollection=_st($HashedCollection())._new();
  2800. _st(_st(aNode)._nodes())._do_((function(each){
  2801. return smalltalk.withContext(function($ctx2) {
  2802. return _st(hashedCollection)._add_(self._pop());
  2803. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  2804. self._push_(hashedCollection);
  2805. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,hashedCollection:hashedCollection},smalltalk.Interpreter)})},
  2806. args: ["aNode"],
  2807. source: "visitDynamicDictionaryNode: aNode\x0a\x09| hashedCollection |\x0a\x09\x0a\x09hashedCollection := HashedCollection new.\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09hashedCollection add: self pop ].\x0a\x09\x0a\x09self push: hashedCollection",
  2808. messageSends: ["new", "do:", "nodes", "add:", "pop", "push:"],
  2809. referencedClasses: ["HashedCollection"]
  2810. }),
  2811. smalltalk.Interpreter);
  2812. smalltalk.addMethod(
  2813. smalltalk.method({
  2814. selector: "visitJSStatementNode:",
  2815. category: 'visiting',
  2816. fn: function (aNode){
  2817. var self=this;
  2818. return smalltalk.withContext(function($ctx1) {
  2819. self._returnValue_(self._eval_(_st(aNode)._source()));
  2820. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2821. args: ["aNode"],
  2822. source: "visitJSStatementNode: aNode\x0a\x09self returnValue: (self eval: aNode source)",
  2823. messageSends: ["returnValue:", "eval:", "source"],
  2824. referencedClasses: []
  2825. }),
  2826. smalltalk.Interpreter);
  2827. smalltalk.addMethod(
  2828. smalltalk.method({
  2829. selector: "visitNode:",
  2830. category: 'visiting',
  2831. fn: function (aNode){
  2832. var self=this;
  2833. return smalltalk.withContext(function($ctx1) {
  2834. return self}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2835. args: ["aNode"],
  2836. source: "visitNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
  2837. messageSends: [],
  2838. referencedClasses: []
  2839. }),
  2840. smalltalk.Interpreter);
  2841. smalltalk.addMethod(
  2842. smalltalk.method({
  2843. selector: "visitReturnNode:",
  2844. category: 'visiting',
  2845. fn: function (aNode){
  2846. var self=this;
  2847. return smalltalk.withContext(function($ctx1) {
  2848. self._returnValue_(self._pop());
  2849. return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2850. args: ["aNode"],
  2851. source: "visitReturnNode: aNode\x0a\x09self returnValue: self pop",
  2852. messageSends: ["returnValue:", "pop"],
  2853. referencedClasses: []
  2854. }),
  2855. smalltalk.Interpreter);
  2856. smalltalk.addMethod(
  2857. smalltalk.method({
  2858. selector: "visitSendNode:",
  2859. category: 'visiting',
  2860. fn: function (aNode){
  2861. var self=this;
  2862. var receiver,args,message,result;
  2863. return smalltalk.withContext(function($ctx1) {
  2864. var $1;
  2865. args=_st(_st(aNode)._arguments())._collect_((function(each){
  2866. return smalltalk.withContext(function($ctx2) {
  2867. return self._pop();
  2868. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  2869. receiver=self._pop();
  2870. message=self._messageFromSendNode_arguments_(aNode,_st(args)._reversed());
  2871. result=self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend());
  2872. _st(self._context())._pc_(_st(_st(self._context())._pc()).__plus((1)));
  2873. $1=_st(_st(aNode)._isCascadeSendNode())._and_((function(){
  2874. return smalltalk.withContext(function($ctx2) {
  2875. return _st(_st(aNode)._isLastChild())._not();
  2876. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  2877. if(smalltalk.assert($1)){
  2878. self._push_(receiver);
  2879. } else {
  2880. self._push_(result);
  2881. };
  2882. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},smalltalk.Interpreter)})},
  2883. args: ["aNode"],
  2884. source: "visitSendNode: aNode\x0a\x09| receiver args message result |\x0a\x09\x0a\x09args := aNode arguments collect: [ :each | self pop ].\x0a\x09receiver := self pop.\x0a\x09\x0a\x09message := self\x0a\x09\x09messageFromSendNode: aNode\x0a\x09\x09arguments: args reversed.\x0a\x09\x0a\x09result := self sendMessage: message to: receiver superSend: aNode superSend.\x0a\x09\x0a\x09self context pc: self context pc + 1.\x0a\x09\x0a\x09\x22For cascade sends, push the reciever if the send is not the last one\x22\x0a\x09(aNode isCascadeSendNode and: [ aNode isLastChild not ])\x0a\x09\x09ifTrue: [ self push: receiver ]\x0a\x09\x09ifFalse: [ self push: result ]",
  2885. messageSends: ["collect:", "arguments", "pop", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "pc:", "context", "+", "pc", "ifTrue:ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"],
  2886. referencedClasses: []
  2887. }),
  2888. smalltalk.Interpreter);
  2889. smalltalk.addMethod(
  2890. smalltalk.method({
  2891. selector: "visitValueNode:",
  2892. category: 'visiting',
  2893. fn: function (aNode){
  2894. var self=this;
  2895. return smalltalk.withContext(function($ctx1) {
  2896. self._push_(_st(aNode)._value());
  2897. return self}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2898. args: ["aNode"],
  2899. source: "visitValueNode: aNode\x0a\x09self push: aNode value",
  2900. messageSends: ["push:", "value"],
  2901. referencedClasses: []
  2902. }),
  2903. smalltalk.Interpreter);
  2904. smalltalk.addMethod(
  2905. smalltalk.method({
  2906. selector: "visitVariableNode:",
  2907. category: 'visiting',
  2908. fn: function (aNode){
  2909. var self=this;
  2910. return smalltalk.withContext(function($ctx1) {
  2911. var $1,$2,$3,$5,$4;
  2912. $1=_st(_st(aNode)._binding())._isUnknownVar();
  2913. if(smalltalk.assert($1)){
  2914. $2=self._push_(_st(window)._at_ifAbsent_(_st(aNode)._value(),(function(){
  2915. return smalltalk.withContext(function($ctx2) {
  2916. return self._error_("Unknown variable");
  2917. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})));
  2918. return $2;
  2919. };
  2920. $3=self;
  2921. $5=_st(_st(aNode)._binding())._isInstanceVar();
  2922. if(smalltalk.assert($5)){
  2923. $4=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
  2924. } else {
  2925. $4=_st(self._context())._localAt_(_st(aNode)._value());
  2926. };
  2927. _st($3)._push_($4);
  2928. return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2929. args: ["aNode"],
  2930. source: "visitVariableNode: aNode\x0a\x09aNode binding isUnknownVar ifTrue: [\x0a\x09\x09^ self push: (window at: aNode value ifAbsent: [ self error: 'Unknown variable' ]) ].\x0a\x09\x09\x0a\x09self push: (aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value ])",
  2931. messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:"],
  2932. referencedClasses: []
  2933. }),
  2934. smalltalk.Interpreter);
  2935. smalltalk.addMethod(
  2936. smalltalk.method({
  2937. selector: "interpreter:continue:",
  2938. category: '*Compiler-Interpreter',
  2939. fn: function (anInterpreter,aBlock){
  2940. var self=this;
  2941. return smalltalk.withContext(function($ctx1) {
  2942. var $1;
  2943. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  2944. return $1;
  2945. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.Node)})},
  2946. args: ["anInterpreter", "aBlock"],
  2947. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  2948. messageSends: ["interpretNode:continue:"],
  2949. referencedClasses: []
  2950. }),
  2951. smalltalk.Node);
  2952. smalltalk.addMethod(
  2953. smalltalk.method({
  2954. selector: "isSteppingNode",
  2955. category: '*Compiler-Interpreter',
  2956. fn: function (){
  2957. var self=this;
  2958. return smalltalk.withContext(function($ctx1) {
  2959. return false;
  2960. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
  2961. args: [],
  2962. source: "isSteppingNode\x0a\x09^ false",
  2963. messageSends: [],
  2964. referencedClasses: []
  2965. }),
  2966. smalltalk.Node);
  2967. smalltalk.addMethod(
  2968. smalltalk.method({
  2969. selector: "interpreter:continue:",
  2970. category: '*Compiler-Interpreter',
  2971. fn: function (anInterpreter,aBlock){
  2972. var self=this;
  2973. return smalltalk.withContext(function($ctx1) {
  2974. var $1;
  2975. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  2976. return $1;
  2977. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.AssignmentNode)})},
  2978. args: ["anInterpreter", "aBlock"],
  2979. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  2980. messageSends: ["interpretAssignmentNode:continue:"],
  2981. referencedClasses: []
  2982. }),
  2983. smalltalk.AssignmentNode);
  2984. smalltalk.addMethod(
  2985. smalltalk.method({
  2986. selector: "isSteppingNode",
  2987. category: '*Compiler-Interpreter',
  2988. fn: function (){
  2989. var self=this;
  2990. return smalltalk.withContext(function($ctx1) {
  2991. return true;
  2992. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.AssignmentNode)})},
  2993. args: [],
  2994. source: "isSteppingNode\x0a\x09^ true",
  2995. messageSends: [],
  2996. referencedClasses: []
  2997. }),
  2998. smalltalk.AssignmentNode);
  2999. smalltalk.addMethod(
  3000. smalltalk.method({
  3001. selector: "interpreter:continue:",
  3002. category: '*Compiler-Interpreter',
  3003. fn: function (anInterpreter,aBlock){
  3004. var self=this;
  3005. return smalltalk.withContext(function($ctx1) {
  3006. var $1;
  3007. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  3008. return $1;
  3009. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockNode)})},
  3010. args: ["anInterpreter", "aBlock"],
  3011. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  3012. messageSends: ["interpretBlockNode:continue:"],
  3013. referencedClasses: []
  3014. }),
  3015. smalltalk.BlockNode);
  3016. smalltalk.addMethod(
  3017. smalltalk.method({
  3018. selector: "isSteppingNode",
  3019. category: '*Compiler-Interpreter',
  3020. fn: function (){
  3021. var self=this;
  3022. return smalltalk.withContext(function($ctx1) {
  3023. return true;
  3024. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
  3025. args: [],
  3026. source: "isSteppingNode\x0a\x09^ true",
  3027. messageSends: [],
  3028. referencedClasses: []
  3029. }),
  3030. smalltalk.BlockNode);
  3031. smalltalk.addMethod(
  3032. smalltalk.method({
  3033. selector: "interpreter:continue:",
  3034. category: '*Compiler-Interpreter',
  3035. fn: function (anInterpreter,aBlock){
  3036. var self=this;
  3037. return smalltalk.withContext(function($ctx1) {
  3038. var $1;
  3039. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  3040. return $1;
  3041. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.CascadeNode)})},
  3042. args: ["anInterpreter", "aBlock"],
  3043. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  3044. messageSends: ["interpretCascadeNode:continue:"],
  3045. referencedClasses: []
  3046. }),
  3047. smalltalk.CascadeNode);
  3048. smalltalk.addMethod(
  3049. smalltalk.method({
  3050. selector: "interpreter:continue:",
  3051. category: '*Compiler-Interpreter',
  3052. fn: function (anInterpreter,aBlock){
  3053. var self=this;
  3054. return smalltalk.withContext(function($ctx1) {
  3055. var $1;
  3056. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  3057. return $1;
  3058. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicArrayNode)})},
  3059. args: ["anInterpreter", "aBlock"],
  3060. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  3061. messageSends: ["interpretDynamicArrayNode:continue:"],
  3062. referencedClasses: []
  3063. }),
  3064. smalltalk.DynamicArrayNode);
  3065. smalltalk.addMethod(
  3066. smalltalk.method({
  3067. selector: "isSteppingNode",
  3068. category: '*Compiler-Interpreter',
  3069. fn: function (){
  3070. var self=this;
  3071. return smalltalk.withContext(function($ctx1) {
  3072. return true;
  3073. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
  3074. args: [],
  3075. source: "isSteppingNode\x0a\x09^ true",
  3076. messageSends: [],
  3077. referencedClasses: []
  3078. }),
  3079. smalltalk.DynamicArrayNode);
  3080. smalltalk.addMethod(
  3081. smalltalk.method({
  3082. selector: "interpreter:continue:",
  3083. category: '*Compiler-Interpreter',
  3084. fn: function (anInterpreter,aBlock){
  3085. var self=this;
  3086. return smalltalk.withContext(function($ctx1) {
  3087. var $1;
  3088. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  3089. return $1;
  3090. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicDictionaryNode)})},
  3091. args: ["anInterpreter", "aBlock"],
  3092. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  3093. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  3094. referencedClasses: []
  3095. }),
  3096. smalltalk.DynamicDictionaryNode);
  3097. smalltalk.addMethod(
  3098. smalltalk.method({
  3099. selector: "isSteppingNode",
  3100. category: '*Compiler-Interpreter',
  3101. fn: function (){
  3102. var self=this;
  3103. return smalltalk.withContext(function($ctx1) {
  3104. return true;
  3105. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
  3106. args: [],
  3107. source: "isSteppingNode\x0a\x09^ true",
  3108. messageSends: [],
  3109. referencedClasses: []
  3110. }),
  3111. smalltalk.DynamicDictionaryNode);
  3112. smalltalk.addMethod(
  3113. smalltalk.method({
  3114. selector: "interpreter:continue:",
  3115. category: '*Compiler-Interpreter',
  3116. fn: function (anInterpreter,aBlock){
  3117. var self=this;
  3118. return smalltalk.withContext(function($ctx1) {
  3119. var $1;
  3120. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  3121. return $1;
  3122. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.JSStatementNode)})},
  3123. args: ["anInterpreter", "aBlock"],
  3124. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  3125. messageSends: ["interpretJSStatementNode:continue:"],
  3126. referencedClasses: []
  3127. }),
  3128. smalltalk.JSStatementNode);
  3129. smalltalk.addMethod(
  3130. smalltalk.method({
  3131. selector: "isSteppingNode",
  3132. category: '*Compiler-Interpreter',
  3133. fn: function (){
  3134. var self=this;
  3135. return smalltalk.withContext(function($ctx1) {
  3136. return true;
  3137. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
  3138. args: [],
  3139. source: "isSteppingNode\x0a\x09^ true",
  3140. messageSends: [],
  3141. referencedClasses: []
  3142. }),
  3143. smalltalk.JSStatementNode);
  3144. smalltalk.addMethod(
  3145. smalltalk.method({
  3146. selector: "interpreter:continue:",
  3147. category: '*Compiler-Interpreter',
  3148. fn: function (anInterpreter,aBlock){
  3149. var self=this;
  3150. return smalltalk.withContext(function($ctx1) {
  3151. var $1;
  3152. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  3153. return $1;
  3154. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.MethodNode)})},
  3155. args: ["anInterpreter", "aBlock"],
  3156. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  3157. messageSends: ["interpretMethodNode:continue:"],
  3158. referencedClasses: []
  3159. }),
  3160. smalltalk.MethodNode);
  3161. smalltalk.addMethod(
  3162. smalltalk.method({
  3163. selector: "interpreter:continue:",
  3164. category: '*Compiler-Interpreter',
  3165. fn: function (anInterpreter,aBlock){
  3166. var self=this;
  3167. return smalltalk.withContext(function($ctx1) {
  3168. var $1;
  3169. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  3170. return $1;
  3171. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ReturnNode)})},
  3172. args: ["anInterpreter", "aBlock"],
  3173. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  3174. messageSends: ["interpretReturnNode:continue:"],
  3175. referencedClasses: []
  3176. }),
  3177. smalltalk.ReturnNode);
  3178. smalltalk.addMethod(
  3179. smalltalk.method({
  3180. selector: "interpreter:continue:",
  3181. category: '*Compiler-Interpreter',
  3182. fn: function (anInterpreter,aBlock){
  3183. var self=this;
  3184. return smalltalk.withContext(function($ctx1) {
  3185. var $1;
  3186. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  3187. return $1;
  3188. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SendNode)})},
  3189. args: ["anInterpreter", "aBlock"],
  3190. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  3191. messageSends: ["interpretSendNode:continue:"],
  3192. referencedClasses: []
  3193. }),
  3194. smalltalk.SendNode);
  3195. smalltalk.addMethod(
  3196. smalltalk.method({
  3197. selector: "isSteppingNode",
  3198. category: '*Compiler-Interpreter',
  3199. fn: function (){
  3200. var self=this;
  3201. return smalltalk.withContext(function($ctx1) {
  3202. return true;
  3203. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
  3204. args: [],
  3205. source: "isSteppingNode\x0a\x09^ true",
  3206. messageSends: [],
  3207. referencedClasses: []
  3208. }),
  3209. smalltalk.SendNode);
  3210. smalltalk.addMethod(
  3211. smalltalk.method({
  3212. selector: "interpreter:continue:",
  3213. category: '*Compiler-Interpreter',
  3214. fn: function (anInterpreter,aBlock){
  3215. var self=this;
  3216. return smalltalk.withContext(function($ctx1) {
  3217. var $1;
  3218. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  3219. return $1;
  3220. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SequenceNode)})},
  3221. args: ["anInterpreter", "aBlock"],
  3222. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  3223. messageSends: ["interpretSequenceNode:continue:"],
  3224. referencedClasses: []
  3225. }),
  3226. smalltalk.SequenceNode);
  3227. smalltalk.addMethod(
  3228. smalltalk.method({
  3229. selector: "interpreter:continue:",
  3230. category: '*Compiler-Interpreter',
  3231. fn: function (anInterpreter,aBlock){
  3232. var self=this;
  3233. return smalltalk.withContext(function($ctx1) {
  3234. var $1;
  3235. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  3236. return $1;
  3237. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockSequenceNode)})},
  3238. args: ["anInterpreter", "aBlock"],
  3239. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  3240. messageSends: ["interpretBlockSequenceNode:continue:"],
  3241. referencedClasses: []
  3242. }),
  3243. smalltalk.BlockSequenceNode);
  3244. smalltalk.addMethod(
  3245. smalltalk.method({
  3246. selector: "interpreter:continue:",
  3247. category: '*Compiler-Interpreter',
  3248. fn: function (anInterpreter,aBlock){
  3249. var self=this;
  3250. return smalltalk.withContext(function($ctx1) {
  3251. var $1;
  3252. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  3253. return $1;
  3254. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ValueNode)})},
  3255. args: ["anInterpreter", "aBlock"],
  3256. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  3257. messageSends: ["interpretValueNode:continue:"],
  3258. referencedClasses: []
  3259. }),
  3260. smalltalk.ValueNode);
  3261. smalltalk.addMethod(
  3262. smalltalk.method({
  3263. selector: "interpreter:continue:",
  3264. category: '*Compiler-Interpreter',
  3265. fn: function (anInterpreter,aBlock){
  3266. var self=this;
  3267. return smalltalk.withContext(function($ctx1) {
  3268. var $1;
  3269. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  3270. return $1;
  3271. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.VariableNode)})},
  3272. args: ["anInterpreter", "aBlock"],
  3273. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  3274. messageSends: ["interpretVariableNode:continue:"],
  3275. referencedClasses: []
  3276. }),
  3277. smalltalk.VariableNode);
  3278. smalltalk.addMethod(
  3279. smalltalk.method({
  3280. selector: "interpreter:continue:",
  3281. category: '*Compiler-Interpreter',
  3282. fn: function (anInterpreter,aBlock){
  3283. var self=this;
  3284. return smalltalk.withContext(function($ctx1) {
  3285. var $1;
  3286. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  3287. return $1;
  3288. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ClassReferenceNode)})},
  3289. args: ["anInterpreter", "aBlock"],
  3290. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  3291. messageSends: ["interpretClassReferenceNode:continue:"],
  3292. referencedClasses: []
  3293. }),
  3294. smalltalk.ClassReferenceNode);