Compiler-Interpreter.js 129 KB

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