2
0

Compiler-Interpreter.js 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408
  1. define("amber_core/Compiler-Interpreter", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Methods", "amber_core/Kernel-Objects", "amber_core/Compiler-Core", "amber_core/Kernel-Exceptions", "amber_core/Compiler-AST"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Interpreter');
  3. smalltalk.packages["Compiler-Interpreter"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('AIBlockClosure', smalltalk.BlockClosure, ['node', 'outerContext'], 'Compiler-Interpreter');
  5. smalltalk.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`).";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "applyTo:arguments:",
  9. protocol: 'evaluating',
  10. fn: function (anObject,aCollection){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. self._interpreterError();
  14. return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},smalltalk.AIBlockClosure)})},
  15. args: ["anObject", "aCollection"],
  16. source: "applyTo: anObject arguments: aCollection\x0a\x09self interpreterError",
  17. messageSends: ["interpreterError"],
  18. referencedClasses: []
  19. }),
  20. smalltalk.AIBlockClosure);
  21. smalltalk.addMethod(
  22. smalltalk.method({
  23. selector: "compiledSource",
  24. protocol: 'accessing',
  25. fn: function (){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx1) {
  28. return "[ AST Block closure ]";
  29. }, function($ctx1) {$ctx1.fill(self,"compiledSource",{},smalltalk.AIBlockClosure)})},
  30. args: [],
  31. source: "compiledSource\x0a\x09\x22Unlike blocks, the receiver doesn't represent a JS function\x22\x0a\x09\x0a\x09^ '[ AST Block closure ]'",
  32. messageSends: [],
  33. referencedClasses: []
  34. }),
  35. smalltalk.AIBlockClosure);
  36. smalltalk.addMethod(
  37. smalltalk.method({
  38. selector: "currySelf",
  39. protocol: 'converting',
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) {
  43. self._interpreterError();
  44. return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},smalltalk.AIBlockClosure)})},
  45. args: [],
  46. source: "currySelf\x0a\x09self interpreterError",
  47. messageSends: ["interpreterError"],
  48. referencedClasses: []
  49. }),
  50. smalltalk.AIBlockClosure);
  51. smalltalk.addMethod(
  52. smalltalk.method({
  53. selector: "initializeWithContext:node:",
  54. protocol: 'initialization',
  55. fn: function (aContext,aNode){
  56. var self=this;
  57. return smalltalk.withContext(function($ctx1) {
  58. self["@node"]=aNode;
  59. self["@outerContext"]=aContext;
  60. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure)})},
  61. args: ["aContext", "aNode"],
  62. source: "initializeWithContext: aContext node: aNode\x0a\x09node := aNode.\x0a\x09outerContext := aContext",
  63. messageSends: [],
  64. referencedClasses: []
  65. }),
  66. smalltalk.AIBlockClosure);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "interpreterError",
  70. protocol: 'error handling',
  71. fn: function (){
  72. var self=this;
  73. function $ASTInterpreterError(){return smalltalk.ASTInterpreterError||(typeof ASTInterpreterError=="undefined"?nil:ASTInterpreterError)}
  74. return smalltalk.withContext(function($ctx1) {
  75. _st($ASTInterpreterError())._signal_("Method cannot be interpreted by the interpreter.");
  76. return self}, function($ctx1) {$ctx1.fill(self,"interpreterError",{},smalltalk.AIBlockClosure)})},
  77. args: [],
  78. source: "interpreterError\x0a\x09ASTInterpreterError signal: 'Method cannot be interpreted by the interpreter.'",
  79. messageSends: ["signal:"],
  80. referencedClasses: ["ASTInterpreterError"]
  81. }),
  82. smalltalk.AIBlockClosure);
  83. smalltalk.addMethod(
  84. smalltalk.method({
  85. selector: "numArgs",
  86. protocol: 'accessing',
  87. fn: function (){
  88. var self=this;
  89. return smalltalk.withContext(function($ctx1) {
  90. var $1;
  91. $1=_st(_st(self["@node"])._temps())._size();
  92. return $1;
  93. }, function($ctx1) {$ctx1.fill(self,"numArgs",{},smalltalk.AIBlockClosure)})},
  94. args: [],
  95. source: "numArgs\x0a\x09^ node temps size",
  96. messageSends: ["size", "temps"],
  97. referencedClasses: []
  98. }),
  99. smalltalk.AIBlockClosure);
  100. smalltalk.addMethod(
  101. smalltalk.method({
  102. selector: "value",
  103. protocol: 'evaluating',
  104. fn: function (){
  105. var self=this;
  106. return smalltalk.withContext(function($ctx1) {
  107. var $1;
  108. $1=self._valueWithPossibleArguments_([]);
  109. return $1;
  110. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.AIBlockClosure)})},
  111. args: [],
  112. source: "value\x0a\x09^ self valueWithPossibleArguments: #()",
  113. messageSends: ["valueWithPossibleArguments:"],
  114. referencedClasses: []
  115. }),
  116. smalltalk.AIBlockClosure);
  117. smalltalk.addMethod(
  118. smalltalk.method({
  119. selector: "value:",
  120. protocol: 'evaluating',
  121. fn: function (anArgument){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) {
  124. var $1;
  125. $1=self._valueWithPossibleArguments_([anArgument]);
  126. return $1;
  127. }, function($ctx1) {$ctx1.fill(self,"value:",{anArgument:anArgument},smalltalk.AIBlockClosure)})},
  128. args: ["anArgument"],
  129. source: "value: anArgument\x0a\x09^ self valueWithPossibleArguments: {anArgument}",
  130. messageSends: ["valueWithPossibleArguments:"],
  131. referencedClasses: []
  132. }),
  133. smalltalk.AIBlockClosure);
  134. smalltalk.addMethod(
  135. smalltalk.method({
  136. selector: "value:value:",
  137. protocol: 'evaluating',
  138. fn: function (firstArgument,secondArgument){
  139. var self=this;
  140. return smalltalk.withContext(function($ctx1) {
  141. var $1;
  142. $1=self._valueWithPossibleArguments_([firstArgument,secondArgument]);
  143. return $1;
  144. }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},smalltalk.AIBlockClosure)})},
  145. args: ["firstArgument", "secondArgument"],
  146. source: "value: firstArgument value: secondArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument}",
  147. messageSends: ["valueWithPossibleArguments:"],
  148. referencedClasses: []
  149. }),
  150. smalltalk.AIBlockClosure);
  151. smalltalk.addMethod(
  152. smalltalk.method({
  153. selector: "value:value:value:",
  154. protocol: 'evaluating',
  155. fn: function (firstArgument,secondArgument,thirdArgument){
  156. var self=this;
  157. return smalltalk.withContext(function($ctx1) {
  158. var $1;
  159. $1=self._valueWithPossibleArguments_([firstArgument,secondArgument,thirdArgument]);
  160. return $1;
  161. }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},smalltalk.AIBlockClosure)})},
  162. args: ["firstArgument", "secondArgument", "thirdArgument"],
  163. source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument . thirdArgument}",
  164. messageSends: ["valueWithPossibleArguments:"],
  165. referencedClasses: []
  166. }),
  167. smalltalk.AIBlockClosure);
  168. smalltalk.addMethod(
  169. smalltalk.method({
  170. selector: "valueWithPossibleArguments:",
  171. protocol: 'evaluating',
  172. fn: function (aCollection){
  173. var self=this;
  174. var context,sequenceNode;
  175. return smalltalk.withContext(function($ctx1) {
  176. var $1,$2,$3,$4,$5,$6;
  177. context=_st(self["@outerContext"])._newBlockContext();
  178. $1=_st(_st(_st(self["@node"])._nodes())._first())._copy();
  179. _st($1)._parent_(nil);
  180. $2=_st($1)._yourself();
  181. sequenceNode=$2;
  182. _st(_st(self["@node"])._parameters())._withIndexDo_((function(each,index){
  183. return smalltalk.withContext(function($ctx2) {
  184. return _st(context)._localAt_put_(each,_st(aCollection)._at_ifAbsent_(index,(function(){
  185. return smalltalk.withContext(function($ctx3) {
  186. return nil;
  187. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})));
  188. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
  189. $3=_st(context)._interpreter();
  190. $ctx1.sendIdx["interpreter"]=1;
  191. _st($3)._node_(_st(sequenceNode)._nextChild());
  192. $4=_st($3)._proceed();
  193. $5=_st(self["@outerContext"])._interpreter();
  194. $ctx1.sendIdx["interpreter"]=2;
  195. _st($5)._setNonLocalReturnFromContext_(context);
  196. $6=_st(_st(context)._interpreter())._pop();
  197. return $6;
  198. }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection,context:context,sequenceNode:sequenceNode},smalltalk.AIBlockClosure)})},
  199. args: ["aCollection"],
  200. source: "valueWithPossibleArguments: aCollection\x0a\x09| context sequenceNode |\x0a\x09context := outerContext newBlockContext.\x0a\x0a\x09\x22Interpret a copy of the sequence node to avoid creating a new AIBlockClosure\x22\x0a\x09sequenceNode := node nodes first copy\x0a\x09\x09parent: nil;\x0a\x09\x09yourself.\x0a\x0a\x09\x22Populate the arguments into the context locals\x22\x09\x0a\x09node parameters withIndexDo: [ :each :index |\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 nextChild;\x0a\x09\x09proceed.\x0a\x09\x09\x0a\x09outerContext interpreter\x0a\x09\x09setNonLocalReturnFromContext: context.\x0a\x09\x09\x0a\x09^ context interpreter pop",
  201. messageSends: ["newBlockContext", "parent:", "copy", "first", "nodes", "yourself", "withIndexDo:", "parameters", "localAt:put:", "at:ifAbsent:", "node:", "interpreter", "nextChild", "proceed", "setNonLocalReturnFromContext:", "pop"],
  202. referencedClasses: []
  203. }),
  204. smalltalk.AIBlockClosure);
  205. smalltalk.addMethod(
  206. smalltalk.method({
  207. selector: "forContext:node:",
  208. protocol: 'instance creation',
  209. fn: function (aContext,aNode){
  210. var self=this;
  211. return smalltalk.withContext(function($ctx1) {
  212. var $2,$3,$1;
  213. $2=self._new();
  214. _st($2)._initializeWithContext_node_(aContext,aNode);
  215. $3=_st($2)._yourself();
  216. $1=$3;
  217. return $1;
  218. }, function($ctx1) {$ctx1.fill(self,"forContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure.klass)})},
  219. args: ["aContext", "aNode"],
  220. source: "forContext: aContext node: aNode\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext node: aNode;\x0a\x09\x09yourself",
  221. messageSends: ["initializeWithContext:node:", "new", "yourself"],
  222. referencedClasses: []
  223. }),
  224. smalltalk.AIBlockClosure.klass);
  225. smalltalk.addClass('AIContext', smalltalk.MethodContext, ['outerContext', 'innerContext', 'pc', 'locals', 'selector', 'index', 'sendIndexes', 'evaluatedSelector', 'ast', 'interpreter'], 'Compiler-Interpreter');
  226. smalltalk.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)";
  227. smalltalk.addMethod(
  228. smalltalk.method({
  229. selector: "arguments",
  230. protocol: 'interpreting',
  231. fn: function (){
  232. var self=this;
  233. return smalltalk.withContext(function($ctx1) {
  234. var $1;
  235. $1=_st(_st(self._ast())._arguments())._collect_((function(each){
  236. return smalltalk.withContext(function($ctx2) {
  237. return self._localAt_(each);
  238. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  239. return $1;
  240. }, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.AIContext)})},
  241. args: [],
  242. source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ]",
  243. messageSends: ["collect:", "arguments", "ast", "localAt:"],
  244. referencedClasses: []
  245. }),
  246. smalltalk.AIContext);
  247. smalltalk.addMethod(
  248. smalltalk.method({
  249. selector: "ast",
  250. protocol: 'interpreting',
  251. fn: function (){
  252. var self=this;
  253. return smalltalk.withContext(function($ctx1) {
  254. var $1,$3,$2,$4,$5;
  255. $1=self._isBlockContext();
  256. if(smalltalk.assert($1)){
  257. $3=self._outerContext();
  258. if(($receiver = $3) == nil || $receiver == null){
  259. $2=$3;
  260. } else {
  261. var context;
  262. context=$receiver;
  263. $2=_st(context)._ast();
  264. };
  265. return $2;
  266. };
  267. $4=self["@ast"];
  268. if(($receiver = $4) == nil || $receiver == null){
  269. self._initializeAST();
  270. } else {
  271. $4;
  272. };
  273. $5=self["@ast"];
  274. return $5;
  275. }, function($ctx1) {$ctx1.fill(self,"ast",{},smalltalk.AIContext)})},
  276. args: [],
  277. source: "ast\x0a\x09self isBlockContext ifTrue: [ \x0a\x09\x09^ self outerContext ifNotNil: [ :context | context ast ] ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
  278. messageSends: ["ifTrue:", "isBlockContext", "ifNotNil:", "outerContext", "ast", "ifNil:", "initializeAST"],
  279. referencedClasses: []
  280. }),
  281. smalltalk.AIContext);
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "evaluatedSelector",
  285. protocol: 'accessing',
  286. fn: function (){
  287. var self=this;
  288. return smalltalk.withContext(function($ctx1) {
  289. var $1;
  290. $1=self["@evaluatedSelector"];
  291. return $1;
  292. }, function($ctx1) {$ctx1.fill(self,"evaluatedSelector",{},smalltalk.AIContext)})},
  293. args: [],
  294. source: "evaluatedSelector\x0a\x09^ evaluatedSelector",
  295. messageSends: [],
  296. referencedClasses: []
  297. }),
  298. smalltalk.AIContext);
  299. smalltalk.addMethod(
  300. smalltalk.method({
  301. selector: "evaluatedSelector:",
  302. protocol: 'accessing',
  303. fn: function (aString){
  304. var self=this;
  305. return smalltalk.withContext(function($ctx1) {
  306. self["@evaluatedSelector"]=aString;
  307. return self}, function($ctx1) {$ctx1.fill(self,"evaluatedSelector:",{aString:aString},smalltalk.AIContext)})},
  308. args: ["aString"],
  309. source: "evaluatedSelector: aString\x0a\x09evaluatedSelector := aString",
  310. messageSends: [],
  311. referencedClasses: []
  312. }),
  313. smalltalk.AIContext);
  314. smalltalk.addMethod(
  315. smalltalk.method({
  316. selector: "index",
  317. protocol: 'accessing',
  318. fn: function (){
  319. var self=this;
  320. return smalltalk.withContext(function($ctx1) {
  321. var $2,$1;
  322. $2=self["@index"];
  323. if(($receiver = $2) == nil || $receiver == null){
  324. $1=(0);
  325. } else {
  326. $1=$2;
  327. };
  328. return $1;
  329. }, function($ctx1) {$ctx1.fill(self,"index",{},smalltalk.AIContext)})},
  330. args: [],
  331. source: "index\x0a\x09^ index ifNil: [ 0 ]",
  332. messageSends: ["ifNil:"],
  333. referencedClasses: []
  334. }),
  335. smalltalk.AIContext);
  336. smalltalk.addMethod(
  337. smalltalk.method({
  338. selector: "index:",
  339. protocol: 'accessing',
  340. fn: function (anInteger){
  341. var self=this;
  342. return smalltalk.withContext(function($ctx1) {
  343. self["@index"]=anInteger;
  344. return self}, function($ctx1) {$ctx1.fill(self,"index:",{anInteger:anInteger},smalltalk.AIContext)})},
  345. args: ["anInteger"],
  346. source: "index: anInteger\x0a\x09index := anInteger",
  347. messageSends: [],
  348. referencedClasses: []
  349. }),
  350. smalltalk.AIContext);
  351. smalltalk.addMethod(
  352. smalltalk.method({
  353. selector: "initializeAST",
  354. protocol: 'initialization',
  355. fn: function (){
  356. var self=this;
  357. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  358. return smalltalk.withContext(function($ctx1) {
  359. var $1;
  360. $1=self._method();
  361. $ctx1.sendIdx["method"]=1;
  362. self["@ast"]=_st($1)._ast();
  363. _st(_st($SemanticAnalyzer())._on_(_st(self._method())._methodClass()))._visit_(self["@ast"]);
  364. return self}, function($ctx1) {$ctx1.fill(self,"initializeAST",{},smalltalk.AIContext)})},
  365. args: [],
  366. source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
  367. messageSends: ["ast", "method", "visit:", "on:", "methodClass"],
  368. referencedClasses: ["SemanticAnalyzer"]
  369. }),
  370. smalltalk.AIContext);
  371. smalltalk.addMethod(
  372. smalltalk.method({
  373. selector: "initializeFromMethodContext:",
  374. protocol: 'initialization',
  375. fn: function (aMethodContext){
  376. var self=this;
  377. return smalltalk.withContext(function($ctx1) {
  378. var $1,$2,$3,$4;
  379. self._evaluatedSelector_(_st(aMethodContext)._evaluatedSelector());
  380. self._index_(_st(aMethodContext)._index());
  381. self._sendIndexes_(_st(aMethodContext)._sendIndexes());
  382. self._receiver_(_st(aMethodContext)._receiver());
  383. $1=self._selector_(_st(aMethodContext)._selector());
  384. $2=_st(aMethodContext)._outerContext();
  385. $ctx1.sendIdx["outerContext"]=1;
  386. if(($receiver = $2) == nil || $receiver == null){
  387. $2;
  388. } else {
  389. var outer;
  390. outer=$receiver;
  391. $3=_st(outer)._methodContext();
  392. if(($receiver = $3) == nil || $receiver == null){
  393. $3;
  394. } else {
  395. self._outerContext_(_st(self._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
  396. };
  397. $4=_st(aMethodContext)._locals();
  398. $ctx1.sendIdx["locals"]=1;
  399. _st($4)._keysAndValuesDo_((function(key,value){
  400. return smalltalk.withContext(function($ctx2) {
  401. return _st(self._locals())._at_put_(key,value);
  402. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)})}));
  403. };
  404. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext)})},
  405. args: ["aMethodContext"],
  406. 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\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 ] ]",
  407. messageSends: ["evaluatedSelector:", "evaluatedSelector", "index:", "index", "sendIndexes:", "sendIndexes", "receiver:", "receiver", "selector:", "selector", "ifNotNil:", "outerContext", "methodContext", "outerContext:", "fromMethodContext:", "class", "keysAndValuesDo:", "locals", "at:put:"],
  408. referencedClasses: []
  409. }),
  410. smalltalk.AIContext);
  411. smalltalk.addMethod(
  412. smalltalk.method({
  413. selector: "initializeInterpreter",
  414. protocol: 'initialization',
  415. fn: function (){
  416. var self=this;
  417. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  418. return smalltalk.withContext(function($ctx1) {
  419. var $1,$2,$3;
  420. $1=_st($ASTInterpreter())._new();
  421. _st($1)._context_(self);
  422. $2=_st($1)._yourself();
  423. self["@interpreter"]=$2;
  424. $3=self._innerContext();
  425. if(($receiver = $3) == nil || $receiver == null){
  426. $3;
  427. } else {
  428. self._setupInterpreter_(self["@interpreter"]);
  429. };
  430. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},smalltalk.AIContext)})},
  431. args: [],
  432. source: "initializeInterpreter\x0a\x09interpreter := ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09yourself.\x0a\x09\x0a\x09self innerContext ifNotNil: [\x0a\x09\x09self setupInterpreter: interpreter ]",
  433. messageSends: ["context:", "new", "yourself", "ifNotNil:", "innerContext", "setupInterpreter:"],
  434. referencedClasses: ["ASTInterpreter"]
  435. }),
  436. smalltalk.AIContext);
  437. smalltalk.addMethod(
  438. smalltalk.method({
  439. selector: "initializeLocals",
  440. protocol: 'initialization',
  441. fn: function (){
  442. var self=this;
  443. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  444. return smalltalk.withContext(function($ctx1) {
  445. self["@locals"]=_st($Dictionary())._new();
  446. _st(self["@locals"])._at_put_("thisContext",self);
  447. return self}, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},smalltalk.AIContext)})},
  448. args: [],
  449. source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
  450. messageSends: ["new", "at:put:"],
  451. referencedClasses: ["Dictionary"]
  452. }),
  453. smalltalk.AIContext);
  454. smalltalk.addMethod(
  455. smalltalk.method({
  456. selector: "innerContext",
  457. protocol: 'accessing',
  458. fn: function (){
  459. var self=this;
  460. return smalltalk.withContext(function($ctx1) {
  461. var $1;
  462. $1=self["@innerContext"];
  463. return $1;
  464. }, function($ctx1) {$ctx1.fill(self,"innerContext",{},smalltalk.AIContext)})},
  465. args: [],
  466. source: "innerContext\x0a\x09^ innerContext",
  467. messageSends: [],
  468. referencedClasses: []
  469. }),
  470. smalltalk.AIContext);
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "innerContext:",
  474. protocol: 'accessing',
  475. fn: function (anAIContext){
  476. var self=this;
  477. return smalltalk.withContext(function($ctx1) {
  478. self["@innerContext"]=anAIContext;
  479. return self}, function($ctx1) {$ctx1.fill(self,"innerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  480. args: ["anAIContext"],
  481. source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
  482. messageSends: [],
  483. referencedClasses: []
  484. }),
  485. smalltalk.AIContext);
  486. smalltalk.addMethod(
  487. smalltalk.method({
  488. selector: "interpreter",
  489. protocol: 'interpreting',
  490. fn: function (){
  491. var self=this;
  492. return smalltalk.withContext(function($ctx1) {
  493. var $1,$2;
  494. $1=self["@interpreter"];
  495. if(($receiver = $1) == nil || $receiver == null){
  496. self._initializeInterpreter();
  497. } else {
  498. $1;
  499. };
  500. $2=self["@interpreter"];
  501. return $2;
  502. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AIContext)})},
  503. args: [],
  504. source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
  505. messageSends: ["ifNil:", "initializeInterpreter"],
  506. referencedClasses: []
  507. }),
  508. smalltalk.AIContext);
  509. smalltalk.addMethod(
  510. smalltalk.method({
  511. selector: "interpreter:",
  512. protocol: 'interpreting',
  513. fn: function (anInterpreter){
  514. var self=this;
  515. return smalltalk.withContext(function($ctx1) {
  516. self["@interpreter"]=anInterpreter;
  517. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
  518. args: ["anInterpreter"],
  519. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  520. messageSends: [],
  521. referencedClasses: []
  522. }),
  523. smalltalk.AIContext);
  524. smalltalk.addMethod(
  525. smalltalk.method({
  526. selector: "localAt:",
  527. protocol: 'accessing',
  528. fn: function (aString){
  529. var self=this;
  530. return smalltalk.withContext(function($ctx1) {
  531. var $2,$1;
  532. $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
  533. return smalltalk.withContext(function($ctx2) {
  534. $2=self._outerContext();
  535. if(($receiver = $2) == nil || $receiver == null){
  536. return $2;
  537. } else {
  538. var context;
  539. context=$receiver;
  540. return _st(context)._localAt_(aString);
  541. };
  542. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  543. return $1;
  544. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},smalltalk.AIContext)})},
  545. args: ["aString"],
  546. source: "localAt: aString\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self outerContext ifNotNil: [ :context | \x0a\x09\x09\x09context localAt: aString ] ]",
  547. messageSends: ["at:ifAbsent:", "locals", "ifNotNil:", "outerContext", "localAt:"],
  548. referencedClasses: []
  549. }),
  550. smalltalk.AIContext);
  551. smalltalk.addMethod(
  552. smalltalk.method({
  553. selector: "localAt:ifAbsent:",
  554. protocol: 'accessing',
  555. fn: function (aString,aBlock){
  556. var self=this;
  557. return smalltalk.withContext(function($ctx1) {
  558. var $2,$1;
  559. $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
  560. return smalltalk.withContext(function($ctx2) {
  561. $2=self._outerContext();
  562. if(($receiver = $2) == nil || $receiver == null){
  563. return _st(aBlock)._value();
  564. } else {
  565. var context;
  566. context=$receiver;
  567. return _st(context)._localAt_ifAbsent_(aString,aBlock);
  568. };
  569. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  570. return $1;
  571. }, function($ctx1) {$ctx1.fill(self,"localAt:ifAbsent:",{aString:aString,aBlock:aBlock},smalltalk.AIContext)})},
  572. args: ["aString", "aBlock"],
  573. source: "localAt: aString ifAbsent: aBlock\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self outerContext \x0a\x09\x09\x09ifNotNil: [ :context | context localAt: aString ifAbsent: aBlock ]\x0a\x09\x09\x09ifNil: [ aBlock value ] ]",
  574. messageSends: ["at:ifAbsent:", "locals", "ifNotNil:ifNil:", "outerContext", "localAt:ifAbsent:", "value"],
  575. referencedClasses: []
  576. }),
  577. smalltalk.AIContext);
  578. smalltalk.addMethod(
  579. smalltalk.method({
  580. selector: "localAt:put:",
  581. protocol: 'accessing',
  582. fn: function (aString,anObject){
  583. var self=this;
  584. return smalltalk.withContext(function($ctx1) {
  585. _st(self._locals())._at_put_(aString,anObject);
  586. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},smalltalk.AIContext)})},
  587. args: ["aString", "anObject"],
  588. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  589. messageSends: ["at:put:", "locals"],
  590. referencedClasses: []
  591. }),
  592. smalltalk.AIContext);
  593. smalltalk.addMethod(
  594. smalltalk.method({
  595. selector: "locals",
  596. protocol: 'accessing',
  597. fn: function (){
  598. var self=this;
  599. return smalltalk.withContext(function($ctx1) {
  600. var $1,$2;
  601. $1=self["@locals"];
  602. if(($receiver = $1) == nil || $receiver == null){
  603. self._initializeLocals();
  604. } else {
  605. $1;
  606. };
  607. $2=self["@locals"];
  608. return $2;
  609. }, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.AIContext)})},
  610. args: [],
  611. source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
  612. messageSends: ["ifNil:", "initializeLocals"],
  613. referencedClasses: []
  614. }),
  615. smalltalk.AIContext);
  616. smalltalk.addMethod(
  617. smalltalk.method({
  618. selector: "method",
  619. protocol: 'accessing',
  620. fn: function (){
  621. var self=this;
  622. return smalltalk.withContext(function($ctx1) {
  623. var $2,$5,$4,$3,$1;
  624. $2=self._methodContext();
  625. $ctx1.sendIdx["methodContext"]=1;
  626. if(($receiver = $2) == nil || $receiver == null){
  627. $1=$2;
  628. } else {
  629. $5=self._methodContext();
  630. $ctx1.sendIdx["methodContext"]=2;
  631. $4=_st($5)._receiver();
  632. $3=_st($4)._class();
  633. $1=_st($3)._lookupSelector_(_st(self._methodContext())._selector());
  634. };
  635. return $1;
  636. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.AIContext)})},
  637. args: [],
  638. source: "method\x0a\x09^ self methodContext ifNotNil: [\x0a\x09\x09self methodContext receiver class lookupSelector: self methodContext selector ]",
  639. messageSends: ["ifNotNil:", "methodContext", "lookupSelector:", "class", "receiver", "selector"],
  640. referencedClasses: []
  641. }),
  642. smalltalk.AIContext);
  643. smalltalk.addMethod(
  644. smalltalk.method({
  645. selector: "newBlockContext",
  646. protocol: 'factory',
  647. fn: function (){
  648. var self=this;
  649. return smalltalk.withContext(function($ctx1) {
  650. var $2,$3,$1;
  651. $2=_st(self._class())._new();
  652. _st($2)._outerContext_(self);
  653. $3=_st($2)._yourself();
  654. $1=$3;
  655. return $1;
  656. }, function($ctx1) {$ctx1.fill(self,"newBlockContext",{},smalltalk.AIContext)})},
  657. args: [],
  658. source: "newBlockContext\x0a\x09^ self class new\x0a\x09\x09outerContext: self;\x0a\x09\x09yourself",
  659. messageSends: ["outerContext:", "new", "class", "yourself"],
  660. referencedClasses: []
  661. }),
  662. smalltalk.AIContext);
  663. smalltalk.addMethod(
  664. smalltalk.method({
  665. selector: "outerContext",
  666. protocol: 'accessing',
  667. fn: function (){
  668. var self=this;
  669. return smalltalk.withContext(function($ctx1) {
  670. var $1;
  671. $1=self["@outerContext"];
  672. return $1;
  673. }, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.AIContext)})},
  674. args: [],
  675. source: "outerContext\x0a\x09^ outerContext",
  676. messageSends: [],
  677. referencedClasses: []
  678. }),
  679. smalltalk.AIContext);
  680. smalltalk.addMethod(
  681. smalltalk.method({
  682. selector: "outerContext:",
  683. protocol: 'accessing',
  684. fn: function (anAIContext){
  685. var self=this;
  686. return smalltalk.withContext(function($ctx1) {
  687. self["@outerContext"]=anAIContext;
  688. _st(self["@outerContext"])._innerContext_(self);
  689. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  690. args: ["anAIContext"],
  691. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext innerContext: self",
  692. messageSends: ["innerContext:"],
  693. referencedClasses: []
  694. }),
  695. smalltalk.AIContext);
  696. smalltalk.addMethod(
  697. smalltalk.method({
  698. selector: "receiver",
  699. protocol: 'interpreting',
  700. fn: function (){
  701. var self=this;
  702. return smalltalk.withContext(function($ctx1) {
  703. var $1;
  704. $1=self._localAt_("self");
  705. return $1;
  706. }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AIContext)})},
  707. args: [],
  708. source: "receiver\x0a\x09^ self localAt: 'self'",
  709. messageSends: ["localAt:"],
  710. referencedClasses: []
  711. }),
  712. smalltalk.AIContext);
  713. smalltalk.addMethod(
  714. smalltalk.method({
  715. selector: "receiver:",
  716. protocol: 'interpreting',
  717. fn: function (anObject){
  718. var self=this;
  719. return smalltalk.withContext(function($ctx1) {
  720. self._localAt_put_("self",anObject);
  721. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},smalltalk.AIContext)})},
  722. args: ["anObject"],
  723. source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
  724. messageSends: ["localAt:put:"],
  725. referencedClasses: []
  726. }),
  727. smalltalk.AIContext);
  728. smalltalk.addMethod(
  729. smalltalk.method({
  730. selector: "selector",
  731. protocol: 'accessing',
  732. fn: function (){
  733. var self=this;
  734. return smalltalk.withContext(function($ctx1) {
  735. var $1;
  736. $1=self["@selector"];
  737. return $1;
  738. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.AIContext)})},
  739. args: [],
  740. source: "selector\x0a\x09^ selector",
  741. messageSends: [],
  742. referencedClasses: []
  743. }),
  744. smalltalk.AIContext);
  745. smalltalk.addMethod(
  746. smalltalk.method({
  747. selector: "selector:",
  748. protocol: 'accessing',
  749. fn: function (aString){
  750. var self=this;
  751. return smalltalk.withContext(function($ctx1) {
  752. self["@selector"]=aString;
  753. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.AIContext)})},
  754. args: ["aString"],
  755. source: "selector: aString\x0a\x09selector := aString",
  756. messageSends: [],
  757. referencedClasses: []
  758. }),
  759. smalltalk.AIContext);
  760. smalltalk.addMethod(
  761. smalltalk.method({
  762. selector: "sendIndexAt:",
  763. protocol: 'accessing',
  764. fn: function (aString){
  765. var self=this;
  766. return smalltalk.withContext(function($ctx1) {
  767. var $1;
  768. $1=_st(self._sendIndexes())._at_ifAbsent_(aString,(function(){
  769. return smalltalk.withContext(function($ctx2) {
  770. return (0);
  771. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  772. return $1;
  773. }, function($ctx1) {$ctx1.fill(self,"sendIndexAt:",{aString:aString},smalltalk.AIContext)})},
  774. args: ["aString"],
  775. source: "sendIndexAt: aString\x0a\x09^ self sendIndexes at: aString ifAbsent: [ 0 ]",
  776. messageSends: ["at:ifAbsent:", "sendIndexes"],
  777. referencedClasses: []
  778. }),
  779. smalltalk.AIContext);
  780. smalltalk.addMethod(
  781. smalltalk.method({
  782. selector: "sendIndexes",
  783. protocol: 'accessing',
  784. fn: function (){
  785. var self=this;
  786. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  787. return smalltalk.withContext(function($ctx1) {
  788. var $2,$1;
  789. $2=self["@sendIndexes"];
  790. if(($receiver = $2) == nil || $receiver == null){
  791. $1=_st($Dictionary())._new();
  792. } else {
  793. $1=$2;
  794. };
  795. return $1;
  796. }, function($ctx1) {$ctx1.fill(self,"sendIndexes",{},smalltalk.AIContext)})},
  797. args: [],
  798. source: "sendIndexes\x0a\x09^ sendIndexes ifNil: [ Dictionary new ]",
  799. messageSends: ["ifNil:", "new"],
  800. referencedClasses: ["Dictionary"]
  801. }),
  802. smalltalk.AIContext);
  803. smalltalk.addMethod(
  804. smalltalk.method({
  805. selector: "sendIndexes:",
  806. protocol: 'accessing',
  807. fn: function (aDictionary){
  808. var self=this;
  809. return smalltalk.withContext(function($ctx1) {
  810. self["@sendIndexes"]=aDictionary;
  811. return self}, function($ctx1) {$ctx1.fill(self,"sendIndexes:",{aDictionary:aDictionary},smalltalk.AIContext)})},
  812. args: ["aDictionary"],
  813. source: "sendIndexes: aDictionary\x0a\x09sendIndexes := aDictionary",
  814. messageSends: [],
  815. referencedClasses: []
  816. }),
  817. smalltalk.AIContext);
  818. smalltalk.addMethod(
  819. smalltalk.method({
  820. selector: "setupInterpreter:",
  821. protocol: 'interpreting',
  822. fn: function (anInterpreter){
  823. var self=this;
  824. var currentNode;
  825. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  826. return smalltalk.withContext(function($ctx1) {
  827. var $1,$2,$5,$4,$3;
  828. $1=_st($ASTPCNodeVisitor())._new();
  829. _st($1)._selector_(self._evaluatedSelector());
  830. _st($1)._context_(self);
  831. _st($1)._visit_(self._ast());
  832. $2=_st($1)._currentNode();
  833. currentNode=$2;
  834. _st(anInterpreter)._node_(currentNode);
  835. $5=self._innerContext();
  836. $ctx1.sendIdx["innerContext"]=1;
  837. $4=_st($5)._arguments();
  838. $3=_st($4)._reversed();
  839. _st($3)._do_((function(each){
  840. return smalltalk.withContext(function($ctx2) {
  841. return _st(anInterpreter)._push_(each);
  842. $ctx2.sendIdx["push:"]=1;
  843. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  844. _st(anInterpreter)._push_(_st(self._innerContext())._receiver());
  845. return self}, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter,currentNode:currentNode},smalltalk.AIContext)})},
  846. args: ["anInterpreter"],
  847. source: "setupInterpreter: anInterpreter\x0a\x09| currentNode |\x0a\x09\x0a\x09\x22Retrieve the current node\x22\x0a\x09currentNode := ASTPCNodeVisitor new\x0a\x09\x09\x09selector: self evaluatedSelector;\x0a\x09\x09\x09context: self;\x0a\x09\x09\x09visit: self ast;\x0a\x09\x09\x09currentNode.\x0a\x09\x0a\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)",
  848. messageSends: ["selector:", "new", "evaluatedSelector", "context:", "visit:", "ast", "currentNode", "node:", "do:", "reversed", "arguments", "innerContext", "push:", "receiver"],
  849. referencedClasses: ["ASTPCNodeVisitor"]
  850. }),
  851. smalltalk.AIContext);
  852. smalltalk.addMethod(
  853. smalltalk.method({
  854. selector: "fromMethodContext:",
  855. protocol: 'instance creation',
  856. fn: function (aMethodContext){
  857. var self=this;
  858. return smalltalk.withContext(function($ctx1) {
  859. var $2,$3,$1;
  860. $2=self._new();
  861. _st($2)._initializeFromMethodContext_(aMethodContext);
  862. $3=_st($2)._yourself();
  863. $1=$3;
  864. return $1;
  865. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext.klass)})},
  866. args: ["aMethodContext"],
  867. source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
  868. messageSends: ["initializeFromMethodContext:", "new", "yourself"],
  869. referencedClasses: []
  870. }),
  871. smalltalk.AIContext.klass);
  872. smalltalk.addClass('ASTDebugger', smalltalk.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
  873. smalltalk.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.";
  874. smalltalk.addMethod(
  875. smalltalk.method({
  876. selector: "atEnd",
  877. protocol: 'testing',
  878. fn: function (){
  879. var self=this;
  880. return smalltalk.withContext(function($ctx1) {
  881. var $1;
  882. $1=_st(self._interpreter())._atEnd();
  883. return $1;
  884. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTDebugger)})},
  885. args: [],
  886. source: "atEnd\x0a\x09^ self interpreter atEnd",
  887. messageSends: ["atEnd", "interpreter"],
  888. referencedClasses: []
  889. }),
  890. smalltalk.ASTDebugger);
  891. smalltalk.addMethod(
  892. smalltalk.method({
  893. selector: "buildAST",
  894. protocol: 'initialization',
  895. fn: function (){
  896. var self=this;
  897. var ast;
  898. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  899. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  900. return smalltalk.withContext(function($ctx1) {
  901. var $1;
  902. ast=_st($Smalltalk())._parse_(_st(self._method())._source());
  903. _st(_st($SemanticAnalyzer())._on_(_st(_st(self._context())._receiver())._class()))._visit_(ast);
  904. $1=ast;
  905. return $1;
  906. }, function($ctx1) {$ctx1.fill(self,"buildAST",{ast:ast},smalltalk.ASTDebugger)})},
  907. args: [],
  908. source: "buildAST\x0a\x09\x22Build the AST tree from the method source code.\x0a\x09The AST is annotated with a SemanticAnalyzer,\x0a\x09to know the semantics and bindings of each node needed for later debugging\x22\x0a\x09\x0a\x09| ast |\x0a\x09\x0a\x09ast := Smalltalk parse: self method source.\x0a\x09(SemanticAnalyzer on: self context receiver class)\x0a\x09\x09visit: ast.\x0a\x09\x0a\x09^ ast",
  909. messageSends: ["parse:", "source", "method", "visit:", "on:", "class", "receiver", "context"],
  910. referencedClasses: ["Smalltalk", "SemanticAnalyzer"]
  911. }),
  912. smalltalk.ASTDebugger);
  913. smalltalk.addMethod(
  914. smalltalk.method({
  915. selector: "context",
  916. protocol: 'accessing',
  917. fn: function (){
  918. var self=this;
  919. return smalltalk.withContext(function($ctx1) {
  920. var $1;
  921. $1=self["@context"];
  922. return $1;
  923. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTDebugger)})},
  924. args: [],
  925. source: "context\x0a\x09^ context",
  926. messageSends: [],
  927. referencedClasses: []
  928. }),
  929. smalltalk.ASTDebugger);
  930. smalltalk.addMethod(
  931. smalltalk.method({
  932. selector: "context:",
  933. protocol: 'accessing',
  934. fn: function (aContext){
  935. var self=this;
  936. return smalltalk.withContext(function($ctx1) {
  937. self["@context"]=aContext;
  938. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger)})},
  939. args: ["aContext"],
  940. source: "context: aContext\x0a\x09context := aContext",
  941. messageSends: [],
  942. referencedClasses: []
  943. }),
  944. smalltalk.ASTDebugger);
  945. smalltalk.addMethod(
  946. smalltalk.method({
  947. selector: "defaultInterpreterClass",
  948. protocol: 'defaults',
  949. fn: function (){
  950. var self=this;
  951. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  952. return smalltalk.withContext(function($ctx1) {
  953. return $ASTInterpreter();
  954. }, function($ctx1) {$ctx1.fill(self,"defaultInterpreterClass",{},smalltalk.ASTDebugger)})},
  955. args: [],
  956. source: "defaultInterpreterClass\x0a\x09^ ASTInterpreter",
  957. messageSends: [],
  958. referencedClasses: ["ASTInterpreter"]
  959. }),
  960. smalltalk.ASTDebugger);
  961. smalltalk.addMethod(
  962. smalltalk.method({
  963. selector: "initializeInterpreter",
  964. protocol: 'initialization',
  965. fn: function (){
  966. var self=this;
  967. var ast,next;
  968. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  969. return smalltalk.withContext(function($ctx1) {
  970. var $1,$2;
  971. ast=self._buildAST();
  972. $1=_st($ASTPCNodeVisitor())._new();
  973. _st($1)._context_(self._context());
  974. _st($1)._visit_(ast);
  975. $2=_st($1)._currentNode();
  976. next=$2;
  977. _st(self._interpreter())._node_(next);
  978. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{ast:ast,next:next},smalltalk.ASTDebugger)})},
  979. args: [],
  980. source: "initializeInterpreter\x0a\x09| ast next |\x0a\x09ast := self buildAST.\x0a\x09next := ASTPCNodeVisitor new\x0a\x09\x09context: self context;\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode.\x0a\x09self interpreter node: next",
  981. messageSends: ["buildAST", "context:", "new", "context", "visit:", "currentNode", "node:", "interpreter"],
  982. referencedClasses: ["ASTPCNodeVisitor"]
  983. }),
  984. smalltalk.ASTDebugger);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "initializeWithContext:",
  988. protocol: 'initialization',
  989. fn: function (aContext){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. self._context_(aContext);
  993. self._initializeInterpreter();
  994. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:",{aContext:aContext},smalltalk.ASTDebugger)})},
  995. args: ["aContext"],
  996. source: "initializeWithContext: aContext\x0a\x09\x22TODO: do we need to handle block contexts?\x22\x0a\x09\x0a\x09self context: aContext.\x0a\x09self initializeInterpreter",
  997. messageSends: ["context:", "initializeInterpreter"],
  998. referencedClasses: []
  999. }),
  1000. smalltalk.ASTDebugger);
  1001. smalltalk.addMethod(
  1002. smalltalk.method({
  1003. selector: "interpreter",
  1004. protocol: 'accessing',
  1005. fn: function (){
  1006. var self=this;
  1007. return smalltalk.withContext(function($ctx1) {
  1008. var $2,$1;
  1009. $2=self["@interpreter"];
  1010. if(($receiver = $2) == nil || $receiver == null){
  1011. self["@interpreter"]=_st(self._defaultInterpreterClass())._new();
  1012. $1=self["@interpreter"];
  1013. } else {
  1014. $1=$2;
  1015. };
  1016. return $1;
  1017. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTDebugger)})},
  1018. args: [],
  1019. source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := self defaultInterpreterClass new ]",
  1020. messageSends: ["ifNil:", "new", "defaultInterpreterClass"],
  1021. referencedClasses: []
  1022. }),
  1023. smalltalk.ASTDebugger);
  1024. smalltalk.addMethod(
  1025. smalltalk.method({
  1026. selector: "interpreter:",
  1027. protocol: 'accessing',
  1028. fn: function (anInterpreter){
  1029. var self=this;
  1030. return smalltalk.withContext(function($ctx1) {
  1031. self["@interpreter"]=anInterpreter;
  1032. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.ASTDebugger)})},
  1033. args: ["anInterpreter"],
  1034. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  1035. messageSends: [],
  1036. referencedClasses: []
  1037. }),
  1038. smalltalk.ASTDebugger);
  1039. smalltalk.addMethod(
  1040. smalltalk.method({
  1041. selector: "method",
  1042. protocol: 'accessing',
  1043. fn: function (){
  1044. var self=this;
  1045. return smalltalk.withContext(function($ctx1) {
  1046. var $1;
  1047. $1=_st(self._context())._method();
  1048. return $1;
  1049. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.ASTDebugger)})},
  1050. args: [],
  1051. source: "method\x0a\x09^ self context method",
  1052. messageSends: ["method", "context"],
  1053. referencedClasses: []
  1054. }),
  1055. smalltalk.ASTDebugger);
  1056. smalltalk.addMethod(
  1057. smalltalk.method({
  1058. selector: "nextNode",
  1059. protocol: 'accessing',
  1060. fn: function (){
  1061. var self=this;
  1062. return smalltalk.withContext(function($ctx1) {
  1063. var $1;
  1064. $1=_st(self._interpreter())._nextNode();
  1065. return $1;
  1066. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTDebugger)})},
  1067. args: [],
  1068. source: "nextNode\x0a\x09^ self interpreter nextNode",
  1069. messageSends: ["nextNode", "interpreter"],
  1070. referencedClasses: []
  1071. }),
  1072. smalltalk.ASTDebugger);
  1073. smalltalk.addMethod(
  1074. smalltalk.method({
  1075. selector: "proceed",
  1076. protocol: 'stepping',
  1077. fn: function (){
  1078. var self=this;
  1079. return smalltalk.withContext(function($ctx1) {
  1080. self._shouldBeImplemented();
  1081. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTDebugger)})},
  1082. args: [],
  1083. source: "proceed\x0a\x09self shouldBeImplemented",
  1084. messageSends: ["shouldBeImplemented"],
  1085. referencedClasses: []
  1086. }),
  1087. smalltalk.ASTDebugger);
  1088. smalltalk.addMethod(
  1089. smalltalk.method({
  1090. selector: "restart",
  1091. protocol: 'stepping',
  1092. fn: function (){
  1093. var self=this;
  1094. return smalltalk.withContext(function($ctx1) {
  1095. _st(self._interpreter())._restart();
  1096. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTDebugger)})},
  1097. args: [],
  1098. source: "restart\x0a\x09self interpreter restart",
  1099. messageSends: ["restart", "interpreter"],
  1100. referencedClasses: []
  1101. }),
  1102. smalltalk.ASTDebugger);
  1103. smalltalk.addMethod(
  1104. smalltalk.method({
  1105. selector: "skip",
  1106. protocol: 'stepping',
  1107. fn: function (){
  1108. var self=this;
  1109. return smalltalk.withContext(function($ctx1) {
  1110. _st(self._interpreter())._skip();
  1111. return self}, function($ctx1) {$ctx1.fill(self,"skip",{},smalltalk.ASTDebugger)})},
  1112. args: [],
  1113. source: "skip\x0a\x09self interpreter skip",
  1114. messageSends: ["skip", "interpreter"],
  1115. referencedClasses: []
  1116. }),
  1117. smalltalk.ASTDebugger);
  1118. smalltalk.addMethod(
  1119. smalltalk.method({
  1120. selector: "stepInto",
  1121. protocol: 'stepping',
  1122. fn: function (){
  1123. var self=this;
  1124. return smalltalk.withContext(function($ctx1) {
  1125. self._shouldBeImplemented();
  1126. return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},smalltalk.ASTDebugger)})},
  1127. args: [],
  1128. source: "stepInto\x0a\x09self shouldBeImplemented",
  1129. messageSends: ["shouldBeImplemented"],
  1130. referencedClasses: []
  1131. }),
  1132. smalltalk.ASTDebugger);
  1133. smalltalk.addMethod(
  1134. smalltalk.method({
  1135. selector: "stepOver",
  1136. protocol: 'stepping',
  1137. fn: function (){
  1138. var self=this;
  1139. return smalltalk.withContext(function($ctx1) {
  1140. _st(self._interpreter())._stepOver();
  1141. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTDebugger)})},
  1142. args: [],
  1143. source: "stepOver\x0a\x09self interpreter stepOver",
  1144. messageSends: ["stepOver", "interpreter"],
  1145. referencedClasses: []
  1146. }),
  1147. smalltalk.ASTDebugger);
  1148. smalltalk.addMethod(
  1149. smalltalk.method({
  1150. selector: "context:",
  1151. protocol: 'instance creation',
  1152. fn: function (aContext){
  1153. var self=this;
  1154. return smalltalk.withContext(function($ctx1) {
  1155. var $2,$3,$1;
  1156. $2=self._new();
  1157. _st($2)._initializeWithContext_(aContext);
  1158. $3=_st($2)._yourself();
  1159. $1=$3;
  1160. return $1;
  1161. }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger.klass)})},
  1162. args: ["aContext"],
  1163. source: "context: aContext\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext;\x0a\x09\x09yourself",
  1164. messageSends: ["initializeWithContext:", "new", "yourself"],
  1165. referencedClasses: []
  1166. }),
  1167. smalltalk.ASTDebugger.klass);
  1168. smalltalk.addClass('ASTInterpreter', smalltalk.NodeVisitor, ['node', 'context', 'stack', 'returnValue', 'returned'], 'Compiler-Interpreter');
  1169. smalltalk.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";
  1170. smalltalk.addMethod(
  1171. smalltalk.method({
  1172. selector: "assign:to:",
  1173. protocol: 'private',
  1174. fn: function (aNode,anObject){
  1175. var self=this;
  1176. return smalltalk.withContext(function($ctx1) {
  1177. var $1,$3,$2,$4;
  1178. $1=_st(_st(aNode)._binding())._isInstanceVar();
  1179. if(smalltalk.assert($1)){
  1180. $3=self._context();
  1181. $ctx1.sendIdx["context"]=1;
  1182. $2=_st($3)._receiver();
  1183. $4=_st(aNode)._value();
  1184. $ctx1.sendIdx["value"]=1;
  1185. _st($2)._instVarAt_put_($4,anObject);
  1186. } else {
  1187. _st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
  1188. };
  1189. return self}, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.ASTInterpreter)})},
  1190. args: ["aNode", "anObject"],
  1191. 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 ]",
  1192. messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
  1193. referencedClasses: []
  1194. }),
  1195. smalltalk.ASTInterpreter);
  1196. smalltalk.addMethod(
  1197. smalltalk.method({
  1198. selector: "atEnd",
  1199. protocol: 'testing',
  1200. fn: function (){
  1201. var self=this;
  1202. return smalltalk.withContext(function($ctx1) {
  1203. var $1;
  1204. $1=_st(self._hasReturned())._or_((function(){
  1205. return smalltalk.withContext(function($ctx2) {
  1206. return _st(self._node())._isNil();
  1207. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1208. return $1;
  1209. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTInterpreter)})},
  1210. args: [],
  1211. source: "atEnd\x0a\x09^ self hasReturned or: [ self node isNil ]",
  1212. messageSends: ["or:", "hasReturned", "isNil", "node"],
  1213. referencedClasses: []
  1214. }),
  1215. smalltalk.ASTInterpreter);
  1216. smalltalk.addMethod(
  1217. smalltalk.method({
  1218. selector: "context",
  1219. protocol: 'accessing',
  1220. fn: function (){
  1221. var self=this;
  1222. return smalltalk.withContext(function($ctx1) {
  1223. var $1;
  1224. $1=self["@context"];
  1225. return $1;
  1226. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTInterpreter)})},
  1227. args: [],
  1228. source: "context\x0a\x09^ context",
  1229. messageSends: [],
  1230. referencedClasses: []
  1231. }),
  1232. smalltalk.ASTInterpreter);
  1233. smalltalk.addMethod(
  1234. smalltalk.method({
  1235. selector: "context:",
  1236. protocol: 'accessing',
  1237. fn: function (aContext){
  1238. var self=this;
  1239. return smalltalk.withContext(function($ctx1) {
  1240. self["@context"]=aContext;
  1241. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTInterpreter)})},
  1242. args: ["aContext"],
  1243. source: "context: aContext\x0a\x09context := aContext",
  1244. messageSends: [],
  1245. referencedClasses: []
  1246. }),
  1247. smalltalk.ASTInterpreter);
  1248. smalltalk.addMethod(
  1249. smalltalk.method({
  1250. selector: "eval:",
  1251. protocol: 'private',
  1252. fn: function (aString){
  1253. var self=this;
  1254. var source,function_;
  1255. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1256. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1257. return smalltalk.withContext(function($ctx1) {
  1258. var $3,$2,$1,$4,$5;
  1259. source=_st($String())._streamContents_((function(str){
  1260. return smalltalk.withContext(function($ctx2) {
  1261. _st(str)._nextPutAll_("(function(");
  1262. $ctx2.sendIdx["nextPutAll:"]=1;
  1263. $3=self._context();
  1264. $ctx2.sendIdx["context"]=1;
  1265. $2=_st($3)._locals();
  1266. $ctx2.sendIdx["locals"]=1;
  1267. $1=_st($2)._keys();
  1268. _st($1)._do_separatedBy_((function(each){
  1269. return smalltalk.withContext(function($ctx3) {
  1270. return _st(str)._nextPutAll_(each);
  1271. $ctx3.sendIdx["nextPutAll:"]=2;
  1272. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
  1273. return smalltalk.withContext(function($ctx3) {
  1274. return _st(str)._nextPutAll_(",");
  1275. $ctx3.sendIdx["nextPutAll:"]=3;
  1276. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1277. _st(str)._nextPutAll_("){ return (function() {");
  1278. $ctx2.sendIdx["nextPutAll:"]=4;
  1279. _st(str)._nextPutAll_(aString);
  1280. $ctx2.sendIdx["nextPutAll:"]=5;
  1281. $4=_st(str)._nextPutAll_("})() })");
  1282. return $4;
  1283. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
  1284. function_=_st(_st($Compiler())._new())._eval_(source);
  1285. $5=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
  1286. return $5;
  1287. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.ASTInterpreter)})},
  1288. args: ["aString"],
  1289. 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: '(function('.\x0a\x09\x09self context locals keys\x0a\x09\x09\x09do: [ :each | str nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ str nextPutAll: ',' ].\x0a\x09\x09str\x0a\x09\x09\x09nextPutAll: '){ return (function() {';\x0a\x09\x09\x09nextPutAll: aString;\x0a\x09\x09\x09nextPutAll: '})() })' ].\x0a\x09\x09\x09\x0a\x09function := Compiler new eval: source.\x0a\x09\x0a\x09^ function valueWithPossibleArguments: self context locals values",
  1290. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  1291. referencedClasses: ["String", "Compiler"]
  1292. }),
  1293. smalltalk.ASTInterpreter);
  1294. smalltalk.addMethod(
  1295. smalltalk.method({
  1296. selector: "hasReturned",
  1297. protocol: 'testing',
  1298. fn: function (){
  1299. var self=this;
  1300. return smalltalk.withContext(function($ctx1) {
  1301. var $2,$1;
  1302. $2=self["@returned"];
  1303. if(($receiver = $2) == nil || $receiver == null){
  1304. $1=false;
  1305. } else {
  1306. $1=$2;
  1307. };
  1308. return $1;
  1309. }, function($ctx1) {$ctx1.fill(self,"hasReturned",{},smalltalk.ASTInterpreter)})},
  1310. args: [],
  1311. source: "hasReturned\x0a\x09^ returned ifNil: [ false ]",
  1312. messageSends: ["ifNil:"],
  1313. referencedClasses: []
  1314. }),
  1315. smalltalk.ASTInterpreter);
  1316. smalltalk.addMethod(
  1317. smalltalk.method({
  1318. selector: "interpret",
  1319. protocol: 'interpreting',
  1320. fn: function (){
  1321. var self=this;
  1322. return smalltalk.withContext(function($ctx1) {
  1323. self._visit_(self._node());
  1324. return self}, function($ctx1) {$ctx1.fill(self,"interpret",{},smalltalk.ASTInterpreter)})},
  1325. args: [],
  1326. source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
  1327. messageSends: ["visit:", "node"],
  1328. referencedClasses: []
  1329. }),
  1330. smalltalk.ASTInterpreter);
  1331. smalltalk.addMethod(
  1332. smalltalk.method({
  1333. selector: "interpret:",
  1334. protocol: 'interpreting',
  1335. fn: function (aNode){
  1336. var self=this;
  1337. return smalltalk.withContext(function($ctx1) {
  1338. self._node_(aNode);
  1339. self._interpret();
  1340. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1341. args: ["aNode"],
  1342. source: "interpret: aNode\x0a\x09self node: aNode.\x0a\x09self interpret",
  1343. messageSends: ["node:", "interpret"],
  1344. referencedClasses: []
  1345. }),
  1346. smalltalk.ASTInterpreter);
  1347. smalltalk.addMethod(
  1348. smalltalk.method({
  1349. selector: "messageFromSendNode:arguments:",
  1350. protocol: 'private',
  1351. fn: function (aSendNode,aCollection){
  1352. var self=this;
  1353. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  1354. return smalltalk.withContext(function($ctx1) {
  1355. var $2,$3,$1;
  1356. $2=_st($Message())._new();
  1357. _st($2)._selector_(_st(aSendNode)._selector());
  1358. _st($2)._arguments_(aCollection);
  1359. $3=_st($2)._yourself();
  1360. $1=$3;
  1361. return $1;
  1362. }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},smalltalk.ASTInterpreter)})},
  1363. args: ["aSendNode", "aCollection"],
  1364. source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
  1365. messageSends: ["selector:", "new", "selector", "arguments:", "yourself"],
  1366. referencedClasses: ["Message"]
  1367. }),
  1368. smalltalk.ASTInterpreter);
  1369. smalltalk.addMethod(
  1370. smalltalk.method({
  1371. selector: "messageNotUnderstood:receiver:",
  1372. protocol: 'private',
  1373. fn: function (aMessage,anObject){
  1374. var self=this;
  1375. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  1376. return smalltalk.withContext(function($ctx1) {
  1377. var $1,$2;
  1378. $1=_st($MessageNotUnderstood())._new();
  1379. _st($1)._meesage_(aMessage);
  1380. _st($1)._receiver_(anObject);
  1381. $2=_st($1)._signal();
  1382. return self}, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},smalltalk.ASTInterpreter)})},
  1383. args: ["aMessage", "anObject"],
  1384. source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09meesage: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
  1385. messageSends: ["meesage:", "new", "receiver:", "signal"],
  1386. referencedClasses: ["MessageNotUnderstood"]
  1387. }),
  1388. smalltalk.ASTInterpreter);
  1389. smalltalk.addMethod(
  1390. smalltalk.method({
  1391. selector: "next",
  1392. protocol: 'interpreting',
  1393. fn: function (){
  1394. var self=this;
  1395. return smalltalk.withContext(function($ctx1) {
  1396. self._node_(_st(self._node())._nextNode());
  1397. return self}, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.ASTInterpreter)})},
  1398. args: [],
  1399. source: "next\x0a\x09self node: self node nextNode",
  1400. messageSends: ["node:", "nextNode", "node"],
  1401. referencedClasses: []
  1402. }),
  1403. smalltalk.ASTInterpreter);
  1404. smalltalk.addMethod(
  1405. smalltalk.method({
  1406. selector: "node",
  1407. protocol: 'accessing',
  1408. fn: function (){
  1409. var self=this;
  1410. return smalltalk.withContext(function($ctx1) {
  1411. var $1;
  1412. $1=self["@node"];
  1413. return $1;
  1414. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.ASTInterpreter)})},
  1415. args: [],
  1416. source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
  1417. messageSends: [],
  1418. referencedClasses: []
  1419. }),
  1420. smalltalk.ASTInterpreter);
  1421. smalltalk.addMethod(
  1422. smalltalk.method({
  1423. selector: "node:",
  1424. protocol: 'accessing',
  1425. fn: function (aNode){
  1426. var self=this;
  1427. return smalltalk.withContext(function($ctx1) {
  1428. self["@node"]=aNode;
  1429. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1430. args: ["aNode"],
  1431. source: "node: aNode\x0a\x09node := aNode",
  1432. messageSends: [],
  1433. referencedClasses: []
  1434. }),
  1435. smalltalk.ASTInterpreter);
  1436. smalltalk.addMethod(
  1437. smalltalk.method({
  1438. selector: "peek",
  1439. protocol: 'stack',
  1440. fn: function (){
  1441. var self=this;
  1442. return smalltalk.withContext(function($ctx1) {
  1443. var $1,$2;
  1444. var $early={};
  1445. try {
  1446. $1=self._stack();
  1447. $ctx1.sendIdx["stack"]=1;
  1448. _st($1)._ifEmpty_((function(){
  1449. return smalltalk.withContext(function($ctx2) {
  1450. throw $early=[nil];
  1451. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1452. $2=_st(self._stack())._last();
  1453. return $2;
  1454. }
  1455. catch(e) {if(e===$early)return e[0]; throw e}
  1456. }, function($ctx1) {$ctx1.fill(self,"peek",{},smalltalk.ASTInterpreter)})},
  1457. args: [],
  1458. 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",
  1459. messageSends: ["ifEmpty:", "stack", "last"],
  1460. referencedClasses: []
  1461. }),
  1462. smalltalk.ASTInterpreter);
  1463. smalltalk.addMethod(
  1464. smalltalk.method({
  1465. selector: "pop",
  1466. protocol: 'stack',
  1467. fn: function (){
  1468. var self=this;
  1469. var peekedValue;
  1470. return smalltalk.withContext(function($ctx1) {
  1471. var $1;
  1472. peekedValue=self._peek();
  1473. _st(self._stack())._removeLast();
  1474. $1=peekedValue;
  1475. return $1;
  1476. }, function($ctx1) {$ctx1.fill(self,"pop",{peekedValue:peekedValue},smalltalk.ASTInterpreter)})},
  1477. args: [],
  1478. 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",
  1479. messageSends: ["peek", "removeLast", "stack"],
  1480. referencedClasses: []
  1481. }),
  1482. smalltalk.ASTInterpreter);
  1483. smalltalk.addMethod(
  1484. smalltalk.method({
  1485. selector: "proceed",
  1486. protocol: 'interpreting',
  1487. fn: function (){
  1488. var self=this;
  1489. return smalltalk.withContext(function($ctx1) {
  1490. _st((function(){
  1491. return smalltalk.withContext(function($ctx2) {
  1492. return self._atEnd();
  1493. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1494. return smalltalk.withContext(function($ctx2) {
  1495. return self._step();
  1496. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1497. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTInterpreter)})},
  1498. args: [],
  1499. source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] \x0a\x09\x09whileFalse: [ self step ]",
  1500. messageSends: ["whileFalse:", "atEnd", "step"],
  1501. referencedClasses: []
  1502. }),
  1503. smalltalk.ASTInterpreter);
  1504. smalltalk.addMethod(
  1505. smalltalk.method({
  1506. selector: "push:",
  1507. protocol: 'stack',
  1508. fn: function (anObject){
  1509. var self=this;
  1510. return smalltalk.withContext(function($ctx1) {
  1511. var $1;
  1512. $1=_st(self._stack())._add_(anObject);
  1513. return $1;
  1514. }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},smalltalk.ASTInterpreter)})},
  1515. args: ["anObject"],
  1516. source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
  1517. messageSends: ["add:", "stack"],
  1518. referencedClasses: []
  1519. }),
  1520. smalltalk.ASTInterpreter);
  1521. smalltalk.addMethod(
  1522. smalltalk.method({
  1523. selector: "restart",
  1524. protocol: 'interpreting',
  1525. fn: function (){
  1526. var self=this;
  1527. return smalltalk.withContext(function($ctx1) {
  1528. self._node_(_st(_st(self._context())._ast())._nextChild());
  1529. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTInterpreter)})},
  1530. args: [],
  1531. source: "restart\x0a\x09self node: self context ast nextChild",
  1532. messageSends: ["node:", "nextChild", "ast", "context"],
  1533. referencedClasses: []
  1534. }),
  1535. smalltalk.ASTInterpreter);
  1536. smalltalk.addMethod(
  1537. smalltalk.method({
  1538. selector: "result",
  1539. protocol: 'accessing',
  1540. fn: function (){
  1541. var self=this;
  1542. return smalltalk.withContext(function($ctx1) {
  1543. var $2,$1;
  1544. $2=self._hasReturned();
  1545. if(smalltalk.assert($2)){
  1546. $1=self._returnValue();
  1547. } else {
  1548. $1=_st(self._context())._receiver();
  1549. };
  1550. return $1;
  1551. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ASTInterpreter)})},
  1552. args: [],
  1553. source: "result\x0a\x09^ self hasReturned \x0a\x09\x09ifTrue: [ self returnValue ] \x0a\x09\x09ifFalse: [ self context receiver ]",
  1554. messageSends: ["ifTrue:ifFalse:", "hasReturned", "returnValue", "receiver", "context"],
  1555. referencedClasses: []
  1556. }),
  1557. smalltalk.ASTInterpreter);
  1558. smalltalk.addMethod(
  1559. smalltalk.method({
  1560. selector: "returnValue",
  1561. protocol: 'accessing',
  1562. fn: function (){
  1563. var self=this;
  1564. return smalltalk.withContext(function($ctx1) {
  1565. var $1;
  1566. $1=self["@returnValue"];
  1567. return $1;
  1568. }, function($ctx1) {$ctx1.fill(self,"returnValue",{},smalltalk.ASTInterpreter)})},
  1569. args: [],
  1570. source: "returnValue\x0a\x09^ returnValue",
  1571. messageSends: [],
  1572. referencedClasses: []
  1573. }),
  1574. smalltalk.ASTInterpreter);
  1575. smalltalk.addMethod(
  1576. smalltalk.method({
  1577. selector: "returnValue:",
  1578. protocol: 'accessing',
  1579. fn: function (anObject){
  1580. var self=this;
  1581. return smalltalk.withContext(function($ctx1) {
  1582. self["@returnValue"]=anObject;
  1583. return self}, function($ctx1) {$ctx1.fill(self,"returnValue:",{anObject:anObject},smalltalk.ASTInterpreter)})},
  1584. args: ["anObject"],
  1585. source: "returnValue: anObject\x0a\x09returnValue := anObject",
  1586. messageSends: [],
  1587. referencedClasses: []
  1588. }),
  1589. smalltalk.ASTInterpreter);
  1590. smalltalk.addMethod(
  1591. smalltalk.method({
  1592. selector: "sendMessage:to:superSend:",
  1593. protocol: 'private',
  1594. fn: function (aMessage,anObject,aBoolean){
  1595. var self=this;
  1596. var method;
  1597. return smalltalk.withContext(function($ctx1) {
  1598. var $1,$3,$2,$4,$5,$6;
  1599. var $early={};
  1600. try {
  1601. if(! smalltalk.assert(aBoolean)){
  1602. $1=_st(aMessage)._sendTo_(anObject);
  1603. return $1;
  1604. };
  1605. $3=_st(anObject)._class();
  1606. $ctx1.sendIdx["class"]=1;
  1607. $2=_st($3)._superclass();
  1608. $ctx1.sendIdx["superclass"]=1;
  1609. if(($receiver = $2) == nil || $receiver == null){
  1610. $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1611. $ctx1.sendIdx["messageNotUnderstood:receiver:"]=1;
  1612. return $4;
  1613. } else {
  1614. $2;
  1615. };
  1616. method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
  1617. return smalltalk.withContext(function($ctx2) {
  1618. $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1619. throw $early=[$5];
  1620. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  1621. $6=_st(method)._sendTo_arguments_(anObject,_st(aMessage)._arguments());
  1622. return $6;
  1623. }
  1624. catch(e) {if(e===$early)return e[0]; throw e}
  1625. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.ASTInterpreter)})},
  1626. args: ["aMessage", "anObject", "aBoolean"],
  1627. source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method sendTo: anObject arguments: aMessage arguments",
  1628. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "sendTo:arguments:", "arguments"],
  1629. referencedClasses: []
  1630. }),
  1631. smalltalk.ASTInterpreter);
  1632. smalltalk.addMethod(
  1633. smalltalk.method({
  1634. selector: "setNonLocalReturnFromContext:",
  1635. protocol: 'interpreting',
  1636. fn: function (aContext){
  1637. var self=this;
  1638. return smalltalk.withContext(function($ctx1) {
  1639. var $2,$1;
  1640. $2=_st(aContext)._interpreter();
  1641. $ctx1.sendIdx["interpreter"]=1;
  1642. $1=_st($2)._hasReturned();
  1643. if(smalltalk.assert($1)){
  1644. self["@returned"]=true;
  1645. self["@returned"];
  1646. self._returnValue_(_st(_st(aContext)._interpreter())._returnValue());
  1647. };
  1648. return self}, function($ctx1) {$ctx1.fill(self,"setNonLocalReturnFromContext:",{aContext:aContext},smalltalk.ASTInterpreter)})},
  1649. args: ["aContext"],
  1650. source: "setNonLocalReturnFromContext: aContext\x0a\x09aContext interpreter hasReturned ifTrue: [\x0a\x09\x09returned := true.\x0a\x09\x09self returnValue: aContext interpreter returnValue ]",
  1651. messageSends: ["ifTrue:", "hasReturned", "interpreter", "returnValue:", "returnValue"],
  1652. referencedClasses: []
  1653. }),
  1654. smalltalk.ASTInterpreter);
  1655. smalltalk.addMethod(
  1656. smalltalk.method({
  1657. selector: "skip",
  1658. protocol: 'interpreting',
  1659. fn: function (){
  1660. var self=this;
  1661. return smalltalk.withContext(function($ctx1) {
  1662. self._next();
  1663. return self}, function($ctx1) {$ctx1.fill(self,"skip",{},smalltalk.ASTInterpreter)})},
  1664. args: [],
  1665. source: "skip\x0a\x09self next",
  1666. messageSends: ["next"],
  1667. referencedClasses: []
  1668. }),
  1669. smalltalk.ASTInterpreter);
  1670. smalltalk.addMethod(
  1671. smalltalk.method({
  1672. selector: "stack",
  1673. protocol: 'accessing',
  1674. fn: function (){
  1675. var self=this;
  1676. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1677. return smalltalk.withContext(function($ctx1) {
  1678. var $2,$1;
  1679. $2=self["@stack"];
  1680. if(($receiver = $2) == nil || $receiver == null){
  1681. self["@stack"]=_st($OrderedCollection())._new();
  1682. $1=self["@stack"];
  1683. } else {
  1684. $1=$2;
  1685. };
  1686. return $1;
  1687. }, function($ctx1) {$ctx1.fill(self,"stack",{},smalltalk.ASTInterpreter)})},
  1688. args: [],
  1689. source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
  1690. messageSends: ["ifNil:", "new"],
  1691. referencedClasses: ["OrderedCollection"]
  1692. }),
  1693. smalltalk.ASTInterpreter);
  1694. smalltalk.addMethod(
  1695. smalltalk.method({
  1696. selector: "step",
  1697. protocol: 'interpreting',
  1698. fn: function (){
  1699. var self=this;
  1700. return smalltalk.withContext(function($ctx1) {
  1701. var $1;
  1702. self._interpret();
  1703. $1=self._next();
  1704. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTInterpreter)})},
  1705. args: [],
  1706. source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
  1707. messageSends: ["interpret", "next"],
  1708. referencedClasses: []
  1709. }),
  1710. smalltalk.ASTInterpreter);
  1711. smalltalk.addMethod(
  1712. smalltalk.method({
  1713. selector: "stepOver",
  1714. protocol: 'interpreting',
  1715. fn: function (){
  1716. var self=this;
  1717. return smalltalk.withContext(function($ctx1) {
  1718. self._step();
  1719. $ctx1.sendIdx["step"]=1;
  1720. _st((function(){
  1721. return smalltalk.withContext(function($ctx2) {
  1722. return _st(self._node())._isSteppingNode();
  1723. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1724. return smalltalk.withContext(function($ctx2) {
  1725. return self._step();
  1726. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1727. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTInterpreter)})},
  1728. args: [],
  1729. source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isSteppingNode ] whileFalse: [ \x0a\x09\x09self step ]",
  1730. messageSends: ["step", "whileFalse:", "isSteppingNode", "node"],
  1731. referencedClasses: []
  1732. }),
  1733. smalltalk.ASTInterpreter);
  1734. smalltalk.addMethod(
  1735. smalltalk.method({
  1736. selector: "visit:",
  1737. protocol: 'visiting',
  1738. fn: function (aNode){
  1739. var self=this;
  1740. return smalltalk.withContext(function($ctx1) {
  1741. var $1;
  1742. $1=self._hasReturned();
  1743. if(! smalltalk.assert($1)){
  1744. smalltalk.ASTInterpreter.superclass.fn.prototype._visit_.apply(_st(self), [aNode]);
  1745. };
  1746. return self}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1747. args: ["aNode"],
  1748. source: "visit: aNode\x0a\x09self hasReturned ifFalse: [ super visit: aNode ]",
  1749. messageSends: ["ifFalse:", "hasReturned", "visit:"],
  1750. referencedClasses: []
  1751. }),
  1752. smalltalk.ASTInterpreter);
  1753. smalltalk.addMethod(
  1754. smalltalk.method({
  1755. selector: "visitAssignmentNode:",
  1756. protocol: 'visiting',
  1757. fn: function (aNode){
  1758. var self=this;
  1759. var poppedValue;
  1760. return smalltalk.withContext(function($ctx1) {
  1761. poppedValue=self._pop();
  1762. $ctx1.sendIdx["pop"]=1;
  1763. self._pop();
  1764. self._push_(poppedValue);
  1765. self._assign_to_(_st(aNode)._left(),poppedValue);
  1766. return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,poppedValue:poppedValue},smalltalk.ASTInterpreter)})},
  1767. args: ["aNode"],
  1768. 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",
  1769. messageSends: ["pop", "push:", "assign:to:", "left"],
  1770. referencedClasses: []
  1771. }),
  1772. smalltalk.ASTInterpreter);
  1773. smalltalk.addMethod(
  1774. smalltalk.method({
  1775. selector: "visitBlockNode:",
  1776. protocol: 'visiting',
  1777. fn: function (aNode){
  1778. var self=this;
  1779. var block;
  1780. function $AIBlockClosure(){return smalltalk.AIBlockClosure||(typeof AIBlockClosure=="undefined"?nil:AIBlockClosure)}
  1781. return smalltalk.withContext(function($ctx1) {
  1782. block=_st($AIBlockClosure())._forContext_node_(self._context(),aNode);
  1783. self._push_(block);
  1784. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,block:block},smalltalk.ASTInterpreter)})},
  1785. args: ["aNode"],
  1786. 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",
  1787. messageSends: ["forContext:node:", "context", "push:"],
  1788. referencedClasses: ["AIBlockClosure"]
  1789. }),
  1790. smalltalk.ASTInterpreter);
  1791. smalltalk.addMethod(
  1792. smalltalk.method({
  1793. selector: "visitDynamicArrayNode:",
  1794. protocol: 'visiting',
  1795. fn: function (aNode){
  1796. var self=this;
  1797. var array;
  1798. return smalltalk.withContext(function($ctx1) {
  1799. array=[];
  1800. _st(_st(aNode)._nodes())._do_((function(each){
  1801. return smalltalk.withContext(function($ctx2) {
  1802. return _st(array)._addFirst_(self._pop());
  1803. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1804. self._push_(array);
  1805. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},smalltalk.ASTInterpreter)})},
  1806. args: ["aNode"],
  1807. source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09\x0a\x09array := #().\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09array addFirst: self pop ].\x0a\x09\x0a\x09self push: array",
  1808. messageSends: ["do:", "nodes", "addFirst:", "pop", "push:"],
  1809. referencedClasses: []
  1810. }),
  1811. smalltalk.ASTInterpreter);
  1812. smalltalk.addMethod(
  1813. smalltalk.method({
  1814. selector: "visitDynamicDictionaryNode:",
  1815. protocol: 'visiting',
  1816. fn: function (aNode){
  1817. var self=this;
  1818. var associations,hashedCollection;
  1819. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1820. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1821. return smalltalk.withContext(function($ctx1) {
  1822. associations=_st($OrderedCollection())._new();
  1823. $ctx1.sendIdx["new"]=1;
  1824. hashedCollection=_st($HashedCollection())._new();
  1825. _st(_st(aNode)._nodes())._do_((function(each){
  1826. return smalltalk.withContext(function($ctx2) {
  1827. return _st(associations)._add_(self._pop());
  1828. $ctx2.sendIdx["add:"]=1;
  1829. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1830. $ctx1.sendIdx["do:"]=1;
  1831. _st(_st(associations)._reversed())._do_((function(each){
  1832. return smalltalk.withContext(function($ctx2) {
  1833. return _st(hashedCollection)._add_(each);
  1834. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1835. self._push_(hashedCollection);
  1836. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,associations:associations,hashedCollection:hashedCollection},smalltalk.ASTInterpreter)})},
  1837. args: ["aNode"],
  1838. source: "visitDynamicDictionaryNode: aNode\x0a\x09| associations hashedCollection |\x0a\x09\x0a\x09associations := OrderedCollection new.\x0a\x09hashedCollection := HashedCollection new.\x0a\x09\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09associations add: self pop ].\x0a\x09\x0a\x09associations reversed do: [ :each |\x0a\x09\x09hashedCollection add: each ].\x0a\x09\x0a\x09self push: hashedCollection",
  1839. messageSends: ["new", "do:", "nodes", "add:", "pop", "reversed", "push:"],
  1840. referencedClasses: ["OrderedCollection", "HashedCollection"]
  1841. }),
  1842. smalltalk.ASTInterpreter);
  1843. smalltalk.addMethod(
  1844. smalltalk.method({
  1845. selector: "visitJSStatementNode:",
  1846. protocol: 'visiting',
  1847. fn: function (aNode){
  1848. var self=this;
  1849. return smalltalk.withContext(function($ctx1) {
  1850. self["@returned"]=true;
  1851. self._returnValue_(self._eval_(_st(aNode)._source()));
  1852. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1853. args: ["aNode"],
  1854. source: "visitJSStatementNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: (self eval: aNode source)",
  1855. messageSends: ["returnValue:", "eval:", "source"],
  1856. referencedClasses: []
  1857. }),
  1858. smalltalk.ASTInterpreter);
  1859. smalltalk.addMethod(
  1860. smalltalk.method({
  1861. selector: "visitNode:",
  1862. protocol: 'visiting',
  1863. fn: function (aNode){
  1864. var self=this;
  1865. return smalltalk.withContext(function($ctx1) {
  1866. return self}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1867. args: ["aNode"],
  1868. source: "visitNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
  1869. messageSends: [],
  1870. referencedClasses: []
  1871. }),
  1872. smalltalk.ASTInterpreter);
  1873. smalltalk.addMethod(
  1874. smalltalk.method({
  1875. selector: "visitReturnNode:",
  1876. protocol: 'visiting',
  1877. fn: function (aNode){
  1878. var self=this;
  1879. return smalltalk.withContext(function($ctx1) {
  1880. self["@returned"]=true;
  1881. self._returnValue_(self._pop());
  1882. return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1883. args: ["aNode"],
  1884. source: "visitReturnNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: self pop",
  1885. messageSends: ["returnValue:", "pop"],
  1886. referencedClasses: []
  1887. }),
  1888. smalltalk.ASTInterpreter);
  1889. smalltalk.addMethod(
  1890. smalltalk.method({
  1891. selector: "visitSendNode:",
  1892. protocol: 'visiting',
  1893. fn: function (aNode){
  1894. var self=this;
  1895. var receiver,args,message,result;
  1896. return smalltalk.withContext(function($ctx1) {
  1897. var $1;
  1898. args=_st(_st(aNode)._arguments())._collect_((function(each){
  1899. return smalltalk.withContext(function($ctx2) {
  1900. return self._pop();
  1901. $ctx2.sendIdx["pop"]=1;
  1902. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1903. receiver=self._pop();
  1904. message=self._messageFromSendNode_arguments_(aNode,_st(args)._reversed());
  1905. result=self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend());
  1906. $1=_st(_st(aNode)._isCascadeSendNode())._and_((function(){
  1907. return smalltalk.withContext(function($ctx2) {
  1908. return _st(_st(aNode)._isLastChild())._not();
  1909. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1910. if(smalltalk.assert($1)){
  1911. self._push_(receiver);
  1912. $ctx1.sendIdx["push:"]=1;
  1913. } else {
  1914. self._push_(result);
  1915. };
  1916. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},smalltalk.ASTInterpreter)})},
  1917. args: ["aNode"],
  1918. source: "visitSendNode: aNode\x0a\x09| receiver args message result |\x0a\x09\x0a\x09args := aNode arguments collect: [ :each | self pop ].\x0a\x09receiver := self pop.\x0a\x09\x0a\x09message := self\x0a\x09\x09messageFromSendNode: aNode\x0a\x09\x09arguments: args reversed.\x0a\x09\x0a\x09result := self sendMessage: message to: receiver superSend: aNode superSend.\x0a\x09\x0a\x09\x22For cascade sends, push the reciever if the send is not the last one\x22\x0a\x09(aNode isCascadeSendNode and: [ aNode isLastChild not ])\x0a\x09\x09ifTrue: [ self push: receiver ]\x0a\x09\x09ifFalse: [ self push: result ]",
  1919. messageSends: ["collect:", "arguments", "pop", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "ifTrue:ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"],
  1920. referencedClasses: []
  1921. }),
  1922. smalltalk.ASTInterpreter);
  1923. smalltalk.addMethod(
  1924. smalltalk.method({
  1925. selector: "visitValueNode:",
  1926. protocol: 'visiting',
  1927. fn: function (aNode){
  1928. var self=this;
  1929. return smalltalk.withContext(function($ctx1) {
  1930. self._push_(_st(aNode)._value());
  1931. return self}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1932. args: ["aNode"],
  1933. source: "visitValueNode: aNode\x0a\x09self push: aNode value",
  1934. messageSends: ["push:", "value"],
  1935. referencedClasses: []
  1936. }),
  1937. smalltalk.ASTInterpreter);
  1938. smalltalk.addMethod(
  1939. smalltalk.method({
  1940. selector: "visitVariableNode:",
  1941. protocol: 'visiting',
  1942. fn: function (aNode){
  1943. var self=this;
  1944. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1945. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1946. return smalltalk.withContext(function($ctx1) {
  1947. var $2,$1,$5,$6,$4,$3,$8,$10,$9,$11,$12,$13,$15,$14,$16,$17,$7;
  1948. $2=_st(aNode)._binding();
  1949. $ctx1.sendIdx["binding"]=1;
  1950. $1=_st($2)._isUnknownVar();
  1951. if(smalltalk.assert($1)){
  1952. $5=_st($PlatformInterface())._globals();
  1953. $ctx1.sendIdx["globals"]=1;
  1954. $6=_st(aNode)._value();
  1955. $ctx1.sendIdx["value"]=1;
  1956. $4=_st($5)._at_ifAbsent_($6,(function(){
  1957. return smalltalk.withContext(function($ctx2) {
  1958. return self._error_("Unknown variable");
  1959. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1960. $ctx1.sendIdx["at:ifAbsent:"]=1;
  1961. $3=self._push_($4);
  1962. $ctx1.sendIdx["push:"]=1;
  1963. return $3;
  1964. };
  1965. $8=_st(_st(aNode)._binding())._isInstanceVar();
  1966. if(smalltalk.assert($8)){
  1967. $10=self._context();
  1968. $ctx1.sendIdx["context"]=1;
  1969. $9=_st($10)._receiver();
  1970. $11=_st(aNode)._value();
  1971. $ctx1.sendIdx["value"]=2;
  1972. $7=_st($9)._instVarAt_($11);
  1973. } else {
  1974. $12=self._context();
  1975. $13=_st(aNode)._value();
  1976. $ctx1.sendIdx["value"]=3;
  1977. $7=_st($12)._localAt_ifAbsent_($13,(function(){
  1978. return smalltalk.withContext(function($ctx2) {
  1979. $15=_st(aNode)._value();
  1980. $ctx2.sendIdx["value"]=4;
  1981. $14=_st($15)._isCapitalized();
  1982. if(smalltalk.assert($14)){
  1983. $16=_st($Smalltalk())._globals();
  1984. $ctx2.sendIdx["globals"]=2;
  1985. $17=_st(aNode)._value();
  1986. $ctx2.sendIdx["value"]=5;
  1987. return _st($16)._at_ifAbsent_($17,(function(){
  1988. return smalltalk.withContext(function($ctx3) {
  1989. return _st(_st($PlatformInterface())._globals())._at_(_st(aNode)._value());
  1990. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)})}));
  1991. };
  1992. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}));
  1993. };
  1994. self._push_($7);
  1995. return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1996. args: ["aNode"],
  1997. source: "visitVariableNode: aNode\x0a\x09aNode binding isUnknownVar ifTrue: [\x0a\x09\x09^ self push: (PlatformInterface globals at: aNode value ifAbsent: [ self error: 'Unknown variable' ]) ].\x0a\x09\x09\x0a\x09self push: (aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09ifFalse: [ self context \x0a\x09\x09\x09localAt: aNode value\x0a\x09\x09\x09ifAbsent: [\x0a\x09\x09\x09\x09aNode value isCapitalized\x0a\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09Smalltalk globals \x0a\x09\x09\x09\x09\x09\x09\x09at: aNode value \x0a\x09\x09\x09\x09\x09\x09\x09ifAbsent: [ PlatformInterface globals at: aNode value ] ] ] ])",
  1998. messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "globals", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:ifAbsent:", "isCapitalized", "at:"],
  1999. referencedClasses: ["PlatformInterface", "Smalltalk"]
  2000. }),
  2001. smalltalk.ASTInterpreter);
  2002. smalltalk.addClass('ASTInterpreterError', smalltalk.Error, [], 'Compiler-Interpreter');
  2003. smalltalk.ASTInterpreterError.comment="I get signaled when an AST interpreter is unable to interpret a node.";
  2004. smalltalk.addClass('ASTPCNodeVisitor', smalltalk.NodeVisitor, ['context', 'index', 'selector', 'currentNode'], 'Compiler-Interpreter');
  2005. smalltalk.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`";
  2006. smalltalk.addMethod(
  2007. smalltalk.method({
  2008. selector: "context",
  2009. protocol: 'accessing',
  2010. fn: function (){
  2011. var self=this;
  2012. return smalltalk.withContext(function($ctx1) {
  2013. var $1;
  2014. $1=self["@context"];
  2015. return $1;
  2016. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTPCNodeVisitor)})},
  2017. args: [],
  2018. source: "context\x0a\x09^ context",
  2019. messageSends: [],
  2020. referencedClasses: []
  2021. }),
  2022. smalltalk.ASTPCNodeVisitor);
  2023. smalltalk.addMethod(
  2024. smalltalk.method({
  2025. selector: "context:",
  2026. protocol: 'accessing',
  2027. fn: function (aContext){
  2028. var self=this;
  2029. return smalltalk.withContext(function($ctx1) {
  2030. self["@context"]=aContext;
  2031. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTPCNodeVisitor)})},
  2032. args: ["aContext"],
  2033. source: "context: aContext\x0a\x09context := aContext",
  2034. messageSends: [],
  2035. referencedClasses: []
  2036. }),
  2037. smalltalk.ASTPCNodeVisitor);
  2038. smalltalk.addMethod(
  2039. smalltalk.method({
  2040. selector: "currentNode",
  2041. protocol: 'accessing',
  2042. fn: function (){
  2043. var self=this;
  2044. return smalltalk.withContext(function($ctx1) {
  2045. var $1;
  2046. $1=self["@currentNode"];
  2047. return $1;
  2048. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTPCNodeVisitor)})},
  2049. args: [],
  2050. source: "currentNode\x0a\x09^ currentNode",
  2051. messageSends: [],
  2052. referencedClasses: []
  2053. }),
  2054. smalltalk.ASTPCNodeVisitor);
  2055. smalltalk.addMethod(
  2056. smalltalk.method({
  2057. selector: "increaseIndex",
  2058. protocol: 'accessing',
  2059. fn: function (){
  2060. var self=this;
  2061. return smalltalk.withContext(function($ctx1) {
  2062. self["@index"]=_st(self._index()).__plus((1));
  2063. return self}, function($ctx1) {$ctx1.fill(self,"increaseIndex",{},smalltalk.ASTPCNodeVisitor)})},
  2064. args: [],
  2065. source: "increaseIndex\x0a\x09index := self index + 1",
  2066. messageSends: ["+", "index"],
  2067. referencedClasses: []
  2068. }),
  2069. smalltalk.ASTPCNodeVisitor);
  2070. smalltalk.addMethod(
  2071. smalltalk.method({
  2072. selector: "index",
  2073. protocol: 'accessing',
  2074. fn: function (){
  2075. var self=this;
  2076. return smalltalk.withContext(function($ctx1) {
  2077. var $2,$1;
  2078. $2=self["@index"];
  2079. if(($receiver = $2) == nil || $receiver == null){
  2080. self["@index"]=(0);
  2081. $1=self["@index"];
  2082. } else {
  2083. $1=$2;
  2084. };
  2085. return $1;
  2086. }, function($ctx1) {$ctx1.fill(self,"index",{},smalltalk.ASTPCNodeVisitor)})},
  2087. args: [],
  2088. source: "index\x0a\x09^ index ifNil: [ index := 0 ]",
  2089. messageSends: ["ifNil:"],
  2090. referencedClasses: []
  2091. }),
  2092. smalltalk.ASTPCNodeVisitor);
  2093. smalltalk.addMethod(
  2094. smalltalk.method({
  2095. selector: "selector",
  2096. protocol: 'accessing',
  2097. fn: function (){
  2098. var self=this;
  2099. return smalltalk.withContext(function($ctx1) {
  2100. var $1;
  2101. $1=self["@selector"];
  2102. return $1;
  2103. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.ASTPCNodeVisitor)})},
  2104. args: [],
  2105. source: "selector\x0a\x09^ selector",
  2106. messageSends: [],
  2107. referencedClasses: []
  2108. }),
  2109. smalltalk.ASTPCNodeVisitor);
  2110. smalltalk.addMethod(
  2111. smalltalk.method({
  2112. selector: "selector:",
  2113. protocol: 'accessing',
  2114. fn: function (aString){
  2115. var self=this;
  2116. return smalltalk.withContext(function($ctx1) {
  2117. self["@selector"]=aString;
  2118. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.ASTPCNodeVisitor)})},
  2119. args: ["aString"],
  2120. source: "selector: aString\x0a\x09selector := aString",
  2121. messageSends: [],
  2122. referencedClasses: []
  2123. }),
  2124. smalltalk.ASTPCNodeVisitor);
  2125. smalltalk.addMethod(
  2126. smalltalk.method({
  2127. selector: "visitJSStatementNode:",
  2128. protocol: 'visiting',
  2129. fn: function (aNode){
  2130. var self=this;
  2131. return smalltalk.withContext(function($ctx1) {
  2132. self["@currentNode"]=aNode;
  2133. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2134. args: ["aNode"],
  2135. 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",
  2136. messageSends: [],
  2137. referencedClasses: []
  2138. }),
  2139. smalltalk.ASTPCNodeVisitor);
  2140. smalltalk.addMethod(
  2141. smalltalk.method({
  2142. selector: "visitSendNode:",
  2143. protocol: 'visiting',
  2144. fn: function (aNode){
  2145. var self=this;
  2146. var sendIndex;
  2147. return smalltalk.withContext(function($ctx1) {
  2148. var $1,$2,$4,$3,$6,$5,$7;
  2149. $1=self._context();
  2150. $2=self._selector();
  2151. $ctx1.sendIdx["selector"]=1;
  2152. sendIndex=_st($1)._sendIndexAt_($2);
  2153. smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  2154. $4=self._selector();
  2155. $ctx1.sendIdx["selector"]=2;
  2156. $3=_st($4).__eq(_st(aNode)._selector());
  2157. if(smalltalk.assert($3)){
  2158. $6=self._index();
  2159. $ctx1.sendIdx["index"]=1;
  2160. $5=_st($6).__lt(sendIndex);
  2161. if(! smalltalk.assert($5)){
  2162. $7=_st(self._index()).__gt(sendIndex);
  2163. if(! smalltalk.assert($7)){
  2164. self["@currentNode"]=aNode;
  2165. self["@currentNode"];
  2166. };
  2167. };
  2168. self._increaseIndex();
  2169. };
  2170. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,sendIndex:sendIndex},smalltalk.ASTPCNodeVisitor)})},
  2171. args: ["aNode"],
  2172. source: "visitSendNode: aNode\x0a\x09| sendIndex |\x0a\x09sendIndex := self context sendIndexAt: self selector.\x0a\x09\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self selector = aNode selector ifTrue: [\x0a\x09\x09self index < sendIndex ifFalse: [ \x0a\x09\x09\x09self index > sendIndex ifFalse: [ currentNode := aNode ] ].\x0a\x09\x09self increaseIndex ]",
  2173. messageSends: ["sendIndexAt:", "context", "selector", "visitSendNode:", "ifTrue:", "=", "ifFalse:", "<", "index", ">", "increaseIndex"],
  2174. referencedClasses: []
  2175. }),
  2176. smalltalk.ASTPCNodeVisitor);
  2177. smalltalk.addMethod(
  2178. smalltalk.method({
  2179. selector: "isSteppingNode",
  2180. protocol: '*Compiler-Interpreter',
  2181. fn: function (){
  2182. var self=this;
  2183. return smalltalk.withContext(function($ctx1) {
  2184. return false;
  2185. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
  2186. args: [],
  2187. source: "isSteppingNode\x0a\x09^ false",
  2188. messageSends: [],
  2189. referencedClasses: []
  2190. }),
  2191. smalltalk.Node);
  2192. smalltalk.addMethod(
  2193. smalltalk.method({
  2194. selector: "isSteppingNode",
  2195. protocol: '*Compiler-Interpreter',
  2196. fn: function (){
  2197. var self=this;
  2198. return smalltalk.withContext(function($ctx1) {
  2199. return true;
  2200. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.AssignmentNode)})},
  2201. args: [],
  2202. source: "isSteppingNode\x0a\x09^ true",
  2203. messageSends: [],
  2204. referencedClasses: []
  2205. }),
  2206. smalltalk.AssignmentNode);
  2207. smalltalk.addMethod(
  2208. smalltalk.method({
  2209. selector: "isSteppingNode",
  2210. protocol: '*Compiler-Interpreter',
  2211. fn: function (){
  2212. var self=this;
  2213. return smalltalk.withContext(function($ctx1) {
  2214. return true;
  2215. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
  2216. args: [],
  2217. source: "isSteppingNode\x0a\x09^ true",
  2218. messageSends: [],
  2219. referencedClasses: []
  2220. }),
  2221. smalltalk.BlockNode);
  2222. smalltalk.addMethod(
  2223. smalltalk.method({
  2224. selector: "isSteppingNode",
  2225. protocol: '*Compiler-Interpreter',
  2226. fn: function (){
  2227. var self=this;
  2228. return smalltalk.withContext(function($ctx1) {
  2229. return true;
  2230. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
  2231. args: [],
  2232. source: "isSteppingNode\x0a\x09^ true",
  2233. messageSends: [],
  2234. referencedClasses: []
  2235. }),
  2236. smalltalk.DynamicArrayNode);
  2237. smalltalk.addMethod(
  2238. smalltalk.method({
  2239. selector: "isSteppingNode",
  2240. protocol: '*Compiler-Interpreter',
  2241. fn: function (){
  2242. var self=this;
  2243. return smalltalk.withContext(function($ctx1) {
  2244. return true;
  2245. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
  2246. args: [],
  2247. source: "isSteppingNode\x0a\x09^ true",
  2248. messageSends: [],
  2249. referencedClasses: []
  2250. }),
  2251. smalltalk.DynamicDictionaryNode);
  2252. smalltalk.addMethod(
  2253. smalltalk.method({
  2254. selector: "isSteppingNode",
  2255. protocol: '*Compiler-Interpreter',
  2256. fn: function (){
  2257. var self=this;
  2258. return smalltalk.withContext(function($ctx1) {
  2259. return true;
  2260. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
  2261. args: [],
  2262. source: "isSteppingNode\x0a\x09^ true",
  2263. messageSends: [],
  2264. referencedClasses: []
  2265. }),
  2266. smalltalk.JSStatementNode);
  2267. smalltalk.addMethod(
  2268. smalltalk.method({
  2269. selector: "isSteppingNode",
  2270. protocol: '*Compiler-Interpreter',
  2271. fn: function (){
  2272. var self=this;
  2273. return smalltalk.withContext(function($ctx1) {
  2274. return true;
  2275. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
  2276. args: [],
  2277. source: "isSteppingNode\x0a\x09^ true",
  2278. messageSends: [],
  2279. referencedClasses: []
  2280. }),
  2281. smalltalk.SendNode);
  2282. });