1
0

Compiler-Interpreter.js 130 KB

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