Compiler-Interpreter.js 129 KB

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