Compiler-Interpreter.js 129 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987
  1. define(["amber/boot", "amber_core/Compiler-AST", "amber_core/Compiler-Semantic", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Methods", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  3. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  4. $core.addPackage("Compiler-Interpreter");
  5. ($core.packageDescriptors||$core.packages)["Compiler-Interpreter"].innerEval = function (expr) { return eval(expr); };
  6. ($core.packageDescriptors||$core.packages)["Compiler-Interpreter"].transport = {"type":"amd","amdNamespace":"amber_core"};
  7. $core.addClass("AIBlockClosure", $globals.BlockClosure, ["node", "outerContext"], "Compiler-Interpreter");
  8. //>>excludeStart("ide", pragmas.excludeIdeData);
  9. $globals.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`).";
  10. //>>excludeEnd("ide");
  11. $core.addMethod(
  12. $core.method({
  13. selector: "applyTo:arguments:",
  14. protocol: "evaluating",
  15. fn: function (anObject,aCollection){
  16. var self=this,$self=this;
  17. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  18. return $core.withContext(function($ctx1) {
  19. //>>excludeEnd("ctx");
  20. $self._interpreterError();
  21. return self;
  22. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  23. }, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},$globals.AIBlockClosure)});
  24. //>>excludeEnd("ctx");
  25. },
  26. //>>excludeStart("ide", pragmas.excludeIdeData);
  27. args: ["anObject", "aCollection"],
  28. source: "applyTo: anObject arguments: aCollection\x0a\x09self interpreterError",
  29. referencedClasses: [],
  30. //>>excludeEnd("ide");
  31. messageSends: ["interpreterError"]
  32. }),
  33. $globals.AIBlockClosure);
  34. $core.addMethod(
  35. $core.method({
  36. selector: "compiledSource",
  37. protocol: "accessing",
  38. fn: function (){
  39. var self=this,$self=this;
  40. return "[ AST Block closure ]";
  41. },
  42. //>>excludeStart("ide", pragmas.excludeIdeData);
  43. args: [],
  44. source: "compiledSource\x0a\x09\x22Unlike blocks, the receiver doesn't represent a JS function\x22\x0a\x09\x0a\x09^ '[ AST Block closure ]'",
  45. referencedClasses: [],
  46. //>>excludeEnd("ide");
  47. messageSends: []
  48. }),
  49. $globals.AIBlockClosure);
  50. $core.addMethod(
  51. $core.method({
  52. selector: "currySelf",
  53. protocol: "converting",
  54. fn: function (){
  55. var self=this,$self=this;
  56. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  57. return $core.withContext(function($ctx1) {
  58. //>>excludeEnd("ctx");
  59. $self._interpreterError();
  60. return self;
  61. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  62. }, function($ctx1) {$ctx1.fill(self,"currySelf",{},$globals.AIBlockClosure)});
  63. //>>excludeEnd("ctx");
  64. },
  65. //>>excludeStart("ide", pragmas.excludeIdeData);
  66. args: [],
  67. source: "currySelf\x0a\x09self interpreterError",
  68. referencedClasses: [],
  69. //>>excludeEnd("ide");
  70. messageSends: ["interpreterError"]
  71. }),
  72. $globals.AIBlockClosure);
  73. $core.addMethod(
  74. $core.method({
  75. selector: "initializeWithContext:node:",
  76. protocol: "initialization",
  77. fn: function (aContext,aNode){
  78. var self=this,$self=this;
  79. $self["@node"]=aNode;
  80. $self["@outerContext"]=aContext;
  81. return self;
  82. },
  83. //>>excludeStart("ide", pragmas.excludeIdeData);
  84. args: ["aContext", "aNode"],
  85. source: "initializeWithContext: aContext node: aNode\x0a\x09node := aNode.\x0a\x09outerContext := aContext",
  86. referencedClasses: [],
  87. //>>excludeEnd("ide");
  88. messageSends: []
  89. }),
  90. $globals.AIBlockClosure);
  91. $core.addMethod(
  92. $core.method({
  93. selector: "interpreterError",
  94. protocol: "error handling",
  95. fn: function (){
  96. var self=this,$self=this;
  97. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  98. return $core.withContext(function($ctx1) {
  99. //>>excludeEnd("ctx");
  100. $recv($globals.ASTInterpreterError)._signal_("Method cannot be interpreted by the interpreter.");
  101. return self;
  102. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  103. }, function($ctx1) {$ctx1.fill(self,"interpreterError",{},$globals.AIBlockClosure)});
  104. //>>excludeEnd("ctx");
  105. },
  106. //>>excludeStart("ide", pragmas.excludeIdeData);
  107. args: [],
  108. source: "interpreterError\x0a\x09ASTInterpreterError signal: 'Method cannot be interpreted by the interpreter.'",
  109. referencedClasses: ["ASTInterpreterError"],
  110. //>>excludeEnd("ide");
  111. messageSends: ["signal:"]
  112. }),
  113. $globals.AIBlockClosure);
  114. $core.addMethod(
  115. $core.method({
  116. selector: "numArgs",
  117. protocol: "accessing",
  118. fn: function (){
  119. var self=this,$self=this;
  120. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  121. return $core.withContext(function($ctx1) {
  122. //>>excludeEnd("ctx");
  123. return $recv($recv($self["@node"])._temps())._size();
  124. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  125. }, function($ctx1) {$ctx1.fill(self,"numArgs",{},$globals.AIBlockClosure)});
  126. //>>excludeEnd("ctx");
  127. },
  128. //>>excludeStart("ide", pragmas.excludeIdeData);
  129. args: [],
  130. source: "numArgs\x0a\x09^ node temps size",
  131. referencedClasses: [],
  132. //>>excludeEnd("ide");
  133. messageSends: ["size", "temps"]
  134. }),
  135. $globals.AIBlockClosure);
  136. $core.addMethod(
  137. $core.method({
  138. selector: "value",
  139. protocol: "evaluating",
  140. fn: function (){
  141. var self=this,$self=this;
  142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  143. return $core.withContext(function($ctx1) {
  144. //>>excludeEnd("ctx");
  145. return $self._valueWithPossibleArguments_([]);
  146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  147. }, function($ctx1) {$ctx1.fill(self,"value",{},$globals.AIBlockClosure)});
  148. //>>excludeEnd("ctx");
  149. },
  150. //>>excludeStart("ide", pragmas.excludeIdeData);
  151. args: [],
  152. source: "value\x0a\x09^ self valueWithPossibleArguments: #()",
  153. referencedClasses: [],
  154. //>>excludeEnd("ide");
  155. messageSends: ["valueWithPossibleArguments:"]
  156. }),
  157. $globals.AIBlockClosure);
  158. $core.addMethod(
  159. $core.method({
  160. selector: "value:",
  161. protocol: "evaluating",
  162. fn: function (anArgument){
  163. var self=this,$self=this;
  164. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  165. return $core.withContext(function($ctx1) {
  166. //>>excludeEnd("ctx");
  167. return $self._valueWithPossibleArguments_([anArgument]);
  168. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  169. }, function($ctx1) {$ctx1.fill(self,"value:",{anArgument:anArgument},$globals.AIBlockClosure)});
  170. //>>excludeEnd("ctx");
  171. },
  172. //>>excludeStart("ide", pragmas.excludeIdeData);
  173. args: ["anArgument"],
  174. source: "value: anArgument\x0a\x09^ self valueWithPossibleArguments: {anArgument}",
  175. referencedClasses: [],
  176. //>>excludeEnd("ide");
  177. messageSends: ["valueWithPossibleArguments:"]
  178. }),
  179. $globals.AIBlockClosure);
  180. $core.addMethod(
  181. $core.method({
  182. selector: "value:value:",
  183. protocol: "evaluating",
  184. fn: function (firstArgument,secondArgument){
  185. var self=this,$self=this;
  186. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  187. return $core.withContext(function($ctx1) {
  188. //>>excludeEnd("ctx");
  189. return $self._valueWithPossibleArguments_([firstArgument,secondArgument]);
  190. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  191. }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},$globals.AIBlockClosure)});
  192. //>>excludeEnd("ctx");
  193. },
  194. //>>excludeStart("ide", pragmas.excludeIdeData);
  195. args: ["firstArgument", "secondArgument"],
  196. source: "value: firstArgument value: secondArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument}",
  197. referencedClasses: [],
  198. //>>excludeEnd("ide");
  199. messageSends: ["valueWithPossibleArguments:"]
  200. }),
  201. $globals.AIBlockClosure);
  202. $core.addMethod(
  203. $core.method({
  204. selector: "value:value:value:",
  205. protocol: "evaluating",
  206. fn: function (firstArgument,secondArgument,thirdArgument){
  207. var self=this,$self=this;
  208. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  209. return $core.withContext(function($ctx1) {
  210. //>>excludeEnd("ctx");
  211. return $self._valueWithPossibleArguments_([firstArgument,secondArgument,thirdArgument]);
  212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  213. }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},$globals.AIBlockClosure)});
  214. //>>excludeEnd("ctx");
  215. },
  216. //>>excludeStart("ide", pragmas.excludeIdeData);
  217. args: ["firstArgument", "secondArgument", "thirdArgument"],
  218. source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument . thirdArgument}",
  219. referencedClasses: [],
  220. //>>excludeEnd("ide");
  221. messageSends: ["valueWithPossibleArguments:"]
  222. }),
  223. $globals.AIBlockClosure);
  224. $core.addMethod(
  225. $core.method({
  226. selector: "valueWithPossibleArguments:",
  227. protocol: "evaluating",
  228. fn: function (aCollection){
  229. var self=this,$self=this;
  230. var context,sequenceNode;
  231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  232. return $core.withContext(function($ctx1) {
  233. //>>excludeEnd("ctx");
  234. var $1,$2,$3;
  235. context=$recv($self["@outerContext"])._newInnerContext();
  236. $1=$recv($recv($recv($self["@node"])._dagChildren())._first())._copy();
  237. $recv($1)._parent_(nil);
  238. sequenceNode=$recv($1)._yourself();
  239. $recv($recv(sequenceNode)._temps())._do_((function(each){
  240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  241. return $core.withContext(function($ctx2) {
  242. //>>excludeEnd("ctx");
  243. return $recv(context)._defineLocal_(each);
  244. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  245. $ctx2.sendIdx["defineLocal:"]=1;
  246. //>>excludeEnd("ctx");
  247. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  248. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  249. //>>excludeEnd("ctx");
  250. }));
  251. $recv($recv($self["@node"])._parameters())._withIndexDo_((function(each,index){
  252. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  253. return $core.withContext(function($ctx2) {
  254. //>>excludeEnd("ctx");
  255. $recv(context)._defineLocal_(each);
  256. return $recv(context)._localAt_put_(each,$recv(aCollection)._at_ifAbsent_(index,(function(){
  257. return nil;
  258. })));
  259. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  260. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,2)});
  261. //>>excludeEnd("ctx");
  262. }));
  263. $2=$recv(context)._interpreter();
  264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  265. $ctx1.sendIdx["interpreter"]=1;
  266. //>>excludeEnd("ctx");
  267. $recv($2)._node_(sequenceNode);
  268. $recv($2)._enterNode();
  269. $recv($2)._proceed();
  270. $3=$recv($self["@outerContext"])._interpreter();
  271. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  272. $ctx1.sendIdx["interpreter"]=2;
  273. //>>excludeEnd("ctx");
  274. $recv($3)._setNonLocalReturnFromContext_(context);
  275. return $recv($recv(context)._interpreter())._pop();
  276. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  277. }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection,context:context,sequenceNode:sequenceNode},$globals.AIBlockClosure)});
  278. //>>excludeEnd("ctx");
  279. },
  280. //>>excludeStart("ide", pragmas.excludeIdeData);
  281. args: ["aCollection"],
  282. source: "valueWithPossibleArguments: aCollection\x0a\x09| context sequenceNode |\x0a\x09context := outerContext newInnerContext.\x0a\x0a\x09\x22Interpret a copy of the sequence node to avoid creating a new AIBlockClosure\x22\x0a\x09sequenceNode := node dagChildren first copy\x0a\x09\x09parent: nil;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09\x22Define locals in the context\x22\x0a\x09sequenceNode temps do: [ :each |\x0a\x09\x09context defineLocal: each ].\x0a\x09\x09\x0a\x09\x22Populate the arguments into the context locals\x22\x09\x0a\x09node parameters withIndexDo: [ :each :index |\x0a\x09\x09context defineLocal: each.\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;\x0a\x09\x09enterNode;\x0a\x09\x09proceed.\x0a\x09\x09\x0a\x09outerContext interpreter\x0a\x09\x09setNonLocalReturnFromContext: context.\x0a\x09\x09\x0a\x09^ context interpreter pop",
  283. referencedClasses: [],
  284. //>>excludeEnd("ide");
  285. messageSends: ["newInnerContext", "parent:", "copy", "first", "dagChildren", "yourself", "do:", "temps", "defineLocal:", "withIndexDo:", "parameters", "localAt:put:", "at:ifAbsent:", "node:", "interpreter", "enterNode", "proceed", "setNonLocalReturnFromContext:", "pop"]
  286. }),
  287. $globals.AIBlockClosure);
  288. $core.addMethod(
  289. $core.method({
  290. selector: "forContext:node:",
  291. protocol: "instance creation",
  292. fn: function (aContext,aNode){
  293. var self=this,$self=this;
  294. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  295. return $core.withContext(function($ctx1) {
  296. //>>excludeEnd("ctx");
  297. var $1;
  298. $1=$self._new();
  299. $recv($1)._initializeWithContext_node_(aContext,aNode);
  300. return $recv($1)._yourself();
  301. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  302. }, function($ctx1) {$ctx1.fill(self,"forContext:node:",{aContext:aContext,aNode:aNode},$globals.AIBlockClosure.a$cls)});
  303. //>>excludeEnd("ctx");
  304. },
  305. //>>excludeStart("ide", pragmas.excludeIdeData);
  306. args: ["aContext", "aNode"],
  307. source: "forContext: aContext node: aNode\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext node: aNode;\x0a\x09\x09yourself",
  308. referencedClasses: [],
  309. //>>excludeEnd("ide");
  310. messageSends: ["initializeWithContext:node:", "new", "yourself"]
  311. }),
  312. $globals.AIBlockClosure.a$cls);
  313. $core.addClass("AIContext", $globals.MethodContext, ["outerContext", "innerContext", "pc", "locals", "selector", "index", "sendIndexes", "evaluatedSelector", "ast", "interpreter", "supercall"], "Compiler-Interpreter");
  314. //>>excludeStart("ide", pragmas.excludeIdeData);
  315. $globals.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)";
  316. //>>excludeEnd("ide");
  317. $core.addMethod(
  318. $core.method({
  319. selector: "arguments",
  320. protocol: "interpreting",
  321. fn: function (){
  322. var self=this,$self=this;
  323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  324. return $core.withContext(function($ctx1) {
  325. //>>excludeEnd("ctx");
  326. return $recv($recv($self._ast())._arguments())._collect_((function(each){
  327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  328. return $core.withContext(function($ctx2) {
  329. //>>excludeEnd("ctx");
  330. return $self._localAt_ifAbsent_(each,(function(){
  331. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  332. return $core.withContext(function($ctx3) {
  333. //>>excludeEnd("ctx");
  334. return $self._error_("Argument not in context");
  335. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  336. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  337. //>>excludeEnd("ctx");
  338. }));
  339. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  340. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  341. //>>excludeEnd("ctx");
  342. }));
  343. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  344. }, function($ctx1) {$ctx1.fill(self,"arguments",{},$globals.AIContext)});
  345. //>>excludeEnd("ctx");
  346. },
  347. //>>excludeStart("ide", pragmas.excludeIdeData);
  348. args: [],
  349. source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ifAbsent: [ self error: 'Argument not in context' ] ]",
  350. referencedClasses: [],
  351. //>>excludeEnd("ide");
  352. messageSends: ["collect:", "arguments", "ast", "localAt:ifAbsent:", "error:"]
  353. }),
  354. $globals.AIContext);
  355. $core.addMethod(
  356. $core.method({
  357. selector: "ast",
  358. protocol: "interpreting",
  359. fn: function (){
  360. var self=this,$self=this;
  361. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  362. return $core.withContext(function($ctx1) {
  363. //>>excludeEnd("ctx");
  364. var $1,$2,$3,$receiver;
  365. $1=$self._isBlockContext();
  366. if($core.assert($1)){
  367. $2=$self._outerContext();
  368. if(($receiver = $2) == null || $receiver.a$nil){
  369. return $2;
  370. } else {
  371. var context;
  372. context=$receiver;
  373. return $recv(context)._ast();
  374. }
  375. }
  376. $3=$self["@ast"];
  377. if(($receiver = $3) == null || $receiver.a$nil){
  378. $self._initializeAST();
  379. } else {
  380. $3;
  381. }
  382. return $self["@ast"];
  383. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  384. }, function($ctx1) {$ctx1.fill(self,"ast",{},$globals.AIContext)});
  385. //>>excludeEnd("ctx");
  386. },
  387. //>>excludeStart("ide", pragmas.excludeIdeData);
  388. args: [],
  389. source: "ast\x0a\x09self isBlockContext ifTrue: [ \x0a\x09\x09^ self outerContext ifNotNil: [ :context | context ast ] ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
  390. referencedClasses: [],
  391. //>>excludeEnd("ide");
  392. messageSends: ["ifTrue:", "isBlockContext", "ifNotNil:", "outerContext", "ast", "ifNil:", "initializeAST"]
  393. }),
  394. $globals.AIContext);
  395. $core.addMethod(
  396. $core.method({
  397. selector: "basicLocalAt:",
  398. protocol: "private",
  399. fn: function (aString){
  400. var self=this,$self=this;
  401. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  402. return $core.withContext(function($ctx1) {
  403. //>>excludeEnd("ctx");
  404. return $recv($self._locals())._at_(aString);
  405. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  406. }, function($ctx1) {$ctx1.fill(self,"basicLocalAt:",{aString:aString},$globals.AIContext)});
  407. //>>excludeEnd("ctx");
  408. },
  409. //>>excludeStart("ide", pragmas.excludeIdeData);
  410. args: ["aString"],
  411. source: "basicLocalAt: aString\x0a\x09^ self locals at: aString",
  412. referencedClasses: [],
  413. //>>excludeEnd("ide");
  414. messageSends: ["at:", "locals"]
  415. }),
  416. $globals.AIContext);
  417. $core.addMethod(
  418. $core.method({
  419. selector: "basicLocalAt:put:",
  420. protocol: "private",
  421. fn: function (aString,anObject){
  422. var self=this,$self=this;
  423. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  424. return $core.withContext(function($ctx1) {
  425. //>>excludeEnd("ctx");
  426. $recv($self._locals())._at_put_(aString,anObject);
  427. return self;
  428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  429. }, function($ctx1) {$ctx1.fill(self,"basicLocalAt:put:",{aString:aString,anObject:anObject},$globals.AIContext)});
  430. //>>excludeEnd("ctx");
  431. },
  432. //>>excludeStart("ide", pragmas.excludeIdeData);
  433. args: ["aString", "anObject"],
  434. source: "basicLocalAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  435. referencedClasses: [],
  436. //>>excludeEnd("ide");
  437. messageSends: ["at:put:", "locals"]
  438. }),
  439. $globals.AIContext);
  440. $core.addMethod(
  441. $core.method({
  442. selector: "basicReceiver",
  443. protocol: "interpreting",
  444. fn: function (){
  445. var self=this,$self=this;
  446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  447. return $core.withContext(function($ctx1) {
  448. //>>excludeEnd("ctx");
  449. return $self._localAt_("self");
  450. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  451. }, function($ctx1) {$ctx1.fill(self,"basicReceiver",{},$globals.AIContext)});
  452. //>>excludeEnd("ctx");
  453. },
  454. //>>excludeStart("ide", pragmas.excludeIdeData);
  455. args: [],
  456. source: "basicReceiver\x0a\x09^ self localAt: 'self'",
  457. referencedClasses: [],
  458. //>>excludeEnd("ide");
  459. messageSends: ["localAt:"]
  460. }),
  461. $globals.AIContext);
  462. $core.addMethod(
  463. $core.method({
  464. selector: "defineLocal:",
  465. protocol: "accessing",
  466. fn: function (aString){
  467. var self=this,$self=this;
  468. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  469. return $core.withContext(function($ctx1) {
  470. //>>excludeEnd("ctx");
  471. $recv($self._locals())._at_put_(aString,nil);
  472. return self;
  473. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  474. }, function($ctx1) {$ctx1.fill(self,"defineLocal:",{aString:aString},$globals.AIContext)});
  475. //>>excludeEnd("ctx");
  476. },
  477. //>>excludeStart("ide", pragmas.excludeIdeData);
  478. args: ["aString"],
  479. source: "defineLocal: aString\x0a\x09self locals at: aString put: nil",
  480. referencedClasses: [],
  481. //>>excludeEnd("ide");
  482. messageSends: ["at:put:", "locals"]
  483. }),
  484. $globals.AIContext);
  485. $core.addMethod(
  486. $core.method({
  487. selector: "evaluate:on:",
  488. protocol: "evaluating",
  489. fn: function (aString,anEvaluator){
  490. var self=this,$self=this;
  491. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  492. return $core.withContext(function($ctx1) {
  493. //>>excludeEnd("ctx");
  494. return $recv(anEvaluator)._evaluate_context_(aString,self);
  495. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  496. }, function($ctx1) {$ctx1.fill(self,"evaluate:on:",{aString:aString,anEvaluator:anEvaluator},$globals.AIContext)});
  497. //>>excludeEnd("ctx");
  498. },
  499. //>>excludeStart("ide", pragmas.excludeIdeData);
  500. args: ["aString", "anEvaluator"],
  501. source: "evaluate: aString on: anEvaluator\x0a\x09^ anEvaluator evaluate: aString context: self",
  502. referencedClasses: [],
  503. //>>excludeEnd("ide");
  504. messageSends: ["evaluate:context:"]
  505. }),
  506. $globals.AIContext);
  507. $core.addMethod(
  508. $core.method({
  509. selector: "evaluateNode:",
  510. protocol: "evaluating",
  511. fn: function (aNode){
  512. var self=this,$self=this;
  513. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  514. return $core.withContext(function($ctx1) {
  515. //>>excludeEnd("ctx");
  516. var $1;
  517. $1=$recv($globals.ASTInterpreter)._new();
  518. $recv($1)._context_(self);
  519. $recv($1)._node_(aNode);
  520. $recv($1)._enterNode();
  521. $recv($1)._proceed();
  522. return $recv($1)._result();
  523. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  524. }, function($ctx1) {$ctx1.fill(self,"evaluateNode:",{aNode:aNode},$globals.AIContext)});
  525. //>>excludeEnd("ctx");
  526. },
  527. //>>excludeStart("ide", pragmas.excludeIdeData);
  528. args: ["aNode"],
  529. source: "evaluateNode: aNode\x0a\x09^ ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09node: aNode;\x0a\x09\x09enterNode;\x0a\x09\x09proceed;\x0a\x09\x09result",
  530. referencedClasses: ["ASTInterpreter"],
  531. //>>excludeEnd("ide");
  532. messageSends: ["context:", "new", "node:", "enterNode", "proceed", "result"]
  533. }),
  534. $globals.AIContext);
  535. $core.addMethod(
  536. $core.method({
  537. selector: "evaluatedSelector",
  538. protocol: "accessing",
  539. fn: function (){
  540. var self=this,$self=this;
  541. return $self["@evaluatedSelector"];
  542. },
  543. //>>excludeStart("ide", pragmas.excludeIdeData);
  544. args: [],
  545. source: "evaluatedSelector\x0a\x09^ evaluatedSelector",
  546. referencedClasses: [],
  547. //>>excludeEnd("ide");
  548. messageSends: []
  549. }),
  550. $globals.AIContext);
  551. $core.addMethod(
  552. $core.method({
  553. selector: "evaluatedSelector:",
  554. protocol: "accessing",
  555. fn: function (aString){
  556. var self=this,$self=this;
  557. $self["@evaluatedSelector"]=aString;
  558. return self;
  559. },
  560. //>>excludeStart("ide", pragmas.excludeIdeData);
  561. args: ["aString"],
  562. source: "evaluatedSelector: aString\x0a\x09evaluatedSelector := aString",
  563. referencedClasses: [],
  564. //>>excludeEnd("ide");
  565. messageSends: []
  566. }),
  567. $globals.AIContext);
  568. $core.addMethod(
  569. $core.method({
  570. selector: "index",
  571. protocol: "accessing",
  572. fn: function (){
  573. var self=this,$self=this;
  574. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  575. return $core.withContext(function($ctx1) {
  576. //>>excludeEnd("ctx");
  577. var $1,$receiver;
  578. $1=$self["@index"];
  579. if(($receiver = $1) == null || $receiver.a$nil){
  580. return (0);
  581. } else {
  582. return $1;
  583. }
  584. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  585. }, function($ctx1) {$ctx1.fill(self,"index",{},$globals.AIContext)});
  586. //>>excludeEnd("ctx");
  587. },
  588. //>>excludeStart("ide", pragmas.excludeIdeData);
  589. args: [],
  590. source: "index\x0a\x09^ index ifNil: [ 0 ]",
  591. referencedClasses: [],
  592. //>>excludeEnd("ide");
  593. messageSends: ["ifNil:"]
  594. }),
  595. $globals.AIContext);
  596. $core.addMethod(
  597. $core.method({
  598. selector: "index:",
  599. protocol: "accessing",
  600. fn: function (anInteger){
  601. var self=this,$self=this;
  602. $self["@index"]=anInteger;
  603. return self;
  604. },
  605. //>>excludeStart("ide", pragmas.excludeIdeData);
  606. args: ["anInteger"],
  607. source: "index: anInteger\x0a\x09index := anInteger",
  608. referencedClasses: [],
  609. //>>excludeEnd("ide");
  610. messageSends: []
  611. }),
  612. $globals.AIContext);
  613. $core.addMethod(
  614. $core.method({
  615. selector: "initializeAST",
  616. protocol: "initialization",
  617. fn: function (){
  618. var self=this,$self=this;
  619. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  620. return $core.withContext(function($ctx1) {
  621. //>>excludeEnd("ctx");
  622. var $1;
  623. $1=$self._method();
  624. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  625. $ctx1.sendIdx["method"]=1;
  626. //>>excludeEnd("ctx");
  627. $self["@ast"]=$recv($1)._ast();
  628. $recv($recv($globals.SemanticAnalyzer)._on_($recv($self._method())._methodClass()))._visit_($self["@ast"]);
  629. return self;
  630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  631. }, function($ctx1) {$ctx1.fill(self,"initializeAST",{},$globals.AIContext)});
  632. //>>excludeEnd("ctx");
  633. },
  634. //>>excludeStart("ide", pragmas.excludeIdeData);
  635. args: [],
  636. source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
  637. referencedClasses: ["SemanticAnalyzer"],
  638. //>>excludeEnd("ide");
  639. messageSends: ["ast", "method", "visit:", "on:", "methodClass"]
  640. }),
  641. $globals.AIContext);
  642. $core.addMethod(
  643. $core.method({
  644. selector: "initializeFromMethodContext:",
  645. protocol: "initialization",
  646. fn: function (aMethodContext){
  647. var self=this,$self=this;
  648. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  649. return $core.withContext(function($ctx1) {
  650. //>>excludeEnd("ctx");
  651. var $1,$2,$3,$receiver;
  652. $self._evaluatedSelector_($recv(aMethodContext)._evaluatedSelector());
  653. $self._index_($recv(aMethodContext)._index());
  654. $self._sendIndexes_($recv(aMethodContext)._sendIndexes());
  655. $self._receiver_($recv(aMethodContext)._receiver());
  656. $self._supercall_($recv(aMethodContext)._supercall());
  657. $self._selector_($recv(aMethodContext)._selector());
  658. $1=$recv(aMethodContext)._outerContext();
  659. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  660. $ctx1.sendIdx["outerContext"]=1;
  661. //>>excludeEnd("ctx");
  662. if(($receiver = $1) == null || $receiver.a$nil){
  663. $1;
  664. } else {
  665. var outer;
  666. outer=$receiver;
  667. $2=$recv(outer)._methodContext();
  668. if(($receiver = $2) == null || $receiver.a$nil){
  669. $2;
  670. } else {
  671. $self._outerContext_($recv($self._class())._fromMethodContext_($recv(aMethodContext)._outerContext()));
  672. }
  673. $3=$recv(aMethodContext)._locals();
  674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  675. $ctx1.sendIdx["locals"]=1;
  676. //>>excludeEnd("ctx");
  677. $recv($3)._keysAndValuesDo_((function(key,value){
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. return $core.withContext(function($ctx2) {
  680. //>>excludeEnd("ctx");
  681. return $recv($self._locals())._at_put_(key,value);
  682. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  683. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)});
  684. //>>excludeEnd("ctx");
  685. }));
  686. }
  687. return self;
  688. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  689. }, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},$globals.AIContext)});
  690. //>>excludeEnd("ctx");
  691. },
  692. //>>excludeStart("ide", pragmas.excludeIdeData);
  693. args: ["aMethodContext"],
  694. source: "initializeFromMethodContext: aMethodContext\x0a\x0a\x09self\x0a\x09\x09evaluatedSelector: aMethodContext evaluatedSelector;\x0a\x09\x09index: aMethodContext index;\x0a\x09\x09sendIndexes: aMethodContext sendIndexes;\x0a\x09\x09receiver: aMethodContext receiver;\x0a\x09\x09supercall: aMethodContext supercall;\x0a\x09\x09selector: aMethodContext selector.\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 ] ]",
  695. referencedClasses: [],
  696. //>>excludeEnd("ide");
  697. messageSends: ["evaluatedSelector:", "evaluatedSelector", "index:", "index", "sendIndexes:", "sendIndexes", "receiver:", "receiver", "supercall:", "supercall", "selector:", "selector", "ifNotNil:", "outerContext", "methodContext", "outerContext:", "fromMethodContext:", "class", "keysAndValuesDo:", "locals", "at:put:"]
  698. }),
  699. $globals.AIContext);
  700. $core.addMethod(
  701. $core.method({
  702. selector: "initializeInterpreter",
  703. protocol: "initialization",
  704. fn: function (){
  705. var self=this,$self=this;
  706. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  707. return $core.withContext(function($ctx1) {
  708. //>>excludeEnd("ctx");
  709. var $1,$2,$receiver;
  710. $1=$recv($globals.ASTInterpreter)._new();
  711. $recv($1)._context_(self);
  712. $self["@interpreter"]=$recv($1)._yourself();
  713. $2=$self._innerContext();
  714. if(($receiver = $2) == null || $receiver.a$nil){
  715. $2;
  716. } else {
  717. $self._setupInterpreter_($self["@interpreter"]);
  718. }
  719. return self;
  720. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  721. }, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},$globals.AIContext)});
  722. //>>excludeEnd("ctx");
  723. },
  724. //>>excludeStart("ide", pragmas.excludeIdeData);
  725. args: [],
  726. source: "initializeInterpreter\x0a\x09interpreter := ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09yourself.\x0a\x09\x0a\x09self innerContext ifNotNil: [\x0a\x09\x09self setupInterpreter: interpreter ]",
  727. referencedClasses: ["ASTInterpreter"],
  728. //>>excludeEnd("ide");
  729. messageSends: ["context:", "new", "yourself", "ifNotNil:", "innerContext", "setupInterpreter:"]
  730. }),
  731. $globals.AIContext);
  732. $core.addMethod(
  733. $core.method({
  734. selector: "initializeLocals",
  735. protocol: "initialization",
  736. fn: function (){
  737. var self=this,$self=this;
  738. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  739. return $core.withContext(function($ctx1) {
  740. //>>excludeEnd("ctx");
  741. $self["@locals"]=$recv($globals.Dictionary)._new();
  742. $recv($self["@locals"])._at_put_("thisContext",self);
  743. return self;
  744. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  745. }, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},$globals.AIContext)});
  746. //>>excludeEnd("ctx");
  747. },
  748. //>>excludeStart("ide", pragmas.excludeIdeData);
  749. args: [],
  750. source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
  751. referencedClasses: ["Dictionary"],
  752. //>>excludeEnd("ide");
  753. messageSends: ["new", "at:put:"]
  754. }),
  755. $globals.AIContext);
  756. $core.addMethod(
  757. $core.method({
  758. selector: "innerContext",
  759. protocol: "accessing",
  760. fn: function (){
  761. var self=this,$self=this;
  762. return $self["@innerContext"];
  763. },
  764. //>>excludeStart("ide", pragmas.excludeIdeData);
  765. args: [],
  766. source: "innerContext\x0a\x09^ innerContext",
  767. referencedClasses: [],
  768. //>>excludeEnd("ide");
  769. messageSends: []
  770. }),
  771. $globals.AIContext);
  772. $core.addMethod(
  773. $core.method({
  774. selector: "innerContext:",
  775. protocol: "accessing",
  776. fn: function (anAIContext){
  777. var self=this,$self=this;
  778. $self["@innerContext"]=anAIContext;
  779. return self;
  780. },
  781. //>>excludeStart("ide", pragmas.excludeIdeData);
  782. args: ["anAIContext"],
  783. source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
  784. referencedClasses: [],
  785. //>>excludeEnd("ide");
  786. messageSends: []
  787. }),
  788. $globals.AIContext);
  789. $core.addMethod(
  790. $core.method({
  791. selector: "interpreter",
  792. protocol: "interpreting",
  793. fn: function (){
  794. var self=this,$self=this;
  795. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  796. return $core.withContext(function($ctx1) {
  797. //>>excludeEnd("ctx");
  798. var $1,$receiver;
  799. $1=$self["@interpreter"];
  800. if(($receiver = $1) == null || $receiver.a$nil){
  801. $self._initializeInterpreter();
  802. } else {
  803. $1;
  804. }
  805. return $self["@interpreter"];
  806. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  807. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},$globals.AIContext)});
  808. //>>excludeEnd("ctx");
  809. },
  810. //>>excludeStart("ide", pragmas.excludeIdeData);
  811. args: [],
  812. source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
  813. referencedClasses: [],
  814. //>>excludeEnd("ide");
  815. messageSends: ["ifNil:", "initializeInterpreter"]
  816. }),
  817. $globals.AIContext);
  818. $core.addMethod(
  819. $core.method({
  820. selector: "interpreter:",
  821. protocol: "interpreting",
  822. fn: function (anInterpreter){
  823. var self=this,$self=this;
  824. $self["@interpreter"]=anInterpreter;
  825. return self;
  826. },
  827. //>>excludeStart("ide", pragmas.excludeIdeData);
  828. args: ["anInterpreter"],
  829. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  830. referencedClasses: [],
  831. //>>excludeEnd("ide");
  832. messageSends: []
  833. }),
  834. $globals.AIContext);
  835. $core.addMethod(
  836. $core.method({
  837. selector: "isTopContext",
  838. protocol: "testing",
  839. fn: function (){
  840. var self=this,$self=this;
  841. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  842. return $core.withContext(function($ctx1) {
  843. //>>excludeEnd("ctx");
  844. return $recv($self._innerContext())._isNil();
  845. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  846. }, function($ctx1) {$ctx1.fill(self,"isTopContext",{},$globals.AIContext)});
  847. //>>excludeEnd("ctx");
  848. },
  849. //>>excludeStart("ide", pragmas.excludeIdeData);
  850. args: [],
  851. source: "isTopContext\x0a\x09^ self innerContext isNil",
  852. referencedClasses: [],
  853. //>>excludeEnd("ide");
  854. messageSends: ["isNil", "innerContext"]
  855. }),
  856. $globals.AIContext);
  857. $core.addMethod(
  858. $core.method({
  859. selector: "localAt:",
  860. protocol: "accessing",
  861. fn: function (aString){
  862. var self=this,$self=this;
  863. var context;
  864. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  865. return $core.withContext(function($ctx1) {
  866. //>>excludeEnd("ctx");
  867. context=$self._lookupContextForLocal_(aString);
  868. return $recv(context)._basicLocalAt_(aString);
  869. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  870. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString,context:context},$globals.AIContext)});
  871. //>>excludeEnd("ctx");
  872. },
  873. //>>excludeStart("ide", pragmas.excludeIdeData);
  874. args: ["aString"],
  875. source: "localAt: aString\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09| context |\x0a\x09\x0a\x09context := self lookupContextForLocal: aString.\x0a\x09^ context basicLocalAt: aString",
  876. referencedClasses: [],
  877. //>>excludeEnd("ide");
  878. messageSends: ["lookupContextForLocal:", "basicLocalAt:"]
  879. }),
  880. $globals.AIContext);
  881. $core.addMethod(
  882. $core.method({
  883. selector: "localAt:ifAbsent:",
  884. protocol: "accessing",
  885. fn: function (aString,aBlock){
  886. var self=this,$self=this;
  887. var context;
  888. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  889. return $core.withContext(function($ctx1) {
  890. //>>excludeEnd("ctx");
  891. var $early={};
  892. try {
  893. context=$self._lookupContextForLocal_ifNone_(aString,(function(){
  894. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  895. return $core.withContext(function($ctx2) {
  896. //>>excludeEnd("ctx");
  897. throw $early=[$recv(aBlock)._value()];
  898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  899. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  900. //>>excludeEnd("ctx");
  901. }));
  902. return $recv(context)._basicLocalAt_(aString);
  903. }
  904. catch(e) {if(e===$early)return e[0]; throw e}
  905. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  906. }, function($ctx1) {$ctx1.fill(self,"localAt:ifAbsent:",{aString:aString,aBlock:aBlock,context:context},$globals.AIContext)});
  907. //>>excludeEnd("ctx");
  908. },
  909. //>>excludeStart("ide", pragmas.excludeIdeData);
  910. args: ["aString", "aBlock"],
  911. source: "localAt: aString ifAbsent: aBlock\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09| context |\x0a\x09\x0a\x09context := self \x09\x0a\x09\x09lookupContextForLocal: aString \x0a\x09\x09ifNone: [ ^ aBlock value ].\x0a\x09\x0a\x09^ context basicLocalAt: aString",
  912. referencedClasses: [],
  913. //>>excludeEnd("ide");
  914. messageSends: ["lookupContextForLocal:ifNone:", "value", "basicLocalAt:"]
  915. }),
  916. $globals.AIContext);
  917. $core.addMethod(
  918. $core.method({
  919. selector: "localAt:put:",
  920. protocol: "accessing",
  921. fn: function (aString,anObject){
  922. var self=this,$self=this;
  923. var context;
  924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  925. return $core.withContext(function($ctx1) {
  926. //>>excludeEnd("ctx");
  927. context=$self._lookupContextForLocal_(aString);
  928. $recv(context)._basicLocalAt_put_(aString,anObject);
  929. return self;
  930. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  931. }, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject,context:context},$globals.AIContext)});
  932. //>>excludeEnd("ctx");
  933. },
  934. //>>excludeStart("ide", pragmas.excludeIdeData);
  935. args: ["aString", "anObject"],
  936. source: "localAt: aString put: anObject\x0a\x09| context |\x0a\x09\x0a\x09context := self lookupContextForLocal: aString.\x0a\x09context basicLocalAt: aString put: anObject",
  937. referencedClasses: [],
  938. //>>excludeEnd("ide");
  939. messageSends: ["lookupContextForLocal:", "basicLocalAt:put:"]
  940. }),
  941. $globals.AIContext);
  942. $core.addMethod(
  943. $core.method({
  944. selector: "locals",
  945. protocol: "accessing",
  946. fn: function (){
  947. var self=this,$self=this;
  948. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  949. return $core.withContext(function($ctx1) {
  950. //>>excludeEnd("ctx");
  951. var $1,$receiver;
  952. $1=$self["@locals"];
  953. if(($receiver = $1) == null || $receiver.a$nil){
  954. $self._initializeLocals();
  955. } else {
  956. $1;
  957. }
  958. return $self["@locals"];
  959. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  960. }, function($ctx1) {$ctx1.fill(self,"locals",{},$globals.AIContext)});
  961. //>>excludeEnd("ctx");
  962. },
  963. //>>excludeStart("ide", pragmas.excludeIdeData);
  964. args: [],
  965. source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
  966. referencedClasses: [],
  967. //>>excludeEnd("ide");
  968. messageSends: ["ifNil:", "initializeLocals"]
  969. }),
  970. $globals.AIContext);
  971. $core.addMethod(
  972. $core.method({
  973. selector: "lookupContextForLocal:",
  974. protocol: "private",
  975. fn: function (aString){
  976. var self=this,$self=this;
  977. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  978. return $core.withContext(function($ctx1) {
  979. //>>excludeEnd("ctx");
  980. return $self._lookupContextForLocal_ifNone_(aString,(function(){
  981. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  982. return $core.withContext(function($ctx2) {
  983. //>>excludeEnd("ctx");
  984. return $self._variableNotFound();
  985. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  986. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  987. //>>excludeEnd("ctx");
  988. }));
  989. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  990. }, function($ctx1) {$ctx1.fill(self,"lookupContextForLocal:",{aString:aString},$globals.AIContext)});
  991. //>>excludeEnd("ctx");
  992. },
  993. //>>excludeStart("ide", pragmas.excludeIdeData);
  994. args: ["aString"],
  995. source: "lookupContextForLocal: aString\x0a\x09\x22Lookup the context defining the local named `aString` \x0a\x09up to the method context\x22\x0a\x0a\x09^ self \x0a\x09\x09lookupContextForLocal: aString \x0a\x09\x09ifNone: [ self variableNotFound ]",
  996. referencedClasses: [],
  997. //>>excludeEnd("ide");
  998. messageSends: ["lookupContextForLocal:ifNone:", "variableNotFound"]
  999. }),
  1000. $globals.AIContext);
  1001. $core.addMethod(
  1002. $core.method({
  1003. selector: "lookupContextForLocal:ifNone:",
  1004. protocol: "private",
  1005. fn: function (aString,aBlock){
  1006. var self=this,$self=this;
  1007. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1008. return $core.withContext(function($ctx1) {
  1009. //>>excludeEnd("ctx");
  1010. var $1;
  1011. return $recv($self._locals())._at_ifPresent_ifAbsent_(aString,(function(){
  1012. return self;
  1013. }),(function(){
  1014. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1015. return $core.withContext(function($ctx2) {
  1016. //>>excludeEnd("ctx");
  1017. $1=$self._outerContext();
  1018. return $recv($1)._ifNil_ifNotNil_(aBlock,(function(context){
  1019. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1020. return $core.withContext(function($ctx3) {
  1021. //>>excludeEnd("ctx");
  1022. return $recv(context)._lookupContextForLocal_(aString);
  1023. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1024. }, function($ctx3) {$ctx3.fillBlock({context:context},$ctx2,3)});
  1025. //>>excludeEnd("ctx");
  1026. }));
  1027. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1028. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1029. //>>excludeEnd("ctx");
  1030. }));
  1031. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1032. }, function($ctx1) {$ctx1.fill(self,"lookupContextForLocal:ifNone:",{aString:aString,aBlock:aBlock},$globals.AIContext)});
  1033. //>>excludeEnd("ctx");
  1034. },
  1035. //>>excludeStart("ide", pragmas.excludeIdeData);
  1036. args: ["aString", "aBlock"],
  1037. source: "lookupContextForLocal: aString ifNone: aBlock\x0a\x09\x22Lookup the context defining the local named `aString` \x0a\x09up to the method context\x22\x0a\x0a\x09^ self locals \x0a\x09\x09at: aString\x0a\x09\x09ifPresent: [ self ]\x0a\x09\x09ifAbsent: [ \x0a\x09\x09\x09self outerContext \x0a\x09\x09\x09\x09ifNil: aBlock\x0a\x09\x09\x09\x09ifNotNil: [ :context | \x0a\x09\x09\x09\x09\x09context lookupContextForLocal: aString ] ]",
  1038. referencedClasses: [],
  1039. //>>excludeEnd("ide");
  1040. messageSends: ["at:ifPresent:ifAbsent:", "locals", "ifNil:ifNotNil:", "outerContext", "lookupContextForLocal:"]
  1041. }),
  1042. $globals.AIContext);
  1043. $core.addMethod(
  1044. $core.method({
  1045. selector: "newInnerContext",
  1046. protocol: "factory",
  1047. fn: function (){
  1048. var self=this,$self=this;
  1049. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1050. return $core.withContext(function($ctx1) {
  1051. //>>excludeEnd("ctx");
  1052. var $1;
  1053. $1=$recv($self._class())._new();
  1054. $recv($1)._outerContext_(self);
  1055. return $recv($1)._yourself();
  1056. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1057. }, function($ctx1) {$ctx1.fill(self,"newInnerContext",{},$globals.AIContext)});
  1058. //>>excludeEnd("ctx");
  1059. },
  1060. //>>excludeStart("ide", pragmas.excludeIdeData);
  1061. args: [],
  1062. source: "newInnerContext\x0a\x09^ self class new\x0a\x09\x09outerContext: self;\x0a\x09\x09yourself",
  1063. referencedClasses: [],
  1064. //>>excludeEnd("ide");
  1065. messageSends: ["outerContext:", "new", "class", "yourself"]
  1066. }),
  1067. $globals.AIContext);
  1068. $core.addMethod(
  1069. $core.method({
  1070. selector: "outerContext",
  1071. protocol: "accessing",
  1072. fn: function (){
  1073. var self=this,$self=this;
  1074. return $self["@outerContext"];
  1075. },
  1076. //>>excludeStart("ide", pragmas.excludeIdeData);
  1077. args: [],
  1078. source: "outerContext\x0a\x09^ outerContext",
  1079. referencedClasses: [],
  1080. //>>excludeEnd("ide");
  1081. messageSends: []
  1082. }),
  1083. $globals.AIContext);
  1084. $core.addMethod(
  1085. $core.method({
  1086. selector: "outerContext:",
  1087. protocol: "accessing",
  1088. fn: function (anAIContext){
  1089. var self=this,$self=this;
  1090. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1091. return $core.withContext(function($ctx1) {
  1092. //>>excludeEnd("ctx");
  1093. var $1,$receiver;
  1094. $self["@outerContext"]=anAIContext;
  1095. $1=$self["@outerContext"];
  1096. if(($receiver = $1) == null || $receiver.a$nil){
  1097. $1;
  1098. } else {
  1099. var context;
  1100. context=$receiver;
  1101. $recv(context)._innerContext_(self);
  1102. }
  1103. return self;
  1104. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1105. }, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},$globals.AIContext)});
  1106. //>>excludeEnd("ctx");
  1107. },
  1108. //>>excludeStart("ide", pragmas.excludeIdeData);
  1109. args: ["anAIContext"],
  1110. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext ifNotNil: [ :context | \x0a\x09\x09context innerContext: self ]",
  1111. referencedClasses: [],
  1112. //>>excludeEnd("ide");
  1113. messageSends: ["ifNotNil:", "innerContext:"]
  1114. }),
  1115. $globals.AIContext);
  1116. $core.addMethod(
  1117. $core.method({
  1118. selector: "receiver:",
  1119. protocol: "interpreting",
  1120. fn: function (anObject){
  1121. var self=this,$self=this;
  1122. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1123. return $core.withContext(function($ctx1) {
  1124. //>>excludeEnd("ctx");
  1125. $recv($self._locals())._at_put_("self",anObject);
  1126. return self;
  1127. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1128. }, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},$globals.AIContext)});
  1129. //>>excludeEnd("ctx");
  1130. },
  1131. //>>excludeStart("ide", pragmas.excludeIdeData);
  1132. args: ["anObject"],
  1133. source: "receiver: anObject\x0a\x09self locals at: 'self' put: anObject",
  1134. referencedClasses: [],
  1135. //>>excludeEnd("ide");
  1136. messageSends: ["at:put:", "locals"]
  1137. }),
  1138. $globals.AIContext);
  1139. $core.addMethod(
  1140. $core.method({
  1141. selector: "selector",
  1142. protocol: "accessing",
  1143. fn: function (){
  1144. var self=this,$self=this;
  1145. return $self["@selector"];
  1146. },
  1147. //>>excludeStart("ide", pragmas.excludeIdeData);
  1148. args: [],
  1149. source: "selector\x0a\x09^ selector",
  1150. referencedClasses: [],
  1151. //>>excludeEnd("ide");
  1152. messageSends: []
  1153. }),
  1154. $globals.AIContext);
  1155. $core.addMethod(
  1156. $core.method({
  1157. selector: "selector:",
  1158. protocol: "accessing",
  1159. fn: function (aString){
  1160. var self=this,$self=this;
  1161. $self["@selector"]=aString;
  1162. return self;
  1163. },
  1164. //>>excludeStart("ide", pragmas.excludeIdeData);
  1165. args: ["aString"],
  1166. source: "selector: aString\x0a\x09selector := aString",
  1167. referencedClasses: [],
  1168. //>>excludeEnd("ide");
  1169. messageSends: []
  1170. }),
  1171. $globals.AIContext);
  1172. $core.addMethod(
  1173. $core.method({
  1174. selector: "sendIndexAt:",
  1175. protocol: "accessing",
  1176. fn: function (aString){
  1177. var self=this,$self=this;
  1178. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1179. return $core.withContext(function($ctx1) {
  1180. //>>excludeEnd("ctx");
  1181. return $recv($self._sendIndexes())._at_ifAbsent_(aString,(function(){
  1182. return (0);
  1183. }));
  1184. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1185. }, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aString:aString},$globals.AIContext)});
  1186. //>>excludeEnd("ctx");
  1187. },
  1188. //>>excludeStart("ide", pragmas.excludeIdeData);
  1189. args: ["aString"],
  1190. source: "sendIndexAt: aString\x0a\x09^ self sendIndexes at: aString ifAbsent: [ 0 ]",
  1191. referencedClasses: [],
  1192. //>>excludeEnd("ide");
  1193. messageSends: ["at:ifAbsent:", "sendIndexes"]
  1194. }),
  1195. $globals.AIContext);
  1196. $core.addMethod(
  1197. $core.method({
  1198. selector: "sendIndexes",
  1199. protocol: "accessing",
  1200. fn: function (){
  1201. var self=this,$self=this;
  1202. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1203. return $core.withContext(function($ctx1) {
  1204. //>>excludeEnd("ctx");
  1205. var $1,$receiver;
  1206. $1=$self["@sendIndexes"];
  1207. if(($receiver = $1) == null || $receiver.a$nil){
  1208. return $recv($globals.Dictionary)._new();
  1209. } else {
  1210. return $1;
  1211. }
  1212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1213. }, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},$globals.AIContext)});
  1214. //>>excludeEnd("ctx");
  1215. },
  1216. //>>excludeStart("ide", pragmas.excludeIdeData);
  1217. args: [],
  1218. source: "sendIndexes\x0a\x09^ sendIndexes ifNil: [ Dictionary new ]",
  1219. referencedClasses: ["Dictionary"],
  1220. //>>excludeEnd("ide");
  1221. messageSends: ["ifNil:", "new"]
  1222. }),
  1223. $globals.AIContext);
  1224. $core.addMethod(
  1225. $core.method({
  1226. selector: "sendIndexes:",
  1227. protocol: "accessing",
  1228. fn: function (aDictionary){
  1229. var self=this,$self=this;
  1230. $self["@sendIndexes"]=aDictionary;
  1231. return self;
  1232. },
  1233. //>>excludeStart("ide", pragmas.excludeIdeData);
  1234. args: ["aDictionary"],
  1235. source: "sendIndexes: aDictionary\x0a\x09sendIndexes := aDictionary",
  1236. referencedClasses: [],
  1237. //>>excludeEnd("ide");
  1238. messageSends: []
  1239. }),
  1240. $globals.AIContext);
  1241. $core.addMethod(
  1242. $core.method({
  1243. selector: "setupInterpreter:",
  1244. protocol: "interpreting",
  1245. fn: function (anInterpreter){
  1246. var self=this,$self=this;
  1247. var currentNode;
  1248. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1249. return $core.withContext(function($ctx1) {
  1250. //>>excludeEnd("ctx");
  1251. var $1,$2,$3,$4,$7,$6,$5,$receiver;
  1252. $1=$recv($globals.ASTPCNodeVisitor)._new();
  1253. $2=$self._evaluatedSelector();
  1254. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1255. $ctx1.sendIdx["evaluatedSelector"]=1;
  1256. //>>excludeEnd("ctx");
  1257. $recv($1)._selector_($2);
  1258. $recv($1)._index_($self._sendIndexAt_($self._evaluatedSelector()));
  1259. $3=$self._ast();
  1260. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1261. $ctx1.sendIdx["ast"]=1;
  1262. //>>excludeEnd("ctx");
  1263. $recv($1)._visit_($3);
  1264. currentNode=$recv($1)._currentNode();
  1265. $4=$recv($self._ast())._sequenceNode();
  1266. if(($receiver = $4) == null || $receiver.a$nil){
  1267. $4;
  1268. } else {
  1269. var sequence;
  1270. sequence=$receiver;
  1271. $recv($recv(sequence)._temps())._do_((function(each){
  1272. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1273. return $core.withContext(function($ctx2) {
  1274. //>>excludeEnd("ctx");
  1275. return $self._defineLocal_(each);
  1276. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1277. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  1278. //>>excludeEnd("ctx");
  1279. }));
  1280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1281. $ctx1.sendIdx["do:"]=1;
  1282. //>>excludeEnd("ctx");
  1283. }
  1284. $recv(anInterpreter)._node_(currentNode);
  1285. $7=$self._innerContext();
  1286. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1287. $ctx1.sendIdx["innerContext"]=1;
  1288. //>>excludeEnd("ctx");
  1289. $6=$recv($7)._arguments();
  1290. $5=$recv($6)._reversed();
  1291. $recv($5)._do_((function(each){
  1292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1293. return $core.withContext(function($ctx2) {
  1294. //>>excludeEnd("ctx");
  1295. return $recv(anInterpreter)._push_(each);
  1296. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1297. $ctx2.sendIdx["push:"]=1;
  1298. //>>excludeEnd("ctx");
  1299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1300. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)});
  1301. //>>excludeEnd("ctx");
  1302. }));
  1303. $recv(anInterpreter)._push_($recv($self._innerContext())._receiver());
  1304. return self;
  1305. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1306. }, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter,currentNode:currentNode},$globals.AIContext)});
  1307. //>>excludeEnd("ctx");
  1308. },
  1309. //>>excludeStart("ide", pragmas.excludeIdeData);
  1310. args: ["anInterpreter"],
  1311. source: "setupInterpreter: anInterpreter\x0a\x09| currentNode |\x0a\x09\x0a\x09\x22Retrieve the current node\x22\x0a\x09currentNode := ASTPCNodeVisitor new\x0a\x09\x09\x09selector: self evaluatedSelector;\x0a\x09\x09\x09index: (self sendIndexAt: self evaluatedSelector);\x0a\x09\x09\x09visit: self ast;\x0a\x09\x09\x09currentNode.\x0a\x09\x0a\x09\x22Define locals for the context\x22\x0a\x09self ast sequenceNode ifNotNil: [ :sequence |\x0a\x09\x09sequence temps do: [ :each |\x0a\x09\x09\x09self defineLocal: each ] ].\x0a\x09\x0a\x09anInterpreter node: currentNode.\x0a\x0a\x09\x22Push the send args and receiver to the interpreter stack\x22\x09\x0a\x09self innerContext arguments reversed do: [ :each | \x0a\x09\x09anInterpreter push: each ].\x0a\x09\x09\x0a\x09anInterpreter push: (self innerContext receiver)",
  1312. referencedClasses: ["ASTPCNodeVisitor"],
  1313. //>>excludeEnd("ide");
  1314. messageSends: ["selector:", "new", "evaluatedSelector", "index:", "sendIndexAt:", "visit:", "ast", "currentNode", "ifNotNil:", "sequenceNode", "do:", "temps", "defineLocal:", "node:", "reversed", "arguments", "innerContext", "push:", "receiver"]
  1315. }),
  1316. $globals.AIContext);
  1317. $core.addMethod(
  1318. $core.method({
  1319. selector: "supercall",
  1320. protocol: "interpreting",
  1321. fn: function (){
  1322. var self=this,$self=this;
  1323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1324. return $core.withContext(function($ctx1) {
  1325. //>>excludeEnd("ctx");
  1326. var $1,$receiver;
  1327. $1=$self["@supercall"];
  1328. if(($receiver = $1) == null || $receiver.a$nil){
  1329. return false;
  1330. } else {
  1331. return $1;
  1332. }
  1333. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1334. }, function($ctx1) {$ctx1.fill(self,"supercall",{},$globals.AIContext)});
  1335. //>>excludeEnd("ctx");
  1336. },
  1337. //>>excludeStart("ide", pragmas.excludeIdeData);
  1338. args: [],
  1339. source: "supercall\x0a\x09^ supercall ifNil: [ false ]",
  1340. referencedClasses: [],
  1341. //>>excludeEnd("ide");
  1342. messageSends: ["ifNil:"]
  1343. }),
  1344. $globals.AIContext);
  1345. $core.addMethod(
  1346. $core.method({
  1347. selector: "supercall:",
  1348. protocol: "interpreting",
  1349. fn: function (aBoolean){
  1350. var self=this,$self=this;
  1351. $self["@supercall"]=aBoolean;
  1352. return self;
  1353. },
  1354. //>>excludeStart("ide", pragmas.excludeIdeData);
  1355. args: ["aBoolean"],
  1356. source: "supercall: aBoolean\x0a\x09supercall := aBoolean",
  1357. referencedClasses: [],
  1358. //>>excludeEnd("ide");
  1359. messageSends: []
  1360. }),
  1361. $globals.AIContext);
  1362. $core.addMethod(
  1363. $core.method({
  1364. selector: "variableNotFound",
  1365. protocol: "error handling",
  1366. fn: function (){
  1367. var self=this,$self=this;
  1368. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1369. return $core.withContext(function($ctx1) {
  1370. //>>excludeEnd("ctx");
  1371. $self._error_("Variable missing");
  1372. return self;
  1373. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1374. }, function($ctx1) {$ctx1.fill(self,"variableNotFound",{},$globals.AIContext)});
  1375. //>>excludeEnd("ctx");
  1376. },
  1377. //>>excludeStart("ide", pragmas.excludeIdeData);
  1378. args: [],
  1379. source: "variableNotFound\x0a\x09\x22Error thrown whenever a variable lookup fails\x22\x0a\x09\x0a\x09self error: 'Variable missing'",
  1380. referencedClasses: [],
  1381. //>>excludeEnd("ide");
  1382. messageSends: ["error:"]
  1383. }),
  1384. $globals.AIContext);
  1385. $core.addMethod(
  1386. $core.method({
  1387. selector: "fromMethodContext:",
  1388. protocol: "instance creation",
  1389. fn: function (aMethodContext){
  1390. var self=this,$self=this;
  1391. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1392. return $core.withContext(function($ctx1) {
  1393. //>>excludeEnd("ctx");
  1394. var $1;
  1395. $1=$self._new();
  1396. $recv($1)._initializeFromMethodContext_(aMethodContext);
  1397. return $recv($1)._yourself();
  1398. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1399. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},$globals.AIContext.a$cls)});
  1400. //>>excludeEnd("ctx");
  1401. },
  1402. //>>excludeStart("ide", pragmas.excludeIdeData);
  1403. args: ["aMethodContext"],
  1404. source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
  1405. referencedClasses: [],
  1406. //>>excludeEnd("ide");
  1407. messageSends: ["initializeFromMethodContext:", "new", "yourself"]
  1408. }),
  1409. $globals.AIContext.a$cls);
  1410. $core.addClass("AISemanticAnalyzer", $globals.SemanticAnalyzer, ["context"], "Compiler-Interpreter");
  1411. //>>excludeStart("ide", pragmas.excludeIdeData);
  1412. $globals.AISemanticAnalyzer.comment="I perform the same semantic analysis than `SemanticAnalyzer`, with the difference that provided an `AIContext` context, variables are bound with the context variables.";
  1413. //>>excludeEnd("ide");
  1414. $core.addMethod(
  1415. $core.method({
  1416. selector: "context",
  1417. protocol: "accessing",
  1418. fn: function (){
  1419. var self=this,$self=this;
  1420. return $self["@context"];
  1421. },
  1422. //>>excludeStart("ide", pragmas.excludeIdeData);
  1423. args: [],
  1424. source: "context\x0a\x09^ context",
  1425. referencedClasses: [],
  1426. //>>excludeEnd("ide");
  1427. messageSends: []
  1428. }),
  1429. $globals.AISemanticAnalyzer);
  1430. $core.addMethod(
  1431. $core.method({
  1432. selector: "context:",
  1433. protocol: "accessing",
  1434. fn: function (anAIContext){
  1435. var self=this,$self=this;
  1436. $self["@context"]=anAIContext;
  1437. return self;
  1438. },
  1439. //>>excludeStart("ide", pragmas.excludeIdeData);
  1440. args: ["anAIContext"],
  1441. source: "context: anAIContext\x0a\x09context := anAIContext",
  1442. referencedClasses: [],
  1443. //>>excludeEnd("ide");
  1444. messageSends: []
  1445. }),
  1446. $globals.AISemanticAnalyzer);
  1447. $core.addMethod(
  1448. $core.method({
  1449. selector: "visitVariableNode:",
  1450. protocol: "visiting",
  1451. fn: function (aNode){
  1452. var self=this,$self=this;
  1453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1454. return $core.withContext(function($ctx1) {
  1455. //>>excludeEnd("ctx");
  1456. var $1;
  1457. var $early={};
  1458. try {
  1459. $recv($self._context())._localAt_ifAbsent_($recv(aNode)._value(),(function(){
  1460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1461. return $core.withContext(function($ctx2) {
  1462. //>>excludeEnd("ctx");
  1463. $1=(
  1464. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1465. $ctx2.supercall = true,
  1466. //>>excludeEnd("ctx");
  1467. ($globals.AISemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitVariableNode_.apply($self, [aNode]));
  1468. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1469. $ctx2.supercall = false;
  1470. //>>excludeEnd("ctx");;
  1471. throw $early=[$1];
  1472. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1473. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1474. //>>excludeEnd("ctx");
  1475. }));
  1476. $recv(aNode)._binding_($recv($globals.ASTContextVar)._new());
  1477. return self;
  1478. }
  1479. catch(e) {if(e===$early)return e[0]; throw e}
  1480. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1481. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},$globals.AISemanticAnalyzer)});
  1482. //>>excludeEnd("ctx");
  1483. },
  1484. //>>excludeStart("ide", pragmas.excludeIdeData);
  1485. args: ["aNode"],
  1486. source: "visitVariableNode: aNode\x0a\x09self context \x0a\x09\x09localAt: aNode value \x0a\x09\x09ifAbsent: [ ^ super visitVariableNode: aNode ].\x0a\x0a\x09aNode binding: ASTContextVar new",
  1487. referencedClasses: ["ASTContextVar"],
  1488. //>>excludeEnd("ide");
  1489. messageSends: ["localAt:ifAbsent:", "context", "value", "visitVariableNode:", "binding:", "new"]
  1490. }),
  1491. $globals.AISemanticAnalyzer);
  1492. $core.addClass("ASTContextVar", $globals.ScopeVar, ["context"], "Compiler-Interpreter");
  1493. //>>excludeStart("ide", pragmas.excludeIdeData);
  1494. $globals.ASTContextVar.comment="I am a variable defined in a `context`.";
  1495. //>>excludeEnd("ide");
  1496. $core.addMethod(
  1497. $core.method({
  1498. selector: "context",
  1499. protocol: "accessing",
  1500. fn: function (){
  1501. var self=this,$self=this;
  1502. return $self["@context"];
  1503. },
  1504. //>>excludeStart("ide", pragmas.excludeIdeData);
  1505. args: [],
  1506. source: "context\x0a\x09^ context",
  1507. referencedClasses: [],
  1508. //>>excludeEnd("ide");
  1509. messageSends: []
  1510. }),
  1511. $globals.ASTContextVar);
  1512. $core.addMethod(
  1513. $core.method({
  1514. selector: "context:",
  1515. protocol: "accessing",
  1516. fn: function (anObject){
  1517. var self=this,$self=this;
  1518. $self["@context"]=anObject;
  1519. return self;
  1520. },
  1521. //>>excludeStart("ide", pragmas.excludeIdeData);
  1522. args: ["anObject"],
  1523. source: "context: anObject\x0a\x09context := anObject",
  1524. referencedClasses: [],
  1525. //>>excludeEnd("ide");
  1526. messageSends: []
  1527. }),
  1528. $globals.ASTContextVar);
  1529. $core.addClass("ASTDebugger", $globals.Object, ["interpreter", "context", "result"], "Compiler-Interpreter");
  1530. //>>excludeStart("ide", pragmas.excludeIdeData);
  1531. $globals.ASTDebugger.comment="I am a stepping debugger interface for Amber code.\x0aI internally use an instance of `ASTInterpreter` to actually step through node and interpret them.\x0a\x0aMy instances are created from an `AIContext` 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.";
  1532. //>>excludeEnd("ide");
  1533. $core.addMethod(
  1534. $core.method({
  1535. selector: "atEnd",
  1536. protocol: "testing",
  1537. fn: function (){
  1538. var self=this,$self=this;
  1539. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1540. return $core.withContext(function($ctx1) {
  1541. //>>excludeEnd("ctx");
  1542. var $1,$receiver;
  1543. $1=$self._context();
  1544. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1545. $ctx1.sendIdx["context"]=1;
  1546. //>>excludeEnd("ctx");
  1547. if(($receiver = $1) == null || $receiver.a$nil){
  1548. return true;
  1549. } else {
  1550. $1;
  1551. }
  1552. return $recv($recv($self._interpreter())._atEnd())._and_((function(){
  1553. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1554. return $core.withContext(function($ctx2) {
  1555. //>>excludeEnd("ctx");
  1556. return $recv($self._context())._isTopContext();
  1557. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1558. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1559. //>>excludeEnd("ctx");
  1560. }));
  1561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1562. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},$globals.ASTDebugger)});
  1563. //>>excludeEnd("ctx");
  1564. },
  1565. //>>excludeStart("ide", pragmas.excludeIdeData);
  1566. args: [],
  1567. source: "atEnd\x09\x0a\x09self context ifNil: [ ^ true ].\x0a\x09\x0a\x09^ self interpreter atEnd and: [ \x0a\x09\x09self context isTopContext ]",
  1568. referencedClasses: [],
  1569. //>>excludeEnd("ide");
  1570. messageSends: ["ifNil:", "context", "and:", "atEnd", "interpreter", "isTopContext"]
  1571. }),
  1572. $globals.ASTDebugger);
  1573. $core.addMethod(
  1574. $core.method({
  1575. selector: "context",
  1576. protocol: "accessing",
  1577. fn: function (){
  1578. var self=this,$self=this;
  1579. return $self["@context"];
  1580. },
  1581. //>>excludeStart("ide", pragmas.excludeIdeData);
  1582. args: [],
  1583. source: "context\x0a\x09^ context",
  1584. referencedClasses: [],
  1585. //>>excludeEnd("ide");
  1586. messageSends: []
  1587. }),
  1588. $globals.ASTDebugger);
  1589. $core.addMethod(
  1590. $core.method({
  1591. selector: "context:",
  1592. protocol: "accessing",
  1593. fn: function (aContext){
  1594. var self=this,$self=this;
  1595. $self["@context"]=aContext;
  1596. return self;
  1597. },
  1598. //>>excludeStart("ide", pragmas.excludeIdeData);
  1599. args: ["aContext"],
  1600. source: "context: aContext\x0a\x09context := aContext",
  1601. referencedClasses: [],
  1602. //>>excludeEnd("ide");
  1603. messageSends: []
  1604. }),
  1605. $globals.ASTDebugger);
  1606. $core.addMethod(
  1607. $core.method({
  1608. selector: "flushInnerContexts",
  1609. protocol: "actions",
  1610. fn: function (){
  1611. var self=this,$self=this;
  1612. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1613. return $core.withContext(function($ctx1) {
  1614. //>>excludeEnd("ctx");
  1615. var $1,$receiver;
  1616. $1=$self._context();
  1617. if(($receiver = $1) == null || $receiver.a$nil){
  1618. $1;
  1619. } else {
  1620. var cxt;
  1621. cxt=$receiver;
  1622. $recv(cxt)._innerContext_(nil);
  1623. }
  1624. return self;
  1625. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1626. }, function($ctx1) {$ctx1.fill(self,"flushInnerContexts",{},$globals.ASTDebugger)});
  1627. //>>excludeEnd("ctx");
  1628. },
  1629. //>>excludeStart("ide", pragmas.excludeIdeData);
  1630. args: [],
  1631. source: "flushInnerContexts\x0a\x09\x22When stepping, the inner contexts are not relevent anymore,\x0a\x09and can be flushed\x22\x0a\x09\x0a\x09self context ifNotNil: [ :cxt | \x0a\x09\x09cxt innerContext: nil ]",
  1632. referencedClasses: [],
  1633. //>>excludeEnd("ide");
  1634. messageSends: ["ifNotNil:", "context", "innerContext:"]
  1635. }),
  1636. $globals.ASTDebugger);
  1637. $core.addMethod(
  1638. $core.method({
  1639. selector: "interpreter",
  1640. protocol: "accessing",
  1641. fn: function (){
  1642. var self=this,$self=this;
  1643. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1644. return $core.withContext(function($ctx1) {
  1645. //>>excludeEnd("ctx");
  1646. var $1,$receiver;
  1647. $1=$self._context();
  1648. if(($receiver = $1) == null || $receiver.a$nil){
  1649. return $1;
  1650. } else {
  1651. var ctx;
  1652. ctx=$receiver;
  1653. return $recv(ctx)._interpreter();
  1654. }
  1655. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1656. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},$globals.ASTDebugger)});
  1657. //>>excludeEnd("ctx");
  1658. },
  1659. //>>excludeStart("ide", pragmas.excludeIdeData);
  1660. args: [],
  1661. source: "interpreter\x0a\x09^ self context ifNotNil: [ :ctx | \x0a\x09\x09ctx interpreter ]",
  1662. referencedClasses: [],
  1663. //>>excludeEnd("ide");
  1664. messageSends: ["ifNotNil:", "context", "interpreter"]
  1665. }),
  1666. $globals.ASTDebugger);
  1667. $core.addMethod(
  1668. $core.method({
  1669. selector: "method",
  1670. protocol: "accessing",
  1671. fn: function (){
  1672. var self=this,$self=this;
  1673. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1674. return $core.withContext(function($ctx1) {
  1675. //>>excludeEnd("ctx");
  1676. return $recv($self._context())._method();
  1677. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1678. }, function($ctx1) {$ctx1.fill(self,"method",{},$globals.ASTDebugger)});
  1679. //>>excludeEnd("ctx");
  1680. },
  1681. //>>excludeStart("ide", pragmas.excludeIdeData);
  1682. args: [],
  1683. source: "method\x0a\x09^ self context method",
  1684. referencedClasses: [],
  1685. //>>excludeEnd("ide");
  1686. messageSends: ["method", "context"]
  1687. }),
  1688. $globals.ASTDebugger);
  1689. $core.addMethod(
  1690. $core.method({
  1691. selector: "node",
  1692. protocol: "accessing",
  1693. fn: function (){
  1694. var self=this,$self=this;
  1695. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1696. return $core.withContext(function($ctx1) {
  1697. //>>excludeEnd("ctx");
  1698. var $1,$receiver;
  1699. $1=$self._interpreter();
  1700. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1701. $ctx1.sendIdx["interpreter"]=1;
  1702. //>>excludeEnd("ctx");
  1703. if(($receiver = $1) == null || $receiver.a$nil){
  1704. return $1;
  1705. } else {
  1706. return $recv($self._interpreter())._node();
  1707. }
  1708. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1709. }, function($ctx1) {$ctx1.fill(self,"node",{},$globals.ASTDebugger)});
  1710. //>>excludeEnd("ctx");
  1711. },
  1712. //>>excludeStart("ide", pragmas.excludeIdeData);
  1713. args: [],
  1714. source: "node\x0a\x09^ self interpreter ifNotNil: [\x0a\x09\x09self interpreter node ]",
  1715. referencedClasses: [],
  1716. //>>excludeEnd("ide");
  1717. messageSends: ["ifNotNil:", "interpreter", "node"]
  1718. }),
  1719. $globals.ASTDebugger);
  1720. $core.addMethod(
  1721. $core.method({
  1722. selector: "onStep",
  1723. protocol: "private",
  1724. fn: function (){
  1725. var self=this,$self=this;
  1726. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1727. return $core.withContext(function($ctx1) {
  1728. //>>excludeEnd("ctx");
  1729. var $1,$3,$2,$4,$6,$5,$receiver;
  1730. $1=$self._interpreter();
  1731. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1732. $ctx1.sendIdx["interpreter"]=1;
  1733. //>>excludeEnd("ctx");
  1734. $self["@result"]=$recv($1)._result();
  1735. $3=$self._interpreter();
  1736. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1737. $ctx1.sendIdx["interpreter"]=2;
  1738. //>>excludeEnd("ctx");
  1739. $2=$recv($3)._atEnd();
  1740. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1741. $ctx1.sendIdx["atEnd"]=1;
  1742. //>>excludeEnd("ctx");
  1743. if($core.assert($2)){
  1744. $4=$recv($self._context())._outerContext();
  1745. if(($receiver = $4) == null || $receiver.a$nil){
  1746. $4;
  1747. } else {
  1748. var outerContext;
  1749. outerContext=$receiver;
  1750. $self._context_(outerContext);
  1751. }
  1752. $6=$self._interpreter();
  1753. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1754. $ctx1.sendIdx["interpreter"]=3;
  1755. //>>excludeEnd("ctx");
  1756. $5=$recv($6)._atEnd();
  1757. if(!$core.assert($5)){
  1758. $recv($self._interpreter())._skip();
  1759. }
  1760. }
  1761. $self._flushInnerContexts();
  1762. return self;
  1763. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1764. }, function($ctx1) {$ctx1.fill(self,"onStep",{},$globals.ASTDebugger)});
  1765. //>>excludeEnd("ctx");
  1766. },
  1767. //>>excludeStart("ide", pragmas.excludeIdeData);
  1768. args: [],
  1769. source: "onStep\x0a\x09\x22After each step, check if the interpreter is at the end,\x0a\x09and if it is move to its outer context if any, skipping its \x0a\x09current node (which was just evaluated by the current \x0a\x09interpreter).\x0a\x09\x0a\x09After each step we also flush inner contexts.\x22\x0a\x09\x0a\x09result := self interpreter result.\x0a\x09\x0a\x09self interpreter atEnd ifTrue: [\x0a\x09\x09self context outerContext ifNotNil: [ :outerContext | \x0a\x09\x09\x09self context: outerContext ].\x0a\x09\x09self interpreter atEnd ifFalse: [ self interpreter skip ] ].\x0a\x09\x09\x0a\x09self flushInnerContexts",
  1770. referencedClasses: [],
  1771. //>>excludeEnd("ide");
  1772. messageSends: ["result", "interpreter", "ifTrue:", "atEnd", "ifNotNil:", "outerContext", "context", "context:", "ifFalse:", "skip", "flushInnerContexts"]
  1773. }),
  1774. $globals.ASTDebugger);
  1775. $core.addMethod(
  1776. $core.method({
  1777. selector: "proceed",
  1778. protocol: "stepping",
  1779. fn: function (){
  1780. var self=this,$self=this;
  1781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1782. return $core.withContext(function($ctx1) {
  1783. //>>excludeEnd("ctx");
  1784. $recv((function(){
  1785. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1786. return $core.withContext(function($ctx2) {
  1787. //>>excludeEnd("ctx");
  1788. return $self._atEnd();
  1789. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1790. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1791. //>>excludeEnd("ctx");
  1792. }))._whileFalse_((function(){
  1793. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1794. return $core.withContext(function($ctx2) {
  1795. //>>excludeEnd("ctx");
  1796. return $self._stepOver();
  1797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1798. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1799. //>>excludeEnd("ctx");
  1800. }));
  1801. return self;
  1802. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1803. }, function($ctx1) {$ctx1.fill(self,"proceed",{},$globals.ASTDebugger)});
  1804. //>>excludeEnd("ctx");
  1805. },
  1806. //>>excludeStart("ide", pragmas.excludeIdeData);
  1807. args: [],
  1808. source: "proceed\x0a\x09[ self atEnd ] whileFalse: [ self stepOver ]",
  1809. referencedClasses: [],
  1810. //>>excludeEnd("ide");
  1811. messageSends: ["whileFalse:", "atEnd", "stepOver"]
  1812. }),
  1813. $globals.ASTDebugger);
  1814. $core.addMethod(
  1815. $core.method({
  1816. selector: "restart",
  1817. protocol: "stepping",
  1818. fn: function (){
  1819. var self=this,$self=this;
  1820. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1821. return $core.withContext(function($ctx1) {
  1822. //>>excludeEnd("ctx");
  1823. $recv($self._interpreter())._restart();
  1824. $self._flushInnerContexts();
  1825. return self;
  1826. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1827. }, function($ctx1) {$ctx1.fill(self,"restart",{},$globals.ASTDebugger)});
  1828. //>>excludeEnd("ctx");
  1829. },
  1830. //>>excludeStart("ide", pragmas.excludeIdeData);
  1831. args: [],
  1832. source: "restart\x0a\x09self interpreter restart.\x0a\x09self flushInnerContexts",
  1833. referencedClasses: [],
  1834. //>>excludeEnd("ide");
  1835. messageSends: ["restart", "interpreter", "flushInnerContexts"]
  1836. }),
  1837. $globals.ASTDebugger);
  1838. $core.addMethod(
  1839. $core.method({
  1840. selector: "result",
  1841. protocol: "accessing",
  1842. fn: function (){
  1843. var self=this,$self=this;
  1844. return $self["@result"];
  1845. },
  1846. //>>excludeStart("ide", pragmas.excludeIdeData);
  1847. args: [],
  1848. source: "result\x0a\x09^ result",
  1849. referencedClasses: [],
  1850. //>>excludeEnd("ide");
  1851. messageSends: []
  1852. }),
  1853. $globals.ASTDebugger);
  1854. $core.addMethod(
  1855. $core.method({
  1856. selector: "stepInto",
  1857. protocol: "stepping",
  1858. fn: function (){
  1859. var self=this,$self=this;
  1860. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1861. return $core.withContext(function($ctx1) {
  1862. //>>excludeEnd("ctx");
  1863. $self._shouldBeImplemented();
  1864. return self;
  1865. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1866. }, function($ctx1) {$ctx1.fill(self,"stepInto",{},$globals.ASTDebugger)});
  1867. //>>excludeEnd("ctx");
  1868. },
  1869. //>>excludeStart("ide", pragmas.excludeIdeData);
  1870. args: [],
  1871. source: "stepInto\x0a\x09self shouldBeImplemented",
  1872. referencedClasses: [],
  1873. //>>excludeEnd("ide");
  1874. messageSends: ["shouldBeImplemented"]
  1875. }),
  1876. $globals.ASTDebugger);
  1877. $core.addMethod(
  1878. $core.method({
  1879. selector: "stepOver",
  1880. protocol: "stepping",
  1881. fn: function (){
  1882. var self=this,$self=this;
  1883. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1884. return $core.withContext(function($ctx1) {
  1885. //>>excludeEnd("ctx");
  1886. var $1,$2;
  1887. $1=$recv($self._context())._isTopContext();
  1888. if($core.assert($1)){
  1889. $recv($self._interpreter())._stepOver();
  1890. } else {
  1891. $2=$self._interpreter();
  1892. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1893. $ctx1.sendIdx["interpreter"]=1;
  1894. //>>excludeEnd("ctx");
  1895. $recv($2)._skip();
  1896. }
  1897. $self._onStep();
  1898. return self;
  1899. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1900. }, function($ctx1) {$ctx1.fill(self,"stepOver",{},$globals.ASTDebugger)});
  1901. //>>excludeEnd("ctx");
  1902. },
  1903. //>>excludeStart("ide", pragmas.excludeIdeData);
  1904. args: [],
  1905. source: "stepOver\x0a\x09self context isTopContext \x0a\x09\x09ifFalse: [ self interpreter skip ]\x0a\x09\x09ifTrue: [ self interpreter stepOver ].\x0a\x09self onStep",
  1906. referencedClasses: [],
  1907. //>>excludeEnd("ide");
  1908. messageSends: ["ifFalse:ifTrue:", "isTopContext", "context", "skip", "interpreter", "stepOver", "onStep"]
  1909. }),
  1910. $globals.ASTDebugger);
  1911. $core.addMethod(
  1912. $core.method({
  1913. selector: "context:",
  1914. protocol: "instance creation",
  1915. fn: function (aContext){
  1916. var self=this,$self=this;
  1917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1918. return $core.withContext(function($ctx1) {
  1919. //>>excludeEnd("ctx");
  1920. var $1;
  1921. $1=$self._new();
  1922. $recv($1)._context_(aContext);
  1923. return $recv($1)._yourself();
  1924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1925. }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},$globals.ASTDebugger.a$cls)});
  1926. //>>excludeEnd("ctx");
  1927. },
  1928. //>>excludeStart("ide", pragmas.excludeIdeData);
  1929. args: ["aContext"],
  1930. source: "context: aContext\x0a\x09^ self new\x0a\x09\x09context: aContext;\x0a\x09\x09yourself",
  1931. referencedClasses: [],
  1932. //>>excludeEnd("ide");
  1933. messageSends: ["context:", "new", "yourself"]
  1934. }),
  1935. $globals.ASTDebugger.a$cls);
  1936. $core.addClass("ASTEnterNode", $globals.NodeVisitor, ["interpreter"], "Compiler-Interpreter");
  1937. $core.addMethod(
  1938. $core.method({
  1939. selector: "interpreter",
  1940. protocol: "accessing",
  1941. fn: function (){
  1942. var self=this,$self=this;
  1943. return $self["@interpreter"];
  1944. },
  1945. //>>excludeStart("ide", pragmas.excludeIdeData);
  1946. args: [],
  1947. source: "interpreter\x0a\x09^ interpreter",
  1948. referencedClasses: [],
  1949. //>>excludeEnd("ide");
  1950. messageSends: []
  1951. }),
  1952. $globals.ASTEnterNode);
  1953. $core.addMethod(
  1954. $core.method({
  1955. selector: "interpreter:",
  1956. protocol: "accessing",
  1957. fn: function (anObject){
  1958. var self=this,$self=this;
  1959. $self["@interpreter"]=anObject;
  1960. return self;
  1961. },
  1962. //>>excludeStart("ide", pragmas.excludeIdeData);
  1963. args: ["anObject"],
  1964. source: "interpreter: anObject\x0a\x09interpreter := anObject",
  1965. referencedClasses: [],
  1966. //>>excludeEnd("ide");
  1967. messageSends: []
  1968. }),
  1969. $globals.ASTEnterNode);
  1970. $core.addMethod(
  1971. $core.method({
  1972. selector: "visitBlockNode:",
  1973. protocol: "visiting",
  1974. fn: function (aNode){
  1975. var self=this,$self=this;
  1976. return aNode;
  1977. },
  1978. //>>excludeStart("ide", pragmas.excludeIdeData);
  1979. args: ["aNode"],
  1980. source: "visitBlockNode: aNode\x0a\x09\x22Answer the node as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ aNode",
  1981. referencedClasses: [],
  1982. //>>excludeEnd("ide");
  1983. messageSends: []
  1984. }),
  1985. $globals.ASTEnterNode);
  1986. $core.addMethod(
  1987. $core.method({
  1988. selector: "visitDagNode:",
  1989. protocol: "visiting",
  1990. fn: function (aNode){
  1991. var self=this,$self=this;
  1992. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1993. return $core.withContext(function($ctx1) {
  1994. //>>excludeEnd("ctx");
  1995. var $early={};
  1996. try {
  1997. $recv($recv(aNode)._dagChildren())._ifEmpty_ifNotEmpty_((function(){
  1998. throw $early=[aNode];
  1999. }),(function(nodes){
  2000. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2001. return $core.withContext(function($ctx2) {
  2002. //>>excludeEnd("ctx");
  2003. throw $early=[$self._visit_($recv(nodes)._first())];
  2004. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2005. }, function($ctx2) {$ctx2.fillBlock({nodes:nodes},$ctx1,2)});
  2006. //>>excludeEnd("ctx");
  2007. }));
  2008. return self;
  2009. }
  2010. catch(e) {if(e===$early)return e[0]; throw e}
  2011. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2012. }, function($ctx1) {$ctx1.fill(self,"visitDagNode:",{aNode:aNode},$globals.ASTEnterNode)});
  2013. //>>excludeEnd("ctx");
  2014. },
  2015. //>>excludeStart("ide", pragmas.excludeIdeData);
  2016. args: ["aNode"],
  2017. source: "visitDagNode: aNode\x0a\x09aNode dagChildren\x0a\x09\x09ifEmpty: [ ^ aNode ]\x0a\x09\x09ifNotEmpty: [ :nodes | ^ self visit: nodes first ]",
  2018. referencedClasses: [],
  2019. //>>excludeEnd("ide");
  2020. messageSends: ["ifEmpty:ifNotEmpty:", "dagChildren", "visit:", "first"]
  2021. }),
  2022. $globals.ASTEnterNode);
  2023. $core.addMethod(
  2024. $core.method({
  2025. selector: "visitSequenceNode:",
  2026. protocol: "visiting",
  2027. fn: function (aNode){
  2028. var self=this,$self=this;
  2029. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2030. return $core.withContext(function($ctx1) {
  2031. //>>excludeEnd("ctx");
  2032. var $1;
  2033. $recv($recv(aNode)._temps())._do_((function(each){
  2034. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2035. return $core.withContext(function($ctx2) {
  2036. //>>excludeEnd("ctx");
  2037. return $recv($recv($self._interpreter())._context())._defineLocal_(each);
  2038. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2039. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2040. //>>excludeEnd("ctx");
  2041. }));
  2042. $1=(
  2043. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2044. $ctx1.supercall = true,
  2045. //>>excludeEnd("ctx");
  2046. ($globals.ASTEnterNode.superclass||$boot.nilAsClass).fn.prototype._visitSequenceNode_.apply($self, [aNode]));
  2047. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2048. $ctx1.supercall = false;
  2049. //>>excludeEnd("ctx");;
  2050. return $1;
  2051. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2052. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},$globals.ASTEnterNode)});
  2053. //>>excludeEnd("ctx");
  2054. },
  2055. //>>excludeStart("ide", pragmas.excludeIdeData);
  2056. args: ["aNode"],
  2057. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each |\x0a\x09\x09self interpreter context defineLocal: each ].\x0a\x09^ super visitSequenceNode: aNode",
  2058. referencedClasses: [],
  2059. //>>excludeEnd("ide");
  2060. messageSends: ["do:", "temps", "defineLocal:", "context", "interpreter", "visitSequenceNode:"]
  2061. }),
  2062. $globals.ASTEnterNode);
  2063. $core.addMethod(
  2064. $core.method({
  2065. selector: "on:",
  2066. protocol: "instance creation",
  2067. fn: function (anInterpreter){
  2068. var self=this,$self=this;
  2069. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2070. return $core.withContext(function($ctx1) {
  2071. //>>excludeEnd("ctx");
  2072. var $1;
  2073. $1=$self._new();
  2074. $recv($1)._interpreter_(anInterpreter);
  2075. return $recv($1)._yourself();
  2076. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2077. }, function($ctx1) {$ctx1.fill(self,"on:",{anInterpreter:anInterpreter},$globals.ASTEnterNode.a$cls)});
  2078. //>>excludeEnd("ctx");
  2079. },
  2080. //>>excludeStart("ide", pragmas.excludeIdeData);
  2081. args: ["anInterpreter"],
  2082. source: "on: anInterpreter\x0a\x09^ self new\x0a\x09\x09interpreter: anInterpreter;\x0a\x09\x09yourself",
  2083. referencedClasses: [],
  2084. //>>excludeEnd("ide");
  2085. messageSends: ["interpreter:", "new", "yourself"]
  2086. }),
  2087. $globals.ASTEnterNode.a$cls);
  2088. $core.addClass("ASTInterpreter", $globals.NodeVisitor, ["node", "context", "stack", "returnValue", "returned", "forceAtEnd"], "Compiler-Interpreter");
  2089. //>>excludeStart("ide", pragmas.excludeIdeData);
  2090. $globals.ASTInterpreter.comment="I visit an AST, interpreting (evaluating) nodes one after the other, using a small stack machine.\x0a\x0a## API\x0a\x0aWhile my instances should be used from within an `ASTDebugger`, which provides a more high level interface,\x0ayou can use methods from the `interpreting` protocol:\x0a\x0a- `#step` evaluates the current `node` only\x0a- `#stepOver` evaluates the AST from the current `node` up to the next stepping node (most likely the next send node)\x0a- `#proceed` evaluates eagerly the AST\x0a- `#restart` select the first node of the AST\x0a- `#skip` skips the current node, moving to the next one if any";
  2091. //>>excludeEnd("ide");
  2092. $core.addMethod(
  2093. $core.method({
  2094. selector: "assign:to:",
  2095. protocol: "private",
  2096. fn: function (aNode,anObject){
  2097. var self=this,$self=this;
  2098. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2099. return $core.withContext(function($ctx1) {
  2100. //>>excludeEnd("ctx");
  2101. var $1,$3,$2,$4;
  2102. $1=$recv($recv(aNode)._binding())._isInstanceVar();
  2103. if($core.assert($1)){
  2104. $3=$self._context();
  2105. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2106. $ctx1.sendIdx["context"]=1;
  2107. //>>excludeEnd("ctx");
  2108. $2=$recv($3)._receiver();
  2109. $4=$recv(aNode)._value();
  2110. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2111. $ctx1.sendIdx["value"]=1;
  2112. //>>excludeEnd("ctx");
  2113. $recv($2)._instVarAt_put_($4,anObject);
  2114. } else {
  2115. $recv($self._context())._localAt_put_($recv(aNode)._value(),anObject);
  2116. }
  2117. return self;
  2118. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2119. }, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},$globals.ASTInterpreter)});
  2120. //>>excludeEnd("ctx");
  2121. },
  2122. //>>excludeStart("ide", pragmas.excludeIdeData);
  2123. args: ["aNode", "anObject"],
  2124. 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 ]",
  2125. referencedClasses: [],
  2126. //>>excludeEnd("ide");
  2127. messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"]
  2128. }),
  2129. $globals.ASTInterpreter);
  2130. $core.addMethod(
  2131. $core.method({
  2132. selector: "atEnd",
  2133. protocol: "testing",
  2134. fn: function (){
  2135. var self=this,$self=this;
  2136. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2137. return $core.withContext(function($ctx1) {
  2138. //>>excludeEnd("ctx");
  2139. var $1;
  2140. $1=$self["@forceAtEnd"];
  2141. if($core.assert($1)){
  2142. return true;
  2143. }
  2144. return $recv($self._hasReturned())._or_((function(){
  2145. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2146. return $core.withContext(function($ctx2) {
  2147. //>>excludeEnd("ctx");
  2148. return $recv($self._node())._isNil();
  2149. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2150. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  2151. //>>excludeEnd("ctx");
  2152. }));
  2153. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2154. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},$globals.ASTInterpreter)});
  2155. //>>excludeEnd("ctx");
  2156. },
  2157. //>>excludeStart("ide", pragmas.excludeIdeData);
  2158. args: [],
  2159. source: "atEnd\x0a\x09forceAtEnd ifTrue: [ ^ true ].\x0a\x09\x0a\x09^ self hasReturned or: [ self node isNil ]",
  2160. referencedClasses: [],
  2161. //>>excludeEnd("ide");
  2162. messageSends: ["ifTrue:", "or:", "hasReturned", "isNil", "node"]
  2163. }),
  2164. $globals.ASTInterpreter);
  2165. $core.addMethod(
  2166. $core.method({
  2167. selector: "context",
  2168. protocol: "accessing",
  2169. fn: function (){
  2170. var self=this,$self=this;
  2171. return $self["@context"];
  2172. },
  2173. //>>excludeStart("ide", pragmas.excludeIdeData);
  2174. args: [],
  2175. source: "context\x0a\x09^ context",
  2176. referencedClasses: [],
  2177. //>>excludeEnd("ide");
  2178. messageSends: []
  2179. }),
  2180. $globals.ASTInterpreter);
  2181. $core.addMethod(
  2182. $core.method({
  2183. selector: "context:",
  2184. protocol: "accessing",
  2185. fn: function (aContext){
  2186. var self=this,$self=this;
  2187. $self["@context"]=aContext;
  2188. return self;
  2189. },
  2190. //>>excludeStart("ide", pragmas.excludeIdeData);
  2191. args: ["aContext"],
  2192. source: "context: aContext\x0a\x09context := aContext",
  2193. referencedClasses: [],
  2194. //>>excludeEnd("ide");
  2195. messageSends: []
  2196. }),
  2197. $globals.ASTInterpreter);
  2198. $core.addMethod(
  2199. $core.method({
  2200. selector: "enterNode",
  2201. protocol: "interpreting",
  2202. fn: function (){
  2203. var self=this,$self=this;
  2204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2205. return $core.withContext(function($ctx1) {
  2206. //>>excludeEnd("ctx");
  2207. $self._node_($recv($recv($globals.ASTEnterNode)._on_(self))._visit_($self._node()));
  2208. return self;
  2209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2210. }, function($ctx1) {$ctx1.fill(self,"enterNode",{},$globals.ASTInterpreter)});
  2211. //>>excludeEnd("ctx");
  2212. },
  2213. //>>excludeStart("ide", pragmas.excludeIdeData);
  2214. args: [],
  2215. source: "enterNode\x0a\x09self node: ((ASTEnterNode on: self) visit: self node)",
  2216. referencedClasses: ["ASTEnterNode"],
  2217. //>>excludeEnd("ide");
  2218. messageSends: ["node:", "visit:", "on:", "node"]
  2219. }),
  2220. $globals.ASTInterpreter);
  2221. $core.addMethod(
  2222. $core.method({
  2223. selector: "eval:",
  2224. protocol: "private",
  2225. fn: function (aString){
  2226. var self=this,$self=this;
  2227. var source,function_;
  2228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2229. return $core.withContext(function($ctx1) {
  2230. //>>excludeEnd("ctx");
  2231. var $3,$2,$1;
  2232. source=$recv($globals.String)._streamContents_((function(str){
  2233. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2234. return $core.withContext(function($ctx2) {
  2235. //>>excludeEnd("ctx");
  2236. $recv(str)._nextPutAll_("0,(function(");
  2237. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2238. $ctx2.sendIdx["nextPutAll:"]=1;
  2239. //>>excludeEnd("ctx");
  2240. $3=$self._context();
  2241. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2242. $ctx2.sendIdx["context"]=1;
  2243. //>>excludeEnd("ctx");
  2244. $2=$recv($3)._locals();
  2245. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2246. $ctx2.sendIdx["locals"]=1;
  2247. //>>excludeEnd("ctx");
  2248. $1=$recv($2)._keys();
  2249. $recv($1)._do_separatedBy_((function(each){
  2250. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2251. return $core.withContext(function($ctx3) {
  2252. //>>excludeEnd("ctx");
  2253. return $recv(str)._nextPutAll_(each);
  2254. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2255. $ctx3.sendIdx["nextPutAll:"]=2;
  2256. //>>excludeEnd("ctx");
  2257. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2258. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)});
  2259. //>>excludeEnd("ctx");
  2260. }),(function(){
  2261. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2262. return $core.withContext(function($ctx3) {
  2263. //>>excludeEnd("ctx");
  2264. return $recv(str)._nextPutAll_(",");
  2265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2266. $ctx3.sendIdx["nextPutAll:"]=3;
  2267. //>>excludeEnd("ctx");
  2268. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2269. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
  2270. //>>excludeEnd("ctx");
  2271. }));
  2272. $recv(str)._nextPutAll_("){ return (function() {");
  2273. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2274. $ctx2.sendIdx["nextPutAll:"]=4;
  2275. //>>excludeEnd("ctx");
  2276. $recv(str)._nextPutAll_(aString);
  2277. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2278. $ctx2.sendIdx["nextPutAll:"]=5;
  2279. //>>excludeEnd("ctx");
  2280. return $recv(str)._nextPutAll_("})()})");
  2281. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2282. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)});
  2283. //>>excludeEnd("ctx");
  2284. }));
  2285. function_=$recv($globals.Compiler)._eval_(source);
  2286. return $recv(function_)._valueWithPossibleArguments_($recv($recv($self._context())._locals())._values());
  2287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2288. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},$globals.ASTInterpreter)});
  2289. //>>excludeEnd("ctx");
  2290. },
  2291. //>>excludeStart("ide", pragmas.excludeIdeData);
  2292. args: ["aString"],
  2293. 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: '0,(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 eval: source.\x0a\x09\x0a\x09^ function valueWithPossibleArguments: self context locals values",
  2294. referencedClasses: ["String", "Compiler"],
  2295. //>>excludeEnd("ide");
  2296. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "valueWithPossibleArguments:", "values"]
  2297. }),
  2298. $globals.ASTInterpreter);
  2299. $core.addMethod(
  2300. $core.method({
  2301. selector: "hasReturned",
  2302. protocol: "testing",
  2303. fn: function (){
  2304. var self=this,$self=this;
  2305. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2306. return $core.withContext(function($ctx1) {
  2307. //>>excludeEnd("ctx");
  2308. var $1,$receiver;
  2309. $1=$self["@returned"];
  2310. if(($receiver = $1) == null || $receiver.a$nil){
  2311. return false;
  2312. } else {
  2313. return $1;
  2314. }
  2315. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2316. }, function($ctx1) {$ctx1.fill(self,"hasReturned",{},$globals.ASTInterpreter)});
  2317. //>>excludeEnd("ctx");
  2318. },
  2319. //>>excludeStart("ide", pragmas.excludeIdeData);
  2320. args: [],
  2321. source: "hasReturned\x0a\x09^ returned ifNil: [ false ]",
  2322. referencedClasses: [],
  2323. //>>excludeEnd("ide");
  2324. messageSends: ["ifNil:"]
  2325. }),
  2326. $globals.ASTInterpreter);
  2327. $core.addMethod(
  2328. $core.method({
  2329. selector: "initialize",
  2330. protocol: "initialization",
  2331. fn: function (){
  2332. var self=this,$self=this;
  2333. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2334. return $core.withContext(function($ctx1) {
  2335. //>>excludeEnd("ctx");
  2336. (
  2337. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2338. $ctx1.supercall = true,
  2339. //>>excludeEnd("ctx");
  2340. ($globals.ASTInterpreter.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  2341. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2342. $ctx1.supercall = false;
  2343. //>>excludeEnd("ctx");;
  2344. $self["@forceAtEnd"]=false;
  2345. return self;
  2346. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2347. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.ASTInterpreter)});
  2348. //>>excludeEnd("ctx");
  2349. },
  2350. //>>excludeStart("ide", pragmas.excludeIdeData);
  2351. args: [],
  2352. source: "initialize\x0a\x09super initialize.\x0a\x0a\x09forceAtEnd := false",
  2353. referencedClasses: [],
  2354. //>>excludeEnd("ide");
  2355. messageSends: ["initialize"]
  2356. }),
  2357. $globals.ASTInterpreter);
  2358. $core.addMethod(
  2359. $core.method({
  2360. selector: "interpret",
  2361. protocol: "interpreting",
  2362. fn: function (){
  2363. var self=this,$self=this;
  2364. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2365. return $core.withContext(function($ctx1) {
  2366. //>>excludeEnd("ctx");
  2367. $self._visit_($self._node());
  2368. return self;
  2369. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2370. }, function($ctx1) {$ctx1.fill(self,"interpret",{},$globals.ASTInterpreter)});
  2371. //>>excludeEnd("ctx");
  2372. },
  2373. //>>excludeStart("ide", pragmas.excludeIdeData);
  2374. args: [],
  2375. source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
  2376. referencedClasses: [],
  2377. //>>excludeEnd("ide");
  2378. messageSends: ["visit:", "node"]
  2379. }),
  2380. $globals.ASTInterpreter);
  2381. $core.addMethod(
  2382. $core.method({
  2383. selector: "messageFromSendNode:arguments:",
  2384. protocol: "private",
  2385. fn: function (aSendNode,aCollection){
  2386. var self=this,$self=this;
  2387. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2388. return $core.withContext(function($ctx1) {
  2389. //>>excludeEnd("ctx");
  2390. var $1;
  2391. $1=$recv($globals.Message)._new();
  2392. $recv($1)._selector_($recv(aSendNode)._selector());
  2393. $recv($1)._arguments_(aCollection);
  2394. return $recv($1)._yourself();
  2395. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2396. }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},$globals.ASTInterpreter)});
  2397. //>>excludeEnd("ctx");
  2398. },
  2399. //>>excludeStart("ide", pragmas.excludeIdeData);
  2400. args: ["aSendNode", "aCollection"],
  2401. source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
  2402. referencedClasses: ["Message"],
  2403. //>>excludeEnd("ide");
  2404. messageSends: ["selector:", "new", "selector", "arguments:", "yourself"]
  2405. }),
  2406. $globals.ASTInterpreter);
  2407. $core.addMethod(
  2408. $core.method({
  2409. selector: "messageNotUnderstood:receiver:",
  2410. protocol: "private",
  2411. fn: function (aMessage,anObject){
  2412. var self=this,$self=this;
  2413. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2414. return $core.withContext(function($ctx1) {
  2415. //>>excludeEnd("ctx");
  2416. var $1;
  2417. $1=$recv($globals.MessageNotUnderstood)._new();
  2418. $recv($1)._message_(aMessage);
  2419. $recv($1)._receiver_(anObject);
  2420. $recv($1)._signal();
  2421. return self;
  2422. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2423. }, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},$globals.ASTInterpreter)});
  2424. //>>excludeEnd("ctx");
  2425. },
  2426. //>>excludeStart("ide", pragmas.excludeIdeData);
  2427. args: ["aMessage", "anObject"],
  2428. source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09message: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
  2429. referencedClasses: ["MessageNotUnderstood"],
  2430. //>>excludeEnd("ide");
  2431. messageSends: ["message:", "new", "receiver:", "signal"]
  2432. }),
  2433. $globals.ASTInterpreter);
  2434. $core.addMethod(
  2435. $core.method({
  2436. selector: "next",
  2437. protocol: "interpreting",
  2438. fn: function (){
  2439. var self=this,$self=this;
  2440. var nd,nextNode;
  2441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2442. return $core.withContext(function($ctx1) {
  2443. //>>excludeEnd("ctx");
  2444. var $1,$2,$receiver;
  2445. nd=$self._node();
  2446. $1=$recv(nd)._parent();
  2447. if(($receiver = $1) == null || $receiver.a$nil){
  2448. nextNode=$1;
  2449. } else {
  2450. var parent;
  2451. parent=$receiver;
  2452. $2=$recv(parent)._nextSiblingNode_(nd);
  2453. if(($receiver = $2) == null || $receiver.a$nil){
  2454. nextNode=parent;
  2455. } else {
  2456. var sibling;
  2457. sibling=$receiver;
  2458. nextNode=$recv($recv($globals.ASTEnterNode)._on_(self))._visit_(sibling);
  2459. }
  2460. }
  2461. $self._node_(nextNode);
  2462. return self;
  2463. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2464. }, function($ctx1) {$ctx1.fill(self,"next",{nd:nd,nextNode:nextNode},$globals.ASTInterpreter)});
  2465. //>>excludeEnd("ctx");
  2466. },
  2467. //>>excludeStart("ide", pragmas.excludeIdeData);
  2468. args: [],
  2469. source: "next\x0a\x09| nd nextNode |\x0a\x09nd := self node.\x0a\x09nextNode := nd parent ifNotNil: [ :parent |\x0a\x09\x09(parent nextSiblingNode: nd)\x0a\x09\x09\x09ifNil: [ parent ]\x0a\x09\x09\x09ifNotNil: [ :sibling | (ASTEnterNode on: self) visit: sibling ] ].\x0a\x09self node: nextNode",
  2470. referencedClasses: ["ASTEnterNode"],
  2471. //>>excludeEnd("ide");
  2472. messageSends: ["node", "ifNotNil:", "parent", "ifNil:ifNotNil:", "nextSiblingNode:", "visit:", "on:", "node:"]
  2473. }),
  2474. $globals.ASTInterpreter);
  2475. $core.addMethod(
  2476. $core.method({
  2477. selector: "node",
  2478. protocol: "accessing",
  2479. fn: function (){
  2480. var self=this,$self=this;
  2481. return $self["@node"];
  2482. },
  2483. //>>excludeStart("ide", pragmas.excludeIdeData);
  2484. args: [],
  2485. source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
  2486. referencedClasses: [],
  2487. //>>excludeEnd("ide");
  2488. messageSends: []
  2489. }),
  2490. $globals.ASTInterpreter);
  2491. $core.addMethod(
  2492. $core.method({
  2493. selector: "node:",
  2494. protocol: "accessing",
  2495. fn: function (aNode){
  2496. var self=this,$self=this;
  2497. $self["@node"]=aNode;
  2498. return self;
  2499. },
  2500. //>>excludeStart("ide", pragmas.excludeIdeData);
  2501. args: ["aNode"],
  2502. source: "node: aNode\x0a\x09node := aNode",
  2503. referencedClasses: [],
  2504. //>>excludeEnd("ide");
  2505. messageSends: []
  2506. }),
  2507. $globals.ASTInterpreter);
  2508. $core.addMethod(
  2509. $core.method({
  2510. selector: "peek",
  2511. protocol: "stack",
  2512. fn: function (){
  2513. var self=this,$self=this;
  2514. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2515. return $core.withContext(function($ctx1) {
  2516. //>>excludeEnd("ctx");
  2517. var $1;
  2518. var $early={};
  2519. try {
  2520. $1=$self._stack();
  2521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2522. $ctx1.sendIdx["stack"]=1;
  2523. //>>excludeEnd("ctx");
  2524. $recv($1)._ifEmpty_((function(){
  2525. throw $early=[nil];
  2526. }));
  2527. return $recv($self._stack())._last();
  2528. }
  2529. catch(e) {if(e===$early)return e[0]; throw e}
  2530. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2531. }, function($ctx1) {$ctx1.fill(self,"peek",{},$globals.ASTInterpreter)});
  2532. //>>excludeEnd("ctx");
  2533. },
  2534. //>>excludeStart("ide", pragmas.excludeIdeData);
  2535. args: [],
  2536. 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",
  2537. referencedClasses: [],
  2538. //>>excludeEnd("ide");
  2539. messageSends: ["ifEmpty:", "stack", "last"]
  2540. }),
  2541. $globals.ASTInterpreter);
  2542. $core.addMethod(
  2543. $core.method({
  2544. selector: "pop",
  2545. protocol: "stack",
  2546. fn: function (){
  2547. var self=this,$self=this;
  2548. var peekedValue;
  2549. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2550. return $core.withContext(function($ctx1) {
  2551. //>>excludeEnd("ctx");
  2552. peekedValue=$self._peek();
  2553. $recv($self._stack())._removeLast();
  2554. return peekedValue;
  2555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2556. }, function($ctx1) {$ctx1.fill(self,"pop",{peekedValue:peekedValue},$globals.ASTInterpreter)});
  2557. //>>excludeEnd("ctx");
  2558. },
  2559. //>>excludeStart("ide", pragmas.excludeIdeData);
  2560. args: [],
  2561. 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",
  2562. referencedClasses: [],
  2563. //>>excludeEnd("ide");
  2564. messageSends: ["peek", "removeLast", "stack"]
  2565. }),
  2566. $globals.ASTInterpreter);
  2567. $core.addMethod(
  2568. $core.method({
  2569. selector: "proceed",
  2570. protocol: "interpreting",
  2571. fn: function (){
  2572. var self=this,$self=this;
  2573. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2574. return $core.withContext(function($ctx1) {
  2575. //>>excludeEnd("ctx");
  2576. $recv((function(){
  2577. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2578. return $core.withContext(function($ctx2) {
  2579. //>>excludeEnd("ctx");
  2580. return $self._atEnd();
  2581. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2582. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2583. //>>excludeEnd("ctx");
  2584. }))._whileFalse_((function(){
  2585. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2586. return $core.withContext(function($ctx2) {
  2587. //>>excludeEnd("ctx");
  2588. return $self._step();
  2589. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2590. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  2591. //>>excludeEnd("ctx");
  2592. }));
  2593. return self;
  2594. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2595. }, function($ctx1) {$ctx1.fill(self,"proceed",{},$globals.ASTInterpreter)});
  2596. //>>excludeEnd("ctx");
  2597. },
  2598. //>>excludeStart("ide", pragmas.excludeIdeData);
  2599. args: [],
  2600. source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] \x0a\x09\x09whileFalse: [ self step ]",
  2601. referencedClasses: [],
  2602. //>>excludeEnd("ide");
  2603. messageSends: ["whileFalse:", "atEnd", "step"]
  2604. }),
  2605. $globals.ASTInterpreter);
  2606. $core.addMethod(
  2607. $core.method({
  2608. selector: "push:",
  2609. protocol: "stack",
  2610. fn: function (anObject){
  2611. var self=this,$self=this;
  2612. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2613. return $core.withContext(function($ctx1) {
  2614. //>>excludeEnd("ctx");
  2615. return $recv($self._stack())._add_(anObject);
  2616. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2617. }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},$globals.ASTInterpreter)});
  2618. //>>excludeEnd("ctx");
  2619. },
  2620. //>>excludeStart("ide", pragmas.excludeIdeData);
  2621. args: ["anObject"],
  2622. source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
  2623. referencedClasses: [],
  2624. //>>excludeEnd("ide");
  2625. messageSends: ["add:", "stack"]
  2626. }),
  2627. $globals.ASTInterpreter);
  2628. $core.addMethod(
  2629. $core.method({
  2630. selector: "restart",
  2631. protocol: "interpreting",
  2632. fn: function (){
  2633. var self=this,$self=this;
  2634. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2635. return $core.withContext(function($ctx1) {
  2636. //>>excludeEnd("ctx");
  2637. $self._node_($recv($self._context())._ast());
  2638. $self._enterNode();
  2639. return self;
  2640. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2641. }, function($ctx1) {$ctx1.fill(self,"restart",{},$globals.ASTInterpreter)});
  2642. //>>excludeEnd("ctx");
  2643. },
  2644. //>>excludeStart("ide", pragmas.excludeIdeData);
  2645. args: [],
  2646. source: "restart\x0a\x09self node: self context ast; enterNode",
  2647. referencedClasses: [],
  2648. //>>excludeEnd("ide");
  2649. messageSends: ["node:", "ast", "context", "enterNode"]
  2650. }),
  2651. $globals.ASTInterpreter);
  2652. $core.addMethod(
  2653. $core.method({
  2654. selector: "result",
  2655. protocol: "accessing",
  2656. fn: function (){
  2657. var self=this,$self=this;
  2658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2659. return $core.withContext(function($ctx1) {
  2660. //>>excludeEnd("ctx");
  2661. var $1;
  2662. $1=$self._hasReturned();
  2663. if($core.assert($1)){
  2664. return $self._returnValue();
  2665. } else {
  2666. return $recv($self._context())._receiver();
  2667. }
  2668. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2669. }, function($ctx1) {$ctx1.fill(self,"result",{},$globals.ASTInterpreter)});
  2670. //>>excludeEnd("ctx");
  2671. },
  2672. //>>excludeStart("ide", pragmas.excludeIdeData);
  2673. args: [],
  2674. source: "result\x0a\x09^ self hasReturned \x0a\x09\x09ifTrue: [ self returnValue ] \x0a\x09\x09ifFalse: [ self context receiver ]",
  2675. referencedClasses: [],
  2676. //>>excludeEnd("ide");
  2677. messageSends: ["ifTrue:ifFalse:", "hasReturned", "returnValue", "receiver", "context"]
  2678. }),
  2679. $globals.ASTInterpreter);
  2680. $core.addMethod(
  2681. $core.method({
  2682. selector: "returnValue",
  2683. protocol: "accessing",
  2684. fn: function (){
  2685. var self=this,$self=this;
  2686. return $self["@returnValue"];
  2687. },
  2688. //>>excludeStart("ide", pragmas.excludeIdeData);
  2689. args: [],
  2690. source: "returnValue\x0a\x09^ returnValue",
  2691. referencedClasses: [],
  2692. //>>excludeEnd("ide");
  2693. messageSends: []
  2694. }),
  2695. $globals.ASTInterpreter);
  2696. $core.addMethod(
  2697. $core.method({
  2698. selector: "returnValue:",
  2699. protocol: "accessing",
  2700. fn: function (anObject){
  2701. var self=this,$self=this;
  2702. $self["@returnValue"]=anObject;
  2703. return self;
  2704. },
  2705. //>>excludeStart("ide", pragmas.excludeIdeData);
  2706. args: ["anObject"],
  2707. source: "returnValue: anObject\x0a\x09returnValue := anObject",
  2708. referencedClasses: [],
  2709. //>>excludeEnd("ide");
  2710. messageSends: []
  2711. }),
  2712. $globals.ASTInterpreter);
  2713. $core.addMethod(
  2714. $core.method({
  2715. selector: "sendMessage:to:superSend:",
  2716. protocol: "private",
  2717. fn: function (aMessage,anObject,aBoolean){
  2718. var self=this,$self=this;
  2719. var method;
  2720. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2721. return $core.withContext(function($ctx1) {
  2722. //>>excludeEnd("ctx");
  2723. var $2,$1,$3,$receiver;
  2724. var $early={};
  2725. try {
  2726. if(!$core.assert(aBoolean)){
  2727. return $recv(aMessage)._sendTo_(anObject);
  2728. }
  2729. $2=$recv(anObject)._class();
  2730. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2731. $ctx1.sendIdx["class"]=1;
  2732. //>>excludeEnd("ctx");
  2733. $1=$recv($2)._superclass();
  2734. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2735. $ctx1.sendIdx["superclass"]=1;
  2736. //>>excludeEnd("ctx");
  2737. if(($receiver = $1) == null || $receiver.a$nil){
  2738. $3=$self._messageNotUnderstood_receiver_(aMessage,anObject);
  2739. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2740. $ctx1.sendIdx["messageNotUnderstood:receiver:"]=1;
  2741. //>>excludeEnd("ctx");
  2742. return $3;
  2743. } else {
  2744. $1;
  2745. }
  2746. method=$recv($recv($recv($recv(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_($recv(aMessage)._selector(),(function(){
  2747. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2748. return $core.withContext(function($ctx2) {
  2749. //>>excludeEnd("ctx");
  2750. throw $early=[$self._messageNotUnderstood_receiver_(aMessage,anObject)];
  2751. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2752. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  2753. //>>excludeEnd("ctx");
  2754. }));
  2755. return $recv(method)._sendTo_arguments_(anObject,$recv(aMessage)._arguments());
  2756. }
  2757. catch(e) {if(e===$early)return e[0]; throw e}
  2758. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2759. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},$globals.ASTInterpreter)});
  2760. //>>excludeEnd("ctx");
  2761. },
  2762. //>>excludeStart("ide", pragmas.excludeIdeData);
  2763. args: ["aMessage", "anObject", "aBoolean"],
  2764. 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",
  2765. referencedClasses: [],
  2766. //>>excludeEnd("ide");
  2767. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "sendTo:arguments:", "arguments"]
  2768. }),
  2769. $globals.ASTInterpreter);
  2770. $core.addMethod(
  2771. $core.method({
  2772. selector: "setNonLocalReturnFromContext:",
  2773. protocol: "interpreting",
  2774. fn: function (aContext){
  2775. var self=this,$self=this;
  2776. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2777. return $core.withContext(function($ctx1) {
  2778. //>>excludeEnd("ctx");
  2779. var $2,$1;
  2780. $2=$recv(aContext)._interpreter();
  2781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2782. $ctx1.sendIdx["interpreter"]=1;
  2783. //>>excludeEnd("ctx");
  2784. $1=$recv($2)._hasReturned();
  2785. if($core.assert($1)){
  2786. $self["@returned"]=true;
  2787. $self["@returned"];
  2788. $self._returnValue_($recv($recv(aContext)._interpreter())._returnValue());
  2789. }
  2790. return self;
  2791. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2792. }, function($ctx1) {$ctx1.fill(self,"setNonLocalReturnFromContext:",{aContext:aContext},$globals.ASTInterpreter)});
  2793. //>>excludeEnd("ctx");
  2794. },
  2795. //>>excludeStart("ide", pragmas.excludeIdeData);
  2796. args: ["aContext"],
  2797. source: "setNonLocalReturnFromContext: aContext\x0a\x09aContext interpreter hasReturned ifTrue: [\x0a\x09\x09returned := true.\x0a\x09\x09self returnValue: aContext interpreter returnValue ]",
  2798. referencedClasses: [],
  2799. //>>excludeEnd("ide");
  2800. messageSends: ["ifTrue:", "hasReturned", "interpreter", "returnValue:", "returnValue"]
  2801. }),
  2802. $globals.ASTInterpreter);
  2803. $core.addMethod(
  2804. $core.method({
  2805. selector: "skip",
  2806. protocol: "interpreting",
  2807. fn: function (){
  2808. var self=this,$self=this;
  2809. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2810. return $core.withContext(function($ctx1) {
  2811. //>>excludeEnd("ctx");
  2812. $self._next();
  2813. return self;
  2814. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2815. }, function($ctx1) {$ctx1.fill(self,"skip",{},$globals.ASTInterpreter)});
  2816. //>>excludeEnd("ctx");
  2817. },
  2818. //>>excludeStart("ide", pragmas.excludeIdeData);
  2819. args: [],
  2820. source: "skip\x0a\x09self next",
  2821. referencedClasses: [],
  2822. //>>excludeEnd("ide");
  2823. messageSends: ["next"]
  2824. }),
  2825. $globals.ASTInterpreter);
  2826. $core.addMethod(
  2827. $core.method({
  2828. selector: "stack",
  2829. protocol: "accessing",
  2830. fn: function (){
  2831. var self=this,$self=this;
  2832. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2833. return $core.withContext(function($ctx1) {
  2834. //>>excludeEnd("ctx");
  2835. var $1,$receiver;
  2836. $1=$self["@stack"];
  2837. if(($receiver = $1) == null || $receiver.a$nil){
  2838. $self["@stack"]=$recv($globals.OrderedCollection)._new();
  2839. return $self["@stack"];
  2840. } else {
  2841. return $1;
  2842. }
  2843. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2844. }, function($ctx1) {$ctx1.fill(self,"stack",{},$globals.ASTInterpreter)});
  2845. //>>excludeEnd("ctx");
  2846. },
  2847. //>>excludeStart("ide", pragmas.excludeIdeData);
  2848. args: [],
  2849. source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
  2850. referencedClasses: ["OrderedCollection"],
  2851. //>>excludeEnd("ide");
  2852. messageSends: ["ifNil:", "new"]
  2853. }),
  2854. $globals.ASTInterpreter);
  2855. $core.addMethod(
  2856. $core.method({
  2857. selector: "step",
  2858. protocol: "interpreting",
  2859. fn: function (){
  2860. var self=this,$self=this;
  2861. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2862. return $core.withContext(function($ctx1) {
  2863. //>>excludeEnd("ctx");
  2864. $self._interpret();
  2865. $self._next();
  2866. return self;
  2867. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2868. }, function($ctx1) {$ctx1.fill(self,"step",{},$globals.ASTInterpreter)});
  2869. //>>excludeEnd("ctx");
  2870. },
  2871. //>>excludeStart("ide", pragmas.excludeIdeData);
  2872. args: [],
  2873. source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
  2874. referencedClasses: [],
  2875. //>>excludeEnd("ide");
  2876. messageSends: ["interpret", "next"]
  2877. }),
  2878. $globals.ASTInterpreter);
  2879. $core.addMethod(
  2880. $core.method({
  2881. selector: "stepOver",
  2882. protocol: "interpreting",
  2883. fn: function (){
  2884. var self=this,$self=this;
  2885. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2886. return $core.withContext(function($ctx1) {
  2887. //>>excludeEnd("ctx");
  2888. var $2,$1;
  2889. $self._step();
  2890. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2891. $ctx1.sendIdx["step"]=1;
  2892. //>>excludeEnd("ctx");
  2893. $recv((function(){
  2894. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2895. return $core.withContext(function($ctx2) {
  2896. //>>excludeEnd("ctx");
  2897. $2=$self._node();
  2898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2899. $ctx2.sendIdx["node"]=1;
  2900. //>>excludeEnd("ctx");
  2901. $1=$recv($2)._isNil();
  2902. return $recv($1)._or_((function(){
  2903. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2904. return $core.withContext(function($ctx3) {
  2905. //>>excludeEnd("ctx");
  2906. return $recv($self._node())._isSteppingNode();
  2907. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2908. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  2909. //>>excludeEnd("ctx");
  2910. }));
  2911. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2912. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2913. //>>excludeEnd("ctx");
  2914. }))._whileFalse_((function(){
  2915. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2916. return $core.withContext(function($ctx2) {
  2917. //>>excludeEnd("ctx");
  2918. return $self._step();
  2919. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2920. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  2921. //>>excludeEnd("ctx");
  2922. }));
  2923. return self;
  2924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2925. }, function($ctx1) {$ctx1.fill(self,"stepOver",{},$globals.ASTInterpreter)});
  2926. //>>excludeEnd("ctx");
  2927. },
  2928. //>>excludeStart("ide", pragmas.excludeIdeData);
  2929. args: [],
  2930. source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isNil or: [ self node isSteppingNode ] ] whileFalse: [ \x0a\x09\x09self step ]",
  2931. referencedClasses: [],
  2932. //>>excludeEnd("ide");
  2933. messageSends: ["step", "whileFalse:", "or:", "isNil", "node", "isSteppingNode"]
  2934. }),
  2935. $globals.ASTInterpreter);
  2936. $core.addMethod(
  2937. $core.method({
  2938. selector: "visit:",
  2939. protocol: "visiting",
  2940. fn: function (aNode){
  2941. var self=this,$self=this;
  2942. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2943. return $core.withContext(function($ctx1) {
  2944. //>>excludeEnd("ctx");
  2945. var $1;
  2946. $1=$self._hasReturned();
  2947. if(!$core.assert($1)){
  2948. (
  2949. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2950. $ctx1.supercall = true,
  2951. //>>excludeEnd("ctx");
  2952. ($globals.ASTInterpreter.superclass||$boot.nilAsClass).fn.prototype._visit_.apply($self, [aNode]));
  2953. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2954. $ctx1.supercall = false;
  2955. //>>excludeEnd("ctx");;
  2956. }
  2957. return self;
  2958. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2959. }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},$globals.ASTInterpreter)});
  2960. //>>excludeEnd("ctx");
  2961. },
  2962. //>>excludeStart("ide", pragmas.excludeIdeData);
  2963. args: ["aNode"],
  2964. source: "visit: aNode\x0a\x09self hasReturned ifFalse: [ super visit: aNode ]",
  2965. referencedClasses: [],
  2966. //>>excludeEnd("ide");
  2967. messageSends: ["ifFalse:", "hasReturned", "visit:"]
  2968. }),
  2969. $globals.ASTInterpreter);
  2970. $core.addMethod(
  2971. $core.method({
  2972. selector: "visitAssignmentNode:",
  2973. protocol: "visiting",
  2974. fn: function (aNode){
  2975. var self=this,$self=this;
  2976. var poppedValue;
  2977. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2978. return $core.withContext(function($ctx1) {
  2979. //>>excludeEnd("ctx");
  2980. poppedValue=$self._pop();
  2981. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2982. $ctx1.sendIdx["pop"]=1;
  2983. //>>excludeEnd("ctx");
  2984. $self._pop();
  2985. $self._push_(poppedValue);
  2986. $self._assign_to_($recv(aNode)._left(),poppedValue);
  2987. return self;
  2988. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2989. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,poppedValue:poppedValue},$globals.ASTInterpreter)});
  2990. //>>excludeEnd("ctx");
  2991. },
  2992. //>>excludeStart("ide", pragmas.excludeIdeData);
  2993. args: ["aNode"],
  2994. 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",
  2995. referencedClasses: [],
  2996. //>>excludeEnd("ide");
  2997. messageSends: ["pop", "push:", "assign:to:", "left"]
  2998. }),
  2999. $globals.ASTInterpreter);
  3000. $core.addMethod(
  3001. $core.method({
  3002. selector: "visitBlockNode:",
  3003. protocol: "visiting",
  3004. fn: function (aNode){
  3005. var self=this,$self=this;
  3006. var block;
  3007. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3008. return $core.withContext(function($ctx1) {
  3009. //>>excludeEnd("ctx");
  3010. block=$recv($globals.AIBlockClosure)._forContext_node_($self._context(),aNode);
  3011. $self._push_(block);
  3012. return self;
  3013. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3014. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,block:block},$globals.ASTInterpreter)});
  3015. //>>excludeEnd("ctx");
  3016. },
  3017. //>>excludeStart("ide", pragmas.excludeIdeData);
  3018. args: ["aNode"],
  3019. 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",
  3020. referencedClasses: ["AIBlockClosure"],
  3021. //>>excludeEnd("ide");
  3022. messageSends: ["forContext:node:", "context", "push:"]
  3023. }),
  3024. $globals.ASTInterpreter);
  3025. $core.addMethod(
  3026. $core.method({
  3027. selector: "visitBlockSequenceNode:",
  3028. protocol: "visiting",
  3029. fn: function (aNode){
  3030. var self=this,$self=this;
  3031. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3032. return $core.withContext(function($ctx1) {
  3033. //>>excludeEnd("ctx");
  3034. (
  3035. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3036. $ctx1.supercall = true,
  3037. //>>excludeEnd("ctx");
  3038. ($globals.ASTInterpreter.superclass||$boot.nilAsClass).fn.prototype._visitBlockSequenceNode_.apply($self, [aNode]));
  3039. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3040. $ctx1.supercall = false;
  3041. //>>excludeEnd("ctx");;
  3042. $self["@forceAtEnd"]=true;
  3043. return self;
  3044. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3045. }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},$globals.ASTInterpreter)});
  3046. //>>excludeEnd("ctx");
  3047. },
  3048. //>>excludeStart("ide", pragmas.excludeIdeData);
  3049. args: ["aNode"],
  3050. source: "visitBlockSequenceNode: aNode\x0a\x09\x22If the receiver is actually visiting a BlockSequenceNode,\x0a\x09it means the the context is a block context. Evaluation should \x0a\x09stop right after evaluating the block sequence and the outer\x0a\x09context's interpreter should take over. \x0a\x09Therefore we force #atEnd.\x22\x0a\x09\x0a\x09super visitBlockSequenceNode: aNode.\x0a\x09forceAtEnd := true",
  3051. referencedClasses: [],
  3052. //>>excludeEnd("ide");
  3053. messageSends: ["visitBlockSequenceNode:"]
  3054. }),
  3055. $globals.ASTInterpreter);
  3056. $core.addMethod(
  3057. $core.method({
  3058. selector: "visitDagNode:",
  3059. protocol: "visiting",
  3060. fn: function (aNode){
  3061. var self=this,$self=this;
  3062. return self;
  3063. },
  3064. //>>excludeStart("ide", pragmas.excludeIdeData);
  3065. args: ["aNode"],
  3066. source: "visitDagNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
  3067. referencedClasses: [],
  3068. //>>excludeEnd("ide");
  3069. messageSends: []
  3070. }),
  3071. $globals.ASTInterpreter);
  3072. $core.addMethod(
  3073. $core.method({
  3074. selector: "visitDynamicArrayNode:",
  3075. protocol: "visiting",
  3076. fn: function (aNode){
  3077. var self=this,$self=this;
  3078. var array;
  3079. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3080. return $core.withContext(function($ctx1) {
  3081. //>>excludeEnd("ctx");
  3082. array=[];
  3083. $recv($recv(aNode)._dagChildren())._do_((function(each){
  3084. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3085. return $core.withContext(function($ctx2) {
  3086. //>>excludeEnd("ctx");
  3087. return $recv(array)._addFirst_($self._pop());
  3088. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3089. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  3090. //>>excludeEnd("ctx");
  3091. }));
  3092. $self._push_(array);
  3093. return self;
  3094. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3095. }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},$globals.ASTInterpreter)});
  3096. //>>excludeEnd("ctx");
  3097. },
  3098. //>>excludeStart("ide", pragmas.excludeIdeData);
  3099. args: ["aNode"],
  3100. source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09\x0a\x09array := #().\x0a\x09aNode dagChildren do: [ :each |\x0a\x09\x09array addFirst: self pop ].\x0a\x09\x0a\x09self push: array",
  3101. referencedClasses: [],
  3102. //>>excludeEnd("ide");
  3103. messageSends: ["do:", "dagChildren", "addFirst:", "pop", "push:"]
  3104. }),
  3105. $globals.ASTInterpreter);
  3106. $core.addMethod(
  3107. $core.method({
  3108. selector: "visitDynamicDictionaryNode:",
  3109. protocol: "visiting",
  3110. fn: function (aNode){
  3111. var self=this,$self=this;
  3112. var keyValueList;
  3113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3114. return $core.withContext(function($ctx1) {
  3115. //>>excludeEnd("ctx");
  3116. keyValueList=$recv($globals.OrderedCollection)._new();
  3117. $recv($recv(aNode)._dagChildren())._do_((function(each){
  3118. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3119. return $core.withContext(function($ctx2) {
  3120. //>>excludeEnd("ctx");
  3121. return $recv(keyValueList)._add_($self._pop());
  3122. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3123. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  3124. //>>excludeEnd("ctx");
  3125. }));
  3126. $self._push_($recv($globals.HashedCollection)._newFromPairs_($recv(keyValueList)._reversed()));
  3127. return self;
  3128. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3129. }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,keyValueList:keyValueList},$globals.ASTInterpreter)});
  3130. //>>excludeEnd("ctx");
  3131. },
  3132. //>>excludeStart("ide", pragmas.excludeIdeData);
  3133. args: ["aNode"],
  3134. source: "visitDynamicDictionaryNode: aNode\x0a\x09| keyValueList |\x0a\x09\x0a\x09keyValueList := OrderedCollection new.\x0a\x09\x0a\x09aNode dagChildren do: [ :each | \x0a\x09\x09keyValueList add: self pop ].\x0a\x09\x0a\x09self push: (HashedCollection newFromPairs: keyValueList reversed)",
  3135. referencedClasses: ["OrderedCollection", "HashedCollection"],
  3136. //>>excludeEnd("ide");
  3137. messageSends: ["new", "do:", "dagChildren", "add:", "pop", "push:", "newFromPairs:", "reversed"]
  3138. }),
  3139. $globals.ASTInterpreter);
  3140. $core.addMethod(
  3141. $core.method({
  3142. selector: "visitJSStatementNode:",
  3143. protocol: "visiting",
  3144. fn: function (aNode){
  3145. var self=this,$self=this;
  3146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3147. return $core.withContext(function($ctx1) {
  3148. //>>excludeEnd("ctx");
  3149. $self["@returned"]=true;
  3150. $self._returnValue_($self._eval_($recv(aNode)._source()));
  3151. return self;
  3152. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3153. }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},$globals.ASTInterpreter)});
  3154. //>>excludeEnd("ctx");
  3155. },
  3156. //>>excludeStart("ide", pragmas.excludeIdeData);
  3157. args: ["aNode"],
  3158. source: "visitJSStatementNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: (self eval: aNode source)",
  3159. referencedClasses: [],
  3160. //>>excludeEnd("ide");
  3161. messageSends: ["returnValue:", "eval:", "source"]
  3162. }),
  3163. $globals.ASTInterpreter);
  3164. $core.addMethod(
  3165. $core.method({
  3166. selector: "visitReturnNode:",
  3167. protocol: "visiting",
  3168. fn: function (aNode){
  3169. var self=this,$self=this;
  3170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3171. return $core.withContext(function($ctx1) {
  3172. //>>excludeEnd("ctx");
  3173. $self["@returned"]=true;
  3174. $self._returnValue_($self._pop());
  3175. return self;
  3176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3177. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},$globals.ASTInterpreter)});
  3178. //>>excludeEnd("ctx");
  3179. },
  3180. //>>excludeStart("ide", pragmas.excludeIdeData);
  3181. args: ["aNode"],
  3182. source: "visitReturnNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: self pop",
  3183. referencedClasses: [],
  3184. //>>excludeEnd("ide");
  3185. messageSends: ["returnValue:", "pop"]
  3186. }),
  3187. $globals.ASTInterpreter);
  3188. $core.addMethod(
  3189. $core.method({
  3190. selector: "visitSendNode:",
  3191. protocol: "visiting",
  3192. fn: function (aNode){
  3193. var self=this,$self=this;
  3194. var receiver,args,message,result;
  3195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3196. return $core.withContext(function($ctx1) {
  3197. //>>excludeEnd("ctx");
  3198. var $1;
  3199. args=$recv($recv(aNode)._arguments())._collect_((function(each){
  3200. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3201. return $core.withContext(function($ctx2) {
  3202. //>>excludeEnd("ctx");
  3203. return $self._pop();
  3204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3205. $ctx2.sendIdx["pop"]=1;
  3206. //>>excludeEnd("ctx");
  3207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3208. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  3209. //>>excludeEnd("ctx");
  3210. }));
  3211. receiver=$self._peek();
  3212. message=$self._messageFromSendNode_arguments_(aNode,$recv(args)._reversed());
  3213. result=$self._sendMessage_to_superSend_(message,receiver,$recv(aNode)._superSend());
  3214. $1=$recv($recv(aNode)._isCascadeSendNode())._and_((function(){
  3215. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3216. return $core.withContext(function($ctx2) {
  3217. //>>excludeEnd("ctx");
  3218. return $recv($recv(aNode)._isLastChild())._not();
  3219. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3220. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  3221. //>>excludeEnd("ctx");
  3222. }));
  3223. if(!$core.assert($1)){
  3224. $self._pop();
  3225. $self._push_(result);
  3226. }
  3227. return self;
  3228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3229. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},$globals.ASTInterpreter)});
  3230. //>>excludeEnd("ctx");
  3231. },
  3232. //>>excludeStart("ide", pragmas.excludeIdeData);
  3233. args: ["aNode"],
  3234. source: "visitSendNode: aNode\x0a\x09| receiver args message result |\x0a\x09\x0a\x09args := aNode arguments collect: [ :each | self pop ].\x0a\x09receiver := self peek.\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\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\x09ifFalse: [ self pop; push: result ]",
  3235. referencedClasses: [],
  3236. //>>excludeEnd("ide");
  3237. messageSends: ["collect:", "arguments", "pop", "peek", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"]
  3238. }),
  3239. $globals.ASTInterpreter);
  3240. $core.addMethod(
  3241. $core.method({
  3242. selector: "visitValueNode:",
  3243. protocol: "visiting",
  3244. fn: function (aNode){
  3245. var self=this,$self=this;
  3246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3247. return $core.withContext(function($ctx1) {
  3248. //>>excludeEnd("ctx");
  3249. $self._push_($recv(aNode)._value());
  3250. return self;
  3251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3252. }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},$globals.ASTInterpreter)});
  3253. //>>excludeEnd("ctx");
  3254. },
  3255. //>>excludeStart("ide", pragmas.excludeIdeData);
  3256. args: ["aNode"],
  3257. source: "visitValueNode: aNode\x0a\x09self push: aNode value",
  3258. referencedClasses: [],
  3259. //>>excludeEnd("ide");
  3260. messageSends: ["push:", "value"]
  3261. }),
  3262. $globals.ASTInterpreter);
  3263. $core.addMethod(
  3264. $core.method({
  3265. selector: "visitVariableNode:",
  3266. protocol: "visiting",
  3267. fn: function (aNode){
  3268. var self=this,$self=this;
  3269. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3270. return $core.withContext(function($ctx1) {
  3271. //>>excludeEnd("ctx");
  3272. var $2,$1,$5,$6,$4,$3,$8,$10,$9,$11,$12,$13,$15,$14,$16,$17,$7;
  3273. $2=$recv(aNode)._binding();
  3274. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3275. $ctx1.sendIdx["binding"]=1;
  3276. //>>excludeEnd("ctx");
  3277. $1=$recv($2)._isUnknownVar();
  3278. if($core.assert($1)){
  3279. $5=$recv($globals.Platform)._globals();
  3280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3281. $ctx1.sendIdx["globals"]=1;
  3282. //>>excludeEnd("ctx");
  3283. $6=$recv(aNode)._value();
  3284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3285. $ctx1.sendIdx["value"]=1;
  3286. //>>excludeEnd("ctx");
  3287. $4=$recv($5)._at_ifAbsent_($6,(function(){
  3288. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3289. return $core.withContext(function($ctx2) {
  3290. //>>excludeEnd("ctx");
  3291. return $self._error_("Unknown variable");
  3292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3293. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  3294. //>>excludeEnd("ctx");
  3295. }));
  3296. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3297. $ctx1.sendIdx["at:ifAbsent:"]=1;
  3298. //>>excludeEnd("ctx");
  3299. $3=$self._push_($4);
  3300. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3301. $ctx1.sendIdx["push:"]=1;
  3302. //>>excludeEnd("ctx");
  3303. return $3;
  3304. }
  3305. $8=$recv($recv(aNode)._binding())._isInstanceVar();
  3306. if($core.assert($8)){
  3307. $10=$self._context();
  3308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3309. $ctx1.sendIdx["context"]=1;
  3310. //>>excludeEnd("ctx");
  3311. $9=$recv($10)._receiver();
  3312. $11=$recv(aNode)._value();
  3313. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3314. $ctx1.sendIdx["value"]=2;
  3315. //>>excludeEnd("ctx");
  3316. $7=$recv($9)._instVarAt_($11);
  3317. } else {
  3318. $12=$self._context();
  3319. $13=$recv(aNode)._value();
  3320. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3321. $ctx1.sendIdx["value"]=3;
  3322. //>>excludeEnd("ctx");
  3323. $7=$recv($12)._localAt_ifAbsent_($13,(function(){
  3324. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3325. return $core.withContext(function($ctx2) {
  3326. //>>excludeEnd("ctx");
  3327. $15=$recv(aNode)._value();
  3328. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3329. $ctx2.sendIdx["value"]=4;
  3330. //>>excludeEnd("ctx");
  3331. $14=$recv($15)._isCapitalized();
  3332. if($core.assert($14)){
  3333. $16=$recv($globals.Smalltalk)._globals();
  3334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3335. $ctx2.sendIdx["globals"]=2;
  3336. //>>excludeEnd("ctx");
  3337. $17=$recv(aNode)._value();
  3338. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3339. $ctx2.sendIdx["value"]=5;
  3340. //>>excludeEnd("ctx");
  3341. return $recv($16)._at_ifAbsent_($17,(function(){
  3342. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3343. return $core.withContext(function($ctx3) {
  3344. //>>excludeEnd("ctx");
  3345. return $recv($recv($globals.Platform)._globals())._at_($recv(aNode)._value());
  3346. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3347. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)});
  3348. //>>excludeEnd("ctx");
  3349. }));
  3350. }
  3351. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3352. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)});
  3353. //>>excludeEnd("ctx");
  3354. }));
  3355. }
  3356. $self._push_($7);
  3357. return self;
  3358. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3359. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},$globals.ASTInterpreter)});
  3360. //>>excludeEnd("ctx");
  3361. },
  3362. //>>excludeStart("ide", pragmas.excludeIdeData);
  3363. args: ["aNode"],
  3364. source: "visitVariableNode: aNode\x0a\x09aNode binding isUnknownVar ifTrue: [\x0a\x09\x09^ self push: (Platform globals 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 \x0a\x09\x09\x09localAt: aNode value\x0a\x09\x09\x09ifAbsent: [\x0a\x09\x09\x09\x09aNode value isCapitalized\x0a\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09Smalltalk globals \x0a\x09\x09\x09\x09\x09\x09\x09at: aNode value \x0a\x09\x09\x09\x09\x09\x09\x09ifAbsent: [ Platform globals at: aNode value ] ] ] ])",
  3365. referencedClasses: ["Platform", "Smalltalk"],
  3366. //>>excludeEnd("ide");
  3367. messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "globals", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:ifAbsent:", "isCapitalized", "at:"]
  3368. }),
  3369. $globals.ASTInterpreter);
  3370. $core.addClass("ASTInterpreterError", $globals.Error, [], "Compiler-Interpreter");
  3371. //>>excludeStart("ide", pragmas.excludeIdeData);
  3372. $globals.ASTInterpreterError.comment="I get signaled when an AST interpreter is unable to interpret a node.";
  3373. //>>excludeEnd("ide");
  3374. $core.addClass("ASTPCNodeVisitor", $globals.NodeVisitor, ["index", "trackedIndex", "selector", "currentNode"], "Compiler-Interpreter");
  3375. //>>excludeStart("ide", pragmas.excludeIdeData);
  3376. $globals.ASTPCNodeVisitor.comment="I visit an AST until I get to the current node for the `context` 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 is answered by `#currentNode`";
  3377. //>>excludeEnd("ide");
  3378. $core.addMethod(
  3379. $core.method({
  3380. selector: "currentNode",
  3381. protocol: "accessing",
  3382. fn: function (){
  3383. var self=this,$self=this;
  3384. return $self["@currentNode"];
  3385. },
  3386. //>>excludeStart("ide", pragmas.excludeIdeData);
  3387. args: [],
  3388. source: "currentNode\x0a\x09^ currentNode",
  3389. referencedClasses: [],
  3390. //>>excludeEnd("ide");
  3391. messageSends: []
  3392. }),
  3393. $globals.ASTPCNodeVisitor);
  3394. $core.addMethod(
  3395. $core.method({
  3396. selector: "increaseTrackedIndex",
  3397. protocol: "accessing",
  3398. fn: function (){
  3399. var self=this,$self=this;
  3400. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3401. return $core.withContext(function($ctx1) {
  3402. //>>excludeEnd("ctx");
  3403. $self["@trackedIndex"]=$recv($self._trackedIndex()).__plus((1));
  3404. return self;
  3405. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3406. }, function($ctx1) {$ctx1.fill(self,"increaseTrackedIndex",{},$globals.ASTPCNodeVisitor)});
  3407. //>>excludeEnd("ctx");
  3408. },
  3409. //>>excludeStart("ide", pragmas.excludeIdeData);
  3410. args: [],
  3411. source: "increaseTrackedIndex\x0a\x09trackedIndex := self trackedIndex + 1",
  3412. referencedClasses: [],
  3413. //>>excludeEnd("ide");
  3414. messageSends: ["+", "trackedIndex"]
  3415. }),
  3416. $globals.ASTPCNodeVisitor);
  3417. $core.addMethod(
  3418. $core.method({
  3419. selector: "index",
  3420. protocol: "accessing",
  3421. fn: function (){
  3422. var self=this,$self=this;
  3423. return $self["@index"];
  3424. },
  3425. //>>excludeStart("ide", pragmas.excludeIdeData);
  3426. args: [],
  3427. source: "index\x0a\x09^ index",
  3428. referencedClasses: [],
  3429. //>>excludeEnd("ide");
  3430. messageSends: []
  3431. }),
  3432. $globals.ASTPCNodeVisitor);
  3433. $core.addMethod(
  3434. $core.method({
  3435. selector: "index:",
  3436. protocol: "accessing",
  3437. fn: function (aNumber){
  3438. var self=this,$self=this;
  3439. $self["@index"]=aNumber;
  3440. return self;
  3441. },
  3442. //>>excludeStart("ide", pragmas.excludeIdeData);
  3443. args: ["aNumber"],
  3444. source: "index: aNumber\x0a\x09index := aNumber",
  3445. referencedClasses: [],
  3446. //>>excludeEnd("ide");
  3447. messageSends: []
  3448. }),
  3449. $globals.ASTPCNodeVisitor);
  3450. $core.addMethod(
  3451. $core.method({
  3452. selector: "selector",
  3453. protocol: "accessing",
  3454. fn: function (){
  3455. var self=this,$self=this;
  3456. return $self["@selector"];
  3457. },
  3458. //>>excludeStart("ide", pragmas.excludeIdeData);
  3459. args: [],
  3460. source: "selector\x0a\x09^ selector",
  3461. referencedClasses: [],
  3462. //>>excludeEnd("ide");
  3463. messageSends: []
  3464. }),
  3465. $globals.ASTPCNodeVisitor);
  3466. $core.addMethod(
  3467. $core.method({
  3468. selector: "selector:",
  3469. protocol: "accessing",
  3470. fn: function (aString){
  3471. var self=this,$self=this;
  3472. $self["@selector"]=aString;
  3473. return self;
  3474. },
  3475. //>>excludeStart("ide", pragmas.excludeIdeData);
  3476. args: ["aString"],
  3477. source: "selector: aString\x0a\x09selector := aString",
  3478. referencedClasses: [],
  3479. //>>excludeEnd("ide");
  3480. messageSends: []
  3481. }),
  3482. $globals.ASTPCNodeVisitor);
  3483. $core.addMethod(
  3484. $core.method({
  3485. selector: "trackedIndex",
  3486. protocol: "accessing",
  3487. fn: function (){
  3488. var self=this,$self=this;
  3489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3490. return $core.withContext(function($ctx1) {
  3491. //>>excludeEnd("ctx");
  3492. var $1,$receiver;
  3493. $1=$self["@trackedIndex"];
  3494. if(($receiver = $1) == null || $receiver.a$nil){
  3495. $self["@trackedIndex"]=(0);
  3496. return $self["@trackedIndex"];
  3497. } else {
  3498. return $1;
  3499. }
  3500. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3501. }, function($ctx1) {$ctx1.fill(self,"trackedIndex",{},$globals.ASTPCNodeVisitor)});
  3502. //>>excludeEnd("ctx");
  3503. },
  3504. //>>excludeStart("ide", pragmas.excludeIdeData);
  3505. args: [],
  3506. source: "trackedIndex\x0a\x09^ trackedIndex ifNil: [ trackedIndex := 0 ]",
  3507. referencedClasses: [],
  3508. //>>excludeEnd("ide");
  3509. messageSends: ["ifNil:"]
  3510. }),
  3511. $globals.ASTPCNodeVisitor);
  3512. $core.addMethod(
  3513. $core.method({
  3514. selector: "visitJSStatementNode:",
  3515. protocol: "visiting",
  3516. fn: function (aNode){
  3517. var self=this,$self=this;
  3518. $self["@currentNode"]=aNode;
  3519. return self;
  3520. },
  3521. //>>excludeStart("ide", pragmas.excludeIdeData);
  3522. args: ["aNode"],
  3523. source: "visitJSStatementNode: aNode\x0a\x09\x22If a JSStatementNode is encountered, it always is the current node.\x0a\x09Stop visiting the AST there\x22\x0a\x09\x0a\x09currentNode := aNode",
  3524. referencedClasses: [],
  3525. //>>excludeEnd("ide");
  3526. messageSends: []
  3527. }),
  3528. $globals.ASTPCNodeVisitor);
  3529. $core.addMethod(
  3530. $core.method({
  3531. selector: "visitSendNode:",
  3532. protocol: "visiting",
  3533. fn: function (aNode){
  3534. var self=this,$self=this;
  3535. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3536. return $core.withContext(function($ctx1) {
  3537. //>>excludeEnd("ctx");
  3538. var $2,$1,$3;
  3539. (
  3540. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3541. $ctx1.supercall = true,
  3542. //>>excludeEnd("ctx");
  3543. ($globals.ASTPCNodeVisitor.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.apply($self, [aNode]));
  3544. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3545. $ctx1.supercall = false;
  3546. //>>excludeEnd("ctx");;
  3547. $2=$self._selector();
  3548. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3549. $ctx1.sendIdx["selector"]=1;
  3550. //>>excludeEnd("ctx");
  3551. $1=$recv($2).__eq($recv(aNode)._selector());
  3552. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3553. $ctx1.sendIdx["="]=1;
  3554. //>>excludeEnd("ctx");
  3555. if($core.assert($1)){
  3556. $3=$recv($self._trackedIndex()).__eq($self._index());
  3557. if($core.assert($3)){
  3558. $self["@currentNode"]=aNode;
  3559. $self["@currentNode"];
  3560. }
  3561. $self._increaseTrackedIndex();
  3562. }
  3563. return self;
  3564. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3565. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.ASTPCNodeVisitor)});
  3566. //>>excludeEnd("ctx");
  3567. },
  3568. //>>excludeStart("ide", pragmas.excludeIdeData);
  3569. args: ["aNode"],
  3570. source: "visitSendNode: aNode\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self selector = aNode selector ifTrue: [\x0a\x09\x09self trackedIndex = self index ifTrue: [ currentNode := aNode ].\x0a\x09\x09self increaseTrackedIndex ]",
  3571. referencedClasses: [],
  3572. //>>excludeEnd("ide");
  3573. messageSends: ["visitSendNode:", "ifTrue:", "=", "selector", "trackedIndex", "index", "increaseTrackedIndex"]
  3574. }),
  3575. $globals.ASTPCNodeVisitor);
  3576. $core.addMethod(
  3577. $core.method({
  3578. selector: "isLastChild",
  3579. protocol: "*Compiler-Interpreter",
  3580. fn: function (){
  3581. var self=this,$self=this;
  3582. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3583. return $core.withContext(function($ctx1) {
  3584. //>>excludeEnd("ctx");
  3585. return $recv($recv($recv($self._parent())._dagChildren())._last()).__eq(self);
  3586. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3587. }, function($ctx1) {$ctx1.fill(self,"isLastChild",{},$globals.ASTNode)});
  3588. //>>excludeEnd("ctx");
  3589. },
  3590. //>>excludeStart("ide", pragmas.excludeIdeData);
  3591. args: [],
  3592. source: "isLastChild\x0a\x09^ self parent dagChildren last = self",
  3593. referencedClasses: [],
  3594. //>>excludeEnd("ide");
  3595. messageSends: ["=", "last", "dagChildren", "parent"]
  3596. }),
  3597. $globals.ASTNode);
  3598. $core.addMethod(
  3599. $core.method({
  3600. selector: "isSteppingNode",
  3601. protocol: "*Compiler-Interpreter",
  3602. fn: function (){
  3603. var self=this,$self=this;
  3604. return false;
  3605. },
  3606. //>>excludeStart("ide", pragmas.excludeIdeData);
  3607. args: [],
  3608. source: "isSteppingNode\x0a\x09^ false",
  3609. referencedClasses: [],
  3610. //>>excludeEnd("ide");
  3611. messageSends: []
  3612. }),
  3613. $globals.ASTNode);
  3614. $core.addMethod(
  3615. $core.method({
  3616. selector: "nextSiblingNode:",
  3617. protocol: "*Compiler-Interpreter",
  3618. fn: function (aNode){
  3619. var self=this,$self=this;
  3620. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3621. return $core.withContext(function($ctx1) {
  3622. //>>excludeEnd("ctx");
  3623. var $1;
  3624. var $early={};
  3625. try {
  3626. $1=$self._dagChildren();
  3627. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3628. $ctx1.sendIdx["dagChildren"]=1;
  3629. //>>excludeEnd("ctx");
  3630. return $recv($1)._at_ifAbsent_($recv($recv($self._dagChildren())._indexOf_(aNode)).__plus((1)),(function(){
  3631. throw $early=[nil];
  3632. }));
  3633. }
  3634. catch(e) {if(e===$early)return e[0]; throw e}
  3635. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3636. }, function($ctx1) {$ctx1.fill(self,"nextSiblingNode:",{aNode:aNode},$globals.ASTNode)});
  3637. //>>excludeEnd("ctx");
  3638. },
  3639. //>>excludeStart("ide", pragmas.excludeIdeData);
  3640. args: ["aNode"],
  3641. source: "nextSiblingNode: aNode\x0a\x09\x22Answer the next node after aNode or nil\x22\x0a\x09\x0a\x09^ self dagChildren \x0a\x09\x09at: (self dagChildren indexOf: aNode) + 1\x0a\x09\x09ifAbsent: [ ^ nil ]",
  3642. referencedClasses: [],
  3643. //>>excludeEnd("ide");
  3644. messageSends: ["at:ifAbsent:", "dagChildren", "+", "indexOf:"]
  3645. }),
  3646. $globals.ASTNode);
  3647. $core.addMethod(
  3648. $core.method({
  3649. selector: "isSteppingNode",
  3650. protocol: "*Compiler-Interpreter",
  3651. fn: function (){
  3652. var self=this,$self=this;
  3653. return true;
  3654. },
  3655. //>>excludeStart("ide", pragmas.excludeIdeData);
  3656. args: [],
  3657. source: "isSteppingNode\x0a\x09^ true",
  3658. referencedClasses: [],
  3659. //>>excludeEnd("ide");
  3660. messageSends: []
  3661. }),
  3662. $globals.AssignmentNode);
  3663. $core.addMethod(
  3664. $core.method({
  3665. selector: "isSteppingNode",
  3666. protocol: "*Compiler-Interpreter",
  3667. fn: function (){
  3668. var self=this,$self=this;
  3669. return true;
  3670. },
  3671. //>>excludeStart("ide", pragmas.excludeIdeData);
  3672. args: [],
  3673. source: "isSteppingNode\x0a\x09^ true",
  3674. referencedClasses: [],
  3675. //>>excludeEnd("ide");
  3676. messageSends: []
  3677. }),
  3678. $globals.BlockNode);
  3679. $core.addMethod(
  3680. $core.method({
  3681. selector: "nextSiblingNode:",
  3682. protocol: "*Compiler-Interpreter",
  3683. fn: function (aNode){
  3684. var self=this,$self=this;
  3685. return nil;
  3686. },
  3687. //>>excludeStart("ide", pragmas.excludeIdeData);
  3688. args: ["aNode"],
  3689. source: "nextSiblingNode: aNode\x0a\x09\x22Answer nil as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09\x22In fact, this should not have been called, ever. IMO. -- herby\x22\x0a\x09\x0a\x09^ nil",
  3690. referencedClasses: [],
  3691. //>>excludeEnd("ide");
  3692. messageSends: []
  3693. }),
  3694. $globals.BlockNode);
  3695. $core.addMethod(
  3696. $core.method({
  3697. selector: "isSteppingNode",
  3698. protocol: "*Compiler-Interpreter",
  3699. fn: function (){
  3700. var self=this,$self=this;
  3701. return true;
  3702. },
  3703. //>>excludeStart("ide", pragmas.excludeIdeData);
  3704. args: [],
  3705. source: "isSteppingNode\x0a\x09^ true",
  3706. referencedClasses: [],
  3707. //>>excludeEnd("ide");
  3708. messageSends: []
  3709. }),
  3710. $globals.DynamicArrayNode);
  3711. $core.addMethod(
  3712. $core.method({
  3713. selector: "isSteppingNode",
  3714. protocol: "*Compiler-Interpreter",
  3715. fn: function (){
  3716. var self=this,$self=this;
  3717. return true;
  3718. },
  3719. //>>excludeStart("ide", pragmas.excludeIdeData);
  3720. args: [],
  3721. source: "isSteppingNode\x0a\x09^ true",
  3722. referencedClasses: [],
  3723. //>>excludeEnd("ide");
  3724. messageSends: []
  3725. }),
  3726. $globals.DynamicDictionaryNode);
  3727. $core.addMethod(
  3728. $core.method({
  3729. selector: "isSteppingNode",
  3730. protocol: "*Compiler-Interpreter",
  3731. fn: function (){
  3732. var self=this,$self=this;
  3733. return true;
  3734. },
  3735. //>>excludeStart("ide", pragmas.excludeIdeData);
  3736. args: [],
  3737. source: "isSteppingNode\x0a\x09^ true",
  3738. referencedClasses: [],
  3739. //>>excludeEnd("ide");
  3740. messageSends: []
  3741. }),
  3742. $globals.JSStatementNode);
  3743. $core.addMethod(
  3744. $core.method({
  3745. selector: "isCascadeSendNode",
  3746. protocol: "*Compiler-Interpreter",
  3747. fn: function (){
  3748. var self=this,$self=this;
  3749. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3750. return $core.withContext(function($ctx1) {
  3751. //>>excludeEnd("ctx");
  3752. return $recv($self._parent())._isCascadeNode();
  3753. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3754. }, function($ctx1) {$ctx1.fill(self,"isCascadeSendNode",{},$globals.SendNode)});
  3755. //>>excludeEnd("ctx");
  3756. },
  3757. //>>excludeStart("ide", pragmas.excludeIdeData);
  3758. args: [],
  3759. source: "isCascadeSendNode\x0a\x09^ self parent isCascadeNode",
  3760. referencedClasses: [],
  3761. //>>excludeEnd("ide");
  3762. messageSends: ["isCascadeNode", "parent"]
  3763. }),
  3764. $globals.SendNode);
  3765. $core.addMethod(
  3766. $core.method({
  3767. selector: "isSteppingNode",
  3768. protocol: "*Compiler-Interpreter",
  3769. fn: function (){
  3770. var self=this,$self=this;
  3771. return true;
  3772. },
  3773. //>>excludeStart("ide", pragmas.excludeIdeData);
  3774. args: [],
  3775. source: "isSteppingNode\x0a\x09^ true",
  3776. referencedClasses: [],
  3777. //>>excludeEnd("ide");
  3778. messageSends: []
  3779. }),
  3780. $globals.SendNode);
  3781. });