1
0

Compiler-Interpreter.js 128 KB

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