Compiler-Interpreter.js 132 KB

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