Compiler-Interpreter.js 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693
  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/Kernel-Exceptions", "amber_core/Compiler-Core", "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. category: '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. category: '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. category: '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. category: '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. category: 'error handling',
  71. fn: function (){
  72. var self=this;
  73. function $AIInterpreterError(){return smalltalk.AIInterpreterError||(typeof AIInterpreterError=="undefined"?nil:AIInterpreterError)}
  74. return smalltalk.withContext(function($ctx1) {
  75. _st($AIInterpreterError())._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\x09AIInterpreterError signal: 'Method cannot be interpreted by the interpreter.'",
  79. messageSends: ["signal:"],
  80. referencedClasses: ["AIInterpreterError"]
  81. }),
  82. smalltalk.AIBlockClosure);
  83. smalltalk.addMethod(
  84. smalltalk.method({
  85. selector: "numArgs",
  86. category: '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. category: '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. category: '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. category: '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. category: '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. category: '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;
  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. _st($3)._node_(_st(sequenceNode)._nextChild());
  191. $4=_st($3)._proceed();
  192. _st(_st(self["@outerContext"])._interpreter())._setNonLocalReturnFromContext_(context);
  193. $5=_st(_st(context)._interpreter())._pop();
  194. return $5;
  195. }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection,context:context,sequenceNode:sequenceNode},smalltalk.AIBlockClosure)})},
  196. args: ["aCollection"],
  197. 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",
  198. messageSends: ["newBlockContext", "parent:", "copy", "first", "nodes", "yourself", "withIndexDo:", "parameters", "localAt:put:", "at:ifAbsent:", "node:", "interpreter", "nextChild", "proceed", "setNonLocalReturnFromContext:", "pop"],
  199. referencedClasses: []
  200. }),
  201. smalltalk.AIBlockClosure);
  202. smalltalk.addMethod(
  203. smalltalk.method({
  204. selector: "forContext:node:",
  205. category: 'instance creation',
  206. fn: function (aContext,aNode){
  207. var self=this;
  208. return smalltalk.withContext(function($ctx1) {
  209. var $2,$3,$1;
  210. $2=self._new();
  211. _st($2)._initializeWithContext_node_(aContext,aNode);
  212. $3=_st($2)._yourself();
  213. $1=$3;
  214. return $1;
  215. }, function($ctx1) {$ctx1.fill(self,"forContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure.klass)})},
  216. args: ["aContext", "aNode"],
  217. source: "forContext: aContext node: aNode\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext node: aNode;\x0a\x09\x09yourself",
  218. messageSends: ["initializeWithContext:node:", "new", "yourself"],
  219. referencedClasses: []
  220. }),
  221. smalltalk.AIBlockClosure.klass);
  222. smalltalk.addClass('AIContext', smalltalk.Object, ['outerContext', 'innerContext', 'pc', 'locals', 'method', 'index', 'ast', 'interpreter'], 'Compiler-Interpreter');
  223. 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)";
  224. smalltalk.addMethod(
  225. smalltalk.method({
  226. selector: "arguments",
  227. category: 'interpreting',
  228. fn: function (){
  229. var self=this;
  230. return smalltalk.withContext(function($ctx1) {
  231. var $1;
  232. $1=_st(_st(self._ast())._arguments())._collect_((function(each){
  233. return smalltalk.withContext(function($ctx2) {
  234. return self._localAt_(each);
  235. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  236. return $1;
  237. }, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.AIContext)})},
  238. args: [],
  239. source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ]",
  240. messageSends: ["collect:", "arguments", "ast", "localAt:"],
  241. referencedClasses: []
  242. }),
  243. smalltalk.AIContext);
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "asString",
  247. category: 'converting',
  248. fn: function (){
  249. var self=this;
  250. return smalltalk.withContext(function($ctx1) {
  251. var $2,$1;
  252. $2=self._isBlockContext();
  253. if(smalltalk.assert($2)){
  254. $1=_st("a block (in ".__comma(_st(self._methodContext())._asString())).__comma(")");
  255. } else {
  256. $1=_st(_st(_st(_st(self._receiver())._class())._name()).__comma(" >> ")).__comma(self._selector());
  257. };
  258. return $1;
  259. }, function($ctx1) {$ctx1.fill(self,"asString",{},smalltalk.AIContext)})},
  260. args: [],
  261. source: "asString\x0a\x09^self isBlockContext\x0a\x09\x09ifTrue: [ 'a block (in ', self methodContext asString, ')' ]\x0a\x09\x09ifFalse: [ self receiver class name, ' >> ', self selector ]",
  262. messageSends: ["ifTrue:ifFalse:", "isBlockContext", ",", "asString", "methodContext", "name", "class", "receiver", "selector"],
  263. referencedClasses: []
  264. }),
  265. smalltalk.AIContext);
  266. smalltalk.addMethod(
  267. smalltalk.method({
  268. selector: "ast",
  269. category: 'interpreting',
  270. fn: function (){
  271. var self=this;
  272. return smalltalk.withContext(function($ctx1) {
  273. var $1,$2,$3,$4;
  274. $1=self._isBlockContext();
  275. if(smalltalk.assert($1)){
  276. $2=_st(self._outerContext())._ast();
  277. return $2;
  278. };
  279. $3=self["@ast"];
  280. if(($receiver = $3) == nil || $receiver == undefined){
  281. self._initializeAST();
  282. } else {
  283. $3;
  284. };
  285. $4=self["@ast"];
  286. return $4;
  287. }, function($ctx1) {$ctx1.fill(self,"ast",{},smalltalk.AIContext)})},
  288. args: [],
  289. source: "ast\x0a\x09self isBlockContext ifTrue: [ ^ self outerContext ast ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
  290. messageSends: ["ifTrue:", "isBlockContext", "ast", "outerContext", "ifNil:", "initializeAST"],
  291. referencedClasses: []
  292. }),
  293. smalltalk.AIContext);
  294. smalltalk.addMethod(
  295. smalltalk.method({
  296. selector: "index",
  297. category: 'accessing',
  298. fn: function (){
  299. var self=this;
  300. return smalltalk.withContext(function($ctx1) {
  301. var $2,$1;
  302. $2=self["@index"];
  303. if(($receiver = $2) == nil || $receiver == undefined){
  304. $1=(0);
  305. } else {
  306. $1=$2;
  307. };
  308. return $1;
  309. }, function($ctx1) {$ctx1.fill(self,"index",{},smalltalk.AIContext)})},
  310. args: [],
  311. source: "index\x0a\x09^ index ifNil: [ 0 ]",
  312. messageSends: ["ifNil:"],
  313. referencedClasses: []
  314. }),
  315. smalltalk.AIContext);
  316. smalltalk.addMethod(
  317. smalltalk.method({
  318. selector: "index:",
  319. category: 'accessing',
  320. fn: function (anInteger){
  321. var self=this;
  322. return smalltalk.withContext(function($ctx1) {
  323. self["@index"]=anInteger;
  324. return self}, function($ctx1) {$ctx1.fill(self,"index:",{anInteger:anInteger},smalltalk.AIContext)})},
  325. args: ["anInteger"],
  326. source: "index: anInteger\x0a\x09index := anInteger",
  327. messageSends: [],
  328. referencedClasses: []
  329. }),
  330. smalltalk.AIContext);
  331. smalltalk.addMethod(
  332. smalltalk.method({
  333. selector: "initializeAST",
  334. category: 'initialization',
  335. fn: function (){
  336. var self=this;
  337. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  338. return smalltalk.withContext(function($ctx1) {
  339. self["@ast"]=_st(self._method())._ast();
  340. _st(_st($SemanticAnalyzer())._on_(_st(self._method())._methodClass()))._visit_(self["@ast"]);
  341. return self}, function($ctx1) {$ctx1.fill(self,"initializeAST",{},smalltalk.AIContext)})},
  342. args: [],
  343. source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
  344. messageSends: ["ast", "method", "visit:", "on:", "methodClass"],
  345. referencedClasses: ["SemanticAnalyzer"]
  346. }),
  347. smalltalk.AIContext);
  348. smalltalk.addMethod(
  349. smalltalk.method({
  350. selector: "initializeFromMethodContext:",
  351. category: 'initialization',
  352. fn: function (aMethodContext){
  353. var self=this;
  354. return smalltalk.withContext(function($ctx1) {
  355. var $1,$2,$3,$4;
  356. $1=self;
  357. _st($1)._pc_(_st(aMethodContext)._pc());
  358. _st($1)._index_(_st(aMethodContext)._index());
  359. _st($1)._receiver_(_st(aMethodContext)._receiver());
  360. $2=_st($1)._method_(_st(aMethodContext)._method());
  361. $3=_st(aMethodContext)._outerContext();
  362. if(($receiver = $3) == nil || $receiver == undefined){
  363. $3;
  364. } else {
  365. var outer;
  366. outer=$receiver;
  367. $4=_st(outer)._methodContext();
  368. if(($receiver = $4) == nil || $receiver == undefined){
  369. $4;
  370. } else {
  371. self._outerContext_(_st(self._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
  372. };
  373. _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
  374. return smalltalk.withContext(function($ctx2) {
  375. return _st(self._locals())._at_put_(key,value);
  376. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)})}));
  377. };
  378. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext)})},
  379. args: ["aMethodContext"],
  380. source: "initializeFromMethodContext: aMethodContext\x0a\x0a\x09self \x0a\x09\x09pc: aMethodContext pc;\x0a\x09\x09index: aMethodContext index;\x0a\x09\x09receiver: aMethodContext receiver;\x0a\x09\x09method: aMethodContext method.\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 ] ]",
  381. messageSends: ["pc:", "pc", "index:", "index", "receiver:", "receiver", "method:", "method", "ifNotNil:", "outerContext", "methodContext", "outerContext:", "fromMethodContext:", "class", "keysAndValuesDo:", "locals", "at:put:"],
  382. referencedClasses: []
  383. }),
  384. smalltalk.AIContext);
  385. smalltalk.addMethod(
  386. smalltalk.method({
  387. selector: "initializeInterpreter",
  388. category: 'initialization',
  389. fn: function (){
  390. var self=this;
  391. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  392. return smalltalk.withContext(function($ctx1) {
  393. var $1,$2,$3,$4;
  394. $1=_st($ASTInterpreter())._new();
  395. _st($1)._context_(self);
  396. $2=_st($1)._yourself();
  397. self["@interpreter"]=$2;
  398. $3=self["@ast"];
  399. if(($receiver = $3) == nil || $receiver == undefined){
  400. $3;
  401. } else {
  402. _st(self["@interpreter"])._node_(self._retrieveNode());
  403. };
  404. $4=_st(_st(self._innerContext())._notNil())._and_((function(){
  405. return smalltalk.withContext(function($ctx2) {
  406. return _st(_st(self._innerContext())._isBlockContext())._not();
  407. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  408. if(smalltalk.assert($4)){
  409. self._setupInterpreter_(self["@interpreter"]);
  410. };
  411. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},smalltalk.AIContext)})},
  412. args: [],
  413. source: "initializeInterpreter\x0a\x09interpreter := ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09yourself.\x0a\x09ast ifNotNil: [ interpreter node: self retrieveNode ].\x0a\x09\x0a\x09(self innerContext notNil and: [ \x0a\x09\x09self innerContext isBlockContext not ]) ifTrue: [\x0a\x09\x09\x09self setupInterpreter: interpreter ]",
  414. messageSends: ["context:", "new", "yourself", "ifNotNil:", "node:", "retrieveNode", "ifTrue:", "and:", "notNil", "innerContext", "not", "isBlockContext", "setupInterpreter:"],
  415. referencedClasses: ["ASTInterpreter"]
  416. }),
  417. smalltalk.AIContext);
  418. smalltalk.addMethod(
  419. smalltalk.method({
  420. selector: "initializeLocals",
  421. category: 'initialization',
  422. fn: function (){
  423. var self=this;
  424. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  425. return smalltalk.withContext(function($ctx1) {
  426. self["@locals"]=_st($Dictionary())._new();
  427. _st(self["@locals"])._at_put_("thisContext",self);
  428. return self}, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},smalltalk.AIContext)})},
  429. args: [],
  430. source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
  431. messageSends: ["new", "at:put:"],
  432. referencedClasses: ["Dictionary"]
  433. }),
  434. smalltalk.AIContext);
  435. smalltalk.addMethod(
  436. smalltalk.method({
  437. selector: "innerContext",
  438. category: 'accessing',
  439. fn: function (){
  440. var self=this;
  441. return smalltalk.withContext(function($ctx1) {
  442. var $1;
  443. $1=self["@innerContext"];
  444. return $1;
  445. }, function($ctx1) {$ctx1.fill(self,"innerContext",{},smalltalk.AIContext)})},
  446. args: [],
  447. source: "innerContext\x0a\x09^ innerContext",
  448. messageSends: [],
  449. referencedClasses: []
  450. }),
  451. smalltalk.AIContext);
  452. smalltalk.addMethod(
  453. smalltalk.method({
  454. selector: "innerContext:",
  455. category: 'accessing',
  456. fn: function (anAIContext){
  457. var self=this;
  458. return smalltalk.withContext(function($ctx1) {
  459. self["@innerContext"]=anAIContext;
  460. return self}, function($ctx1) {$ctx1.fill(self,"innerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  461. args: ["anAIContext"],
  462. source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
  463. messageSends: [],
  464. referencedClasses: []
  465. }),
  466. smalltalk.AIContext);
  467. smalltalk.addMethod(
  468. smalltalk.method({
  469. selector: "interpreter",
  470. category: 'interpreting',
  471. fn: function (){
  472. var self=this;
  473. return smalltalk.withContext(function($ctx1) {
  474. var $1,$2;
  475. $1=self["@interpreter"];
  476. if(($receiver = $1) == nil || $receiver == undefined){
  477. self._initializeInterpreter();
  478. } else {
  479. $1;
  480. };
  481. $2=self["@interpreter"];
  482. return $2;
  483. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AIContext)})},
  484. args: [],
  485. source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
  486. messageSends: ["ifNil:", "initializeInterpreter"],
  487. referencedClasses: []
  488. }),
  489. smalltalk.AIContext);
  490. smalltalk.addMethod(
  491. smalltalk.method({
  492. selector: "interpreter:",
  493. category: 'interpreting',
  494. fn: function (anInterpreter){
  495. var self=this;
  496. return smalltalk.withContext(function($ctx1) {
  497. self["@interpreter"]=anInterpreter;
  498. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
  499. args: ["anInterpreter"],
  500. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  501. messageSends: [],
  502. referencedClasses: []
  503. }),
  504. smalltalk.AIContext);
  505. smalltalk.addMethod(
  506. smalltalk.method({
  507. selector: "isBlockContext",
  508. category: 'testing',
  509. fn: function (){
  510. var self=this;
  511. return smalltalk.withContext(function($ctx1) {
  512. var $1;
  513. $1=_st(self._selector())._isNil();
  514. return $1;
  515. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},smalltalk.AIContext)})},
  516. args: [],
  517. source: "isBlockContext\x0a\x09\x22Block context do not have selectors.\x22\x0a\x09\x0a\x09^ self selector isNil",
  518. messageSends: ["isNil", "selector"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.AIContext);
  522. smalltalk.addMethod(
  523. smalltalk.method({
  524. selector: "localAt:",
  525. category: 'accessing',
  526. fn: function (aString){
  527. var self=this;
  528. return smalltalk.withContext(function($ctx1) {
  529. var $2,$1;
  530. $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
  531. return smalltalk.withContext(function($ctx2) {
  532. $2=self._isBlockContext();
  533. if(smalltalk.assert($2)){
  534. return nil;
  535. } else {
  536. return _st(self._outerContext())._localAt_(aString);
  537. };
  538. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  539. return $1;
  540. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},smalltalk.AIContext)})},
  541. args: ["aString"],
  542. 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 isBlockContext \x0a\x09\x09\x09ifTrue: [ nil ]\x0a\x09\x09\x09ifFalse: [ self outerContext localAt: aString ] ]",
  543. messageSends: ["at:ifAbsent:", "locals", "ifTrue:ifFalse:", "isBlockContext", "localAt:", "outerContext"],
  544. referencedClasses: []
  545. }),
  546. smalltalk.AIContext);
  547. smalltalk.addMethod(
  548. smalltalk.method({
  549. selector: "localAt:put:",
  550. category: 'accessing',
  551. fn: function (aString,anObject){
  552. var self=this;
  553. return smalltalk.withContext(function($ctx1) {
  554. _st(self._locals())._at_put_(aString,anObject);
  555. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},smalltalk.AIContext)})},
  556. args: ["aString", "anObject"],
  557. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  558. messageSends: ["at:put:", "locals"],
  559. referencedClasses: []
  560. }),
  561. smalltalk.AIContext);
  562. smalltalk.addMethod(
  563. smalltalk.method({
  564. selector: "locals",
  565. category: 'accessing',
  566. fn: function (){
  567. var self=this;
  568. return smalltalk.withContext(function($ctx1) {
  569. var $1,$2;
  570. $1=self["@locals"];
  571. if(($receiver = $1) == nil || $receiver == undefined){
  572. self._initializeLocals();
  573. } else {
  574. $1;
  575. };
  576. $2=self["@locals"];
  577. return $2;
  578. }, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.AIContext)})},
  579. args: [],
  580. source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
  581. messageSends: ["ifNil:", "initializeLocals"],
  582. referencedClasses: []
  583. }),
  584. smalltalk.AIContext);
  585. smalltalk.addMethod(
  586. smalltalk.method({
  587. selector: "method",
  588. category: 'accessing',
  589. fn: function (){
  590. var self=this;
  591. return smalltalk.withContext(function($ctx1) {
  592. var $1;
  593. $1=self["@method"];
  594. return $1;
  595. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.AIContext)})},
  596. args: [],
  597. source: "method\x0a\x09^ method",
  598. messageSends: [],
  599. referencedClasses: []
  600. }),
  601. smalltalk.AIContext);
  602. smalltalk.addMethod(
  603. smalltalk.method({
  604. selector: "method:",
  605. category: 'accessing',
  606. fn: function (aCompiledMethod){
  607. var self=this;
  608. return smalltalk.withContext(function($ctx1) {
  609. self["@method"]=aCompiledMethod;
  610. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod},smalltalk.AIContext)})},
  611. args: ["aCompiledMethod"],
  612. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  613. messageSends: [],
  614. referencedClasses: []
  615. }),
  616. smalltalk.AIContext);
  617. smalltalk.addMethod(
  618. smalltalk.method({
  619. selector: "methodContext",
  620. category: 'accessing',
  621. fn: function (){
  622. var self=this;
  623. return smalltalk.withContext(function($ctx1) {
  624. var $1,$2,$4,$3;
  625. $1=self._isBlockContext();
  626. if(! smalltalk.assert($1)){
  627. $2=self;
  628. return $2;
  629. };
  630. $4=self._outerContext();
  631. if(($receiver = $4) == nil || $receiver == undefined){
  632. $3=$4;
  633. } else {
  634. var outer;
  635. outer=$receiver;
  636. $3=_st(outer)._methodContext();
  637. };
  638. return $3;
  639. }, function($ctx1) {$ctx1.fill(self,"methodContext",{},smalltalk.AIContext)})},
  640. args: [],
  641. source: "methodContext\x0a\x09self isBlockContext ifFalse: [ ^ self ].\x0a\x09\x0a\x09^ self outerContext ifNotNil: [ :outer |\x0a\x09\x09outer methodContext ]",
  642. messageSends: ["ifFalse:", "isBlockContext", "ifNotNil:", "outerContext", "methodContext"],
  643. referencedClasses: []
  644. }),
  645. smalltalk.AIContext);
  646. smalltalk.addMethod(
  647. smalltalk.method({
  648. selector: "newBlockContext",
  649. category: 'factory',
  650. fn: function (){
  651. var self=this;
  652. return smalltalk.withContext(function($ctx1) {
  653. var $2,$3,$1;
  654. $2=_st(self._class())._new();
  655. _st($2)._outerContext_(self);
  656. $3=_st($2)._yourself();
  657. $1=$3;
  658. return $1;
  659. }, function($ctx1) {$ctx1.fill(self,"newBlockContext",{},smalltalk.AIContext)})},
  660. args: [],
  661. source: "newBlockContext\x0a\x09^ self class new\x0a\x09\x09outerContext: self;\x0a\x09\x09yourself",
  662. messageSends: ["outerContext:", "new", "class", "yourself"],
  663. referencedClasses: []
  664. }),
  665. smalltalk.AIContext);
  666. smalltalk.addMethod(
  667. smalltalk.method({
  668. selector: "outerContext",
  669. category: 'accessing',
  670. fn: function (){
  671. var self=this;
  672. return smalltalk.withContext(function($ctx1) {
  673. var $1;
  674. $1=self["@outerContext"];
  675. return $1;
  676. }, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.AIContext)})},
  677. args: [],
  678. source: "outerContext\x0a\x09^ outerContext",
  679. messageSends: [],
  680. referencedClasses: []
  681. }),
  682. smalltalk.AIContext);
  683. smalltalk.addMethod(
  684. smalltalk.method({
  685. selector: "outerContext:",
  686. category: 'accessing',
  687. fn: function (anAIContext){
  688. var self=this;
  689. return smalltalk.withContext(function($ctx1) {
  690. self["@outerContext"]=anAIContext;
  691. _st(self["@outerContext"])._innerContext_(self);
  692. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  693. args: ["anAIContext"],
  694. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext innerContext: self",
  695. messageSends: ["innerContext:"],
  696. referencedClasses: []
  697. }),
  698. smalltalk.AIContext);
  699. smalltalk.addMethod(
  700. smalltalk.method({
  701. selector: "pc",
  702. category: 'interpreting',
  703. fn: function (){
  704. var self=this;
  705. return smalltalk.withContext(function($ctx1) {
  706. var $2,$1;
  707. $2=self["@pc"];
  708. if(($receiver = $2) == nil || $receiver == undefined){
  709. self["@pc"]=(0);
  710. $1=self["@pc"];
  711. } else {
  712. $1=$2;
  713. };
  714. return $1;
  715. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.AIContext)})},
  716. args: [],
  717. source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
  718. messageSends: ["ifNil:"],
  719. referencedClasses: []
  720. }),
  721. smalltalk.AIContext);
  722. smalltalk.addMethod(
  723. smalltalk.method({
  724. selector: "pc:",
  725. category: 'interpreting',
  726. fn: function (anInteger){
  727. var self=this;
  728. return smalltalk.withContext(function($ctx1) {
  729. self["@pc"]=anInteger;
  730. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.AIContext)})},
  731. args: ["anInteger"],
  732. source: "pc: anInteger\x0a\x09pc := anInteger",
  733. messageSends: [],
  734. referencedClasses: []
  735. }),
  736. smalltalk.AIContext);
  737. smalltalk.addMethod(
  738. smalltalk.method({
  739. selector: "receiver",
  740. category: 'interpreting',
  741. fn: function (){
  742. var self=this;
  743. return smalltalk.withContext(function($ctx1) {
  744. var $1;
  745. $1=self._localAt_("self");
  746. return $1;
  747. }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AIContext)})},
  748. args: [],
  749. source: "receiver\x0a\x09^ self localAt: 'self'",
  750. messageSends: ["localAt:"],
  751. referencedClasses: []
  752. }),
  753. smalltalk.AIContext);
  754. smalltalk.addMethod(
  755. smalltalk.method({
  756. selector: "receiver:",
  757. category: 'interpreting',
  758. fn: function (anObject){
  759. var self=this;
  760. return smalltalk.withContext(function($ctx1) {
  761. self._localAt_put_("self",anObject);
  762. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},smalltalk.AIContext)})},
  763. args: ["anObject"],
  764. source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
  765. messageSends: ["localAt:put:"],
  766. referencedClasses: []
  767. }),
  768. smalltalk.AIContext);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "retrieveNode",
  772. category: 'interpreting',
  773. fn: function (){
  774. var self=this;
  775. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  776. return smalltalk.withContext(function($ctx1) {
  777. var $2,$3,$1;
  778. $2=_st($ASTPCNodeVisitor())._new();
  779. _st($2)._context_(self);
  780. _st($2)._visit_(self._ast());
  781. $3=_st($2)._currentNode();
  782. $1=$3;
  783. return $1;
  784. }, function($ctx1) {$ctx1.fill(self,"retrieveNode",{},smalltalk.AIContext)})},
  785. args: [],
  786. source: "retrieveNode\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09context: self;\x0a\x09\x09visit: self ast;\x0a\x09\x09currentNode",
  787. messageSends: ["context:", "new", "visit:", "ast", "currentNode"],
  788. referencedClasses: ["ASTPCNodeVisitor"]
  789. }),
  790. smalltalk.AIContext);
  791. smalltalk.addMethod(
  792. smalltalk.method({
  793. selector: "selector",
  794. category: 'accessing',
  795. fn: function (){
  796. var self=this;
  797. return smalltalk.withContext(function($ctx1) {
  798. var $2,$1;
  799. $2=self._method();
  800. if(($receiver = $2) == nil || $receiver == undefined){
  801. $1=$2;
  802. } else {
  803. $1=_st(self._method())._selector();
  804. };
  805. return $1;
  806. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.AIContext)})},
  807. args: [],
  808. source: "selector\x0a\x09^ self method ifNotNil: [ \x0a\x09\x09self method selector ]",
  809. messageSends: ["ifNotNil:", "method", "selector"],
  810. referencedClasses: []
  811. }),
  812. smalltalk.AIContext);
  813. smalltalk.addMethod(
  814. smalltalk.method({
  815. selector: "setupInterpreter:",
  816. category: 'interpreting',
  817. fn: function (anInterpreter){
  818. var self=this;
  819. return smalltalk.withContext(function($ctx1) {
  820. _st(_st(_st(self._innerContext())._arguments())._reversed())._do_((function(each){
  821. return smalltalk.withContext(function($ctx2) {
  822. return _st(anInterpreter)._push_(each);
  823. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  824. _st(anInterpreter)._push_(_st(self._innerContext())._receiver());
  825. return self}, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
  826. args: ["anInterpreter"],
  827. source: "setupInterpreter: anInterpreter\x0a\x09\x22Push the send args and receiver to the interpreter stack\x22\x0a\x09\x0a\x09self innerContext arguments reversed do: [ :each | \x0a\x09\x09anInterpreter push: each ].\x0a\x09\x09\x0a\x09anInterpreter push: (self innerContext receiver)",
  828. messageSends: ["do:", "reversed", "arguments", "innerContext", "push:", "receiver"],
  829. referencedClasses: []
  830. }),
  831. smalltalk.AIContext);
  832. smalltalk.addMethod(
  833. smalltalk.method({
  834. selector: "fromMethodContext:",
  835. category: 'instance creation',
  836. fn: function (aMethodContext){
  837. var self=this;
  838. return smalltalk.withContext(function($ctx1) {
  839. var $2,$3,$1;
  840. $2=self._new();
  841. _st($2)._initializeFromMethodContext_(aMethodContext);
  842. $3=_st($2)._yourself();
  843. $1=$3;
  844. return $1;
  845. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext.klass)})},
  846. args: ["aMethodContext"],
  847. source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
  848. messageSends: ["initializeFromMethodContext:", "new", "yourself"],
  849. referencedClasses: []
  850. }),
  851. smalltalk.AIContext.klass);
  852. smalltalk.addClass('AIInterpreterError', smalltalk.Error, [], 'Compiler-Interpreter');
  853. smalltalk.AIInterpreterError.comment="I get signaled when an AST interpreter is unable to interpret a node.";
  854. smalltalk.addClass('ASTDebugger', smalltalk.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
  855. smalltalk.ASTDebugger.comment="I am a stepping debugger interface for Amber code.\x0aI internally use an instance of `ASTSteppingInterpreter` to actually step through node and interpret them.\x0a\x0aMy instances are created from a `MethodContext` 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.";
  856. smalltalk.addMethod(
  857. smalltalk.method({
  858. selector: "atEnd",
  859. category: 'testing',
  860. fn: function (){
  861. var self=this;
  862. return smalltalk.withContext(function($ctx1) {
  863. var $1;
  864. $1=_st(self._interpreter())._atEnd();
  865. return $1;
  866. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTDebugger)})},
  867. args: [],
  868. source: "atEnd\x0a\x09^ self interpreter atEnd",
  869. messageSends: ["atEnd", "interpreter"],
  870. referencedClasses: []
  871. }),
  872. smalltalk.ASTDebugger);
  873. smalltalk.addMethod(
  874. smalltalk.method({
  875. selector: "buildAST",
  876. category: 'initialization',
  877. fn: function (){
  878. var self=this;
  879. var ast;
  880. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  881. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  882. return smalltalk.withContext(function($ctx1) {
  883. var $1;
  884. ast=_st(_st($Smalltalk())._current())._parse_(_st(self._method())._source());
  885. _st(_st($SemanticAnalyzer())._on_(_st(_st(self._context())._receiver())._class()))._visit_(ast);
  886. $1=ast;
  887. return $1;
  888. }, function($ctx1) {$ctx1.fill(self,"buildAST",{ast:ast},smalltalk.ASTDebugger)})},
  889. args: [],
  890. 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 current parse: self method source.\x0a\x09(SemanticAnalyzer on: self context receiver class)\x0a\x09\x09visit: ast.\x0a\x09\x0a\x09^ ast",
  891. messageSends: ["parse:", "current", "source", "method", "visit:", "on:", "class", "receiver", "context"],
  892. referencedClasses: ["Smalltalk", "SemanticAnalyzer"]
  893. }),
  894. smalltalk.ASTDebugger);
  895. smalltalk.addMethod(
  896. smalltalk.method({
  897. selector: "context",
  898. category: 'accessing',
  899. fn: function (){
  900. var self=this;
  901. return smalltalk.withContext(function($ctx1) {
  902. var $1;
  903. $1=self["@context"];
  904. return $1;
  905. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTDebugger)})},
  906. args: [],
  907. source: "context\x0a\x09^ context",
  908. messageSends: [],
  909. referencedClasses: []
  910. }),
  911. smalltalk.ASTDebugger);
  912. smalltalk.addMethod(
  913. smalltalk.method({
  914. selector: "context:",
  915. category: 'accessing',
  916. fn: function (aContext){
  917. var self=this;
  918. return smalltalk.withContext(function($ctx1) {
  919. self["@context"]=aContext;
  920. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger)})},
  921. args: ["aContext"],
  922. source: "context: aContext\x0a\x09context := aContext",
  923. messageSends: [],
  924. referencedClasses: []
  925. }),
  926. smalltalk.ASTDebugger);
  927. smalltalk.addMethod(
  928. smalltalk.method({
  929. selector: "defaultInterpreterClass",
  930. category: 'defaults',
  931. fn: function (){
  932. var self=this;
  933. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  934. return smalltalk.withContext(function($ctx1) {
  935. var $1;
  936. $1=$ASTSteppingInterpreter();
  937. return $1;
  938. }, function($ctx1) {$ctx1.fill(self,"defaultInterpreterClass",{},smalltalk.ASTDebugger)})},
  939. args: [],
  940. source: "defaultInterpreterClass\x0a\x09^ ASTSteppingInterpreter",
  941. messageSends: [],
  942. referencedClasses: ["ASTSteppingInterpreter"]
  943. }),
  944. smalltalk.ASTDebugger);
  945. smalltalk.addMethod(
  946. smalltalk.method({
  947. selector: "initializeInterpreter",
  948. category: 'initialization',
  949. fn: function (){
  950. var self=this;
  951. var ast,next;
  952. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  953. return smalltalk.withContext(function($ctx1) {
  954. var $1,$2;
  955. ast=self._buildAST();
  956. $1=_st($ASTPCNodeVisitor())._new();
  957. _st($1)._context_(self._context());
  958. _st($1)._visit_(ast);
  959. $2=_st($1)._currentNode();
  960. next=$2;
  961. _st(self._interpreter())._interpret_(next);
  962. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{ast:ast,next:next},smalltalk.ASTDebugger)})},
  963. args: [],
  964. 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 interpret: next",
  965. messageSends: ["buildAST", "context:", "new", "context", "visit:", "currentNode", "interpret:", "interpreter"],
  966. referencedClasses: ["ASTPCNodeVisitor"]
  967. }),
  968. smalltalk.ASTDebugger);
  969. smalltalk.addMethod(
  970. smalltalk.method({
  971. selector: "initializeWithContext:",
  972. category: 'initialization',
  973. fn: function (aContext){
  974. var self=this;
  975. return smalltalk.withContext(function($ctx1) {
  976. self._context_(aContext);
  977. self._initializeInterpreter();
  978. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:",{aContext:aContext},smalltalk.ASTDebugger)})},
  979. args: ["aContext"],
  980. source: "initializeWithContext: aContext\x0a\x09\x22TODO: do we need to handle block contexts?\x22\x0a\x09\x0a\x09self context: aContext.\x0a\x09self initializeInterpreter",
  981. messageSends: ["context:", "initializeInterpreter"],
  982. referencedClasses: []
  983. }),
  984. smalltalk.ASTDebugger);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "interpreter",
  988. category: 'accessing',
  989. fn: function (){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. var $2,$1;
  993. $2=self["@interpreter"];
  994. if(($receiver = $2) == nil || $receiver == undefined){
  995. self["@interpreter"]=_st(self._defaultInterpreterClass())._new();
  996. $1=self["@interpreter"];
  997. } else {
  998. $1=$2;
  999. };
  1000. return $1;
  1001. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTDebugger)})},
  1002. args: [],
  1003. source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := self defaultInterpreterClass new ]",
  1004. messageSends: ["ifNil:", "new", "defaultInterpreterClass"],
  1005. referencedClasses: []
  1006. }),
  1007. smalltalk.ASTDebugger);
  1008. smalltalk.addMethod(
  1009. smalltalk.method({
  1010. selector: "interpreter:",
  1011. category: 'accessing',
  1012. fn: function (anInterpreter){
  1013. var self=this;
  1014. return smalltalk.withContext(function($ctx1) {
  1015. self["@interpreter"]=anInterpreter;
  1016. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.ASTDebugger)})},
  1017. args: ["anInterpreter"],
  1018. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  1019. messageSends: [],
  1020. referencedClasses: []
  1021. }),
  1022. smalltalk.ASTDebugger);
  1023. smalltalk.addMethod(
  1024. smalltalk.method({
  1025. selector: "method",
  1026. category: 'accessing',
  1027. fn: function (){
  1028. var self=this;
  1029. return smalltalk.withContext(function($ctx1) {
  1030. var $1;
  1031. $1=_st(self._context())._method();
  1032. return $1;
  1033. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.ASTDebugger)})},
  1034. args: [],
  1035. source: "method\x0a\x09^ self context method",
  1036. messageSends: ["method", "context"],
  1037. referencedClasses: []
  1038. }),
  1039. smalltalk.ASTDebugger);
  1040. smalltalk.addMethod(
  1041. smalltalk.method({
  1042. selector: "nextNode",
  1043. category: 'accessing',
  1044. fn: function (){
  1045. var self=this;
  1046. return smalltalk.withContext(function($ctx1) {
  1047. var $1;
  1048. $1=_st(self._interpreter())._nextNode();
  1049. return $1;
  1050. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTDebugger)})},
  1051. args: [],
  1052. source: "nextNode\x0a\x09^ self interpreter nextNode",
  1053. messageSends: ["nextNode", "interpreter"],
  1054. referencedClasses: []
  1055. }),
  1056. smalltalk.ASTDebugger);
  1057. smalltalk.addMethod(
  1058. smalltalk.method({
  1059. selector: "proceed",
  1060. category: 'stepping',
  1061. fn: function (){
  1062. var self=this;
  1063. return smalltalk.withContext(function($ctx1) {
  1064. self._shouldBeImplemented();
  1065. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTDebugger)})},
  1066. args: [],
  1067. source: "proceed\x0a\x09self shouldBeImplemented",
  1068. messageSends: ["shouldBeImplemented"],
  1069. referencedClasses: []
  1070. }),
  1071. smalltalk.ASTDebugger);
  1072. smalltalk.addMethod(
  1073. smalltalk.method({
  1074. selector: "restart",
  1075. category: 'stepping',
  1076. fn: function (){
  1077. var self=this;
  1078. return smalltalk.withContext(function($ctx1) {
  1079. self._shouldBeImplemented();
  1080. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTDebugger)})},
  1081. args: [],
  1082. source: "restart\x0a\x09self shouldBeImplemented",
  1083. messageSends: ["shouldBeImplemented"],
  1084. referencedClasses: []
  1085. }),
  1086. smalltalk.ASTDebugger);
  1087. smalltalk.addMethod(
  1088. smalltalk.method({
  1089. selector: "step",
  1090. category: 'stepping',
  1091. fn: function (){
  1092. var self=this;
  1093. return smalltalk.withContext(function($ctx1) {
  1094. _st((function(){
  1095. return smalltalk.withContext(function($ctx2) {
  1096. return _st(_st(_st(_st(self._interpreter())._nextNode())._notNil())._and_((function(){
  1097. return smalltalk.withContext(function($ctx3) {
  1098. return _st(_st(self._interpreter())._nextNode())._stopOnStepping();
  1099. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})))._or_((function(){
  1100. return smalltalk.withContext(function($ctx3) {
  1101. return _st(_st(self._interpreter())._atEnd())._not();
  1102. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1103. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1104. return smalltalk.withContext(function($ctx2) {
  1105. _st(self._interpreter())._step();
  1106. return self._step();
  1107. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
  1108. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTDebugger)})},
  1109. args: [],
  1110. source: "step\x0a\x09\x22The ASTSteppingInterpreter stops at each node interpretation.\x0a\x09One step will interpret nodes until:\x0a\x09- we get at the end\x0a\x09- the next node is a stepping node (send, assignment, etc.)\x22\x0a\x09\x0a\x09[ (self interpreter nextNode notNil and: [ self interpreter nextNode stopOnStepping ])\x0a\x09\x09or: [ self interpreter atEnd not ] ]\x0a\x09\x09\x09whileFalse: [\x0a\x09\x09\x09\x09self interpreter step.\x0a\x09\x09\x09\x09self step ]",
  1111. messageSends: ["whileFalse:", "or:", "and:", "notNil", "nextNode", "interpreter", "stopOnStepping", "not", "atEnd", "step"],
  1112. referencedClasses: []
  1113. }),
  1114. smalltalk.ASTDebugger);
  1115. smalltalk.addMethod(
  1116. smalltalk.method({
  1117. selector: "stepInto",
  1118. category: 'stepping',
  1119. fn: function (){
  1120. var self=this;
  1121. return smalltalk.withContext(function($ctx1) {
  1122. self._shouldBeImplemented();
  1123. return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},smalltalk.ASTDebugger)})},
  1124. args: [],
  1125. source: "stepInto\x0a\x09self shouldBeImplemented",
  1126. messageSends: ["shouldBeImplemented"],
  1127. referencedClasses: []
  1128. }),
  1129. smalltalk.ASTDebugger);
  1130. smalltalk.addMethod(
  1131. smalltalk.method({
  1132. selector: "stepOver",
  1133. category: 'stepping',
  1134. fn: function (){
  1135. var self=this;
  1136. return smalltalk.withContext(function($ctx1) {
  1137. self._step();
  1138. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTDebugger)})},
  1139. args: [],
  1140. source: "stepOver\x0a\x09self step",
  1141. messageSends: ["step"],
  1142. referencedClasses: []
  1143. }),
  1144. smalltalk.ASTDebugger);
  1145. smalltalk.addMethod(
  1146. smalltalk.method({
  1147. selector: "context:",
  1148. category: 'instance creation',
  1149. fn: function (aContext){
  1150. var self=this;
  1151. return smalltalk.withContext(function($ctx1) {
  1152. var $2,$3,$1;
  1153. $2=self._new();
  1154. _st($2)._initializeWithContext_(aContext);
  1155. $3=_st($2)._yourself();
  1156. $1=$3;
  1157. return $1;
  1158. }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger.klass)})},
  1159. args: ["aContext"],
  1160. source: "context: aContext\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext;\x0a\x09\x09yourself",
  1161. messageSends: ["initializeWithContext:", "new", "yourself"],
  1162. referencedClasses: []
  1163. }),
  1164. smalltalk.ASTDebugger.klass);
  1165. smalltalk.addClass('ASTInterpreter', smalltalk.NodeVisitor, ['node', 'context', 'stack', 'returnValue', 'returned'], 'Compiler-Interpreter');
  1166. smalltalk.addMethod(
  1167. smalltalk.method({
  1168. selector: "assign:to:",
  1169. category: 'private',
  1170. fn: function (aNode,anObject){
  1171. var self=this;
  1172. return smalltalk.withContext(function($ctx1) {
  1173. var $1;
  1174. $1=_st(_st(aNode)._binding())._isInstanceVar();
  1175. if(smalltalk.assert($1)){
  1176. _st(_st(self._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  1177. } else {
  1178. _st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
  1179. };
  1180. return self}, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.ASTInterpreter)})},
  1181. args: ["aNode", "anObject"],
  1182. 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 ]",
  1183. messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
  1184. referencedClasses: []
  1185. }),
  1186. smalltalk.ASTInterpreter);
  1187. smalltalk.addMethod(
  1188. smalltalk.method({
  1189. selector: "atEnd",
  1190. category: 'testing',
  1191. fn: function (){
  1192. var self=this;
  1193. return smalltalk.withContext(function($ctx1) {
  1194. var $1;
  1195. $1=_st(self._hasReturned())._or_((function(){
  1196. return smalltalk.withContext(function($ctx2) {
  1197. return _st(self._node())._isNil();
  1198. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1199. return $1;
  1200. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTInterpreter)})},
  1201. args: [],
  1202. source: "atEnd\x0a\x09^ self hasReturned or: [ self node isNil ]",
  1203. messageSends: ["or:", "hasReturned", "isNil", "node"],
  1204. referencedClasses: []
  1205. }),
  1206. smalltalk.ASTInterpreter);
  1207. smalltalk.addMethod(
  1208. smalltalk.method({
  1209. selector: "context",
  1210. category: 'accessing',
  1211. fn: function (){
  1212. var self=this;
  1213. return smalltalk.withContext(function($ctx1) {
  1214. var $1;
  1215. $1=self["@context"];
  1216. return $1;
  1217. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTInterpreter)})},
  1218. args: [],
  1219. source: "context\x0a\x09^ context",
  1220. messageSends: [],
  1221. referencedClasses: []
  1222. }),
  1223. smalltalk.ASTInterpreter);
  1224. smalltalk.addMethod(
  1225. smalltalk.method({
  1226. selector: "context:",
  1227. category: 'accessing',
  1228. fn: function (aContext){
  1229. var self=this;
  1230. return smalltalk.withContext(function($ctx1) {
  1231. self["@context"]=aContext;
  1232. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTInterpreter)})},
  1233. args: ["aContext"],
  1234. source: "context: aContext\x0a\x09context := aContext",
  1235. messageSends: [],
  1236. referencedClasses: []
  1237. }),
  1238. smalltalk.ASTInterpreter);
  1239. smalltalk.addMethod(
  1240. smalltalk.method({
  1241. selector: "eval:",
  1242. category: 'private',
  1243. fn: function (aString){
  1244. var self=this;
  1245. var source,function_;
  1246. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1247. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1248. return smalltalk.withContext(function($ctx1) {
  1249. var $1,$2,$3;
  1250. source=_st($String())._streamContents_((function(str){
  1251. return smalltalk.withContext(function($ctx2) {
  1252. _st(str)._nextPutAll_("(function(");
  1253. _st(_st(_st(self._context())._locals())._keys())._do_separatedBy_((function(each){
  1254. return smalltalk.withContext(function($ctx3) {
  1255. return _st(str)._nextPutAll_(each);
  1256. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
  1257. return smalltalk.withContext(function($ctx3) {
  1258. return _st(str)._nextPutAll_(",");
  1259. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1260. $1=str;
  1261. _st($1)._nextPutAll_("){ return (function() {");
  1262. _st($1)._nextPutAll_(aString);
  1263. $2=_st($1)._nextPutAll_("})() })");
  1264. return $2;
  1265. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
  1266. function_=_st(_st($Compiler())._new())._eval_(source);
  1267. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
  1268. return $3;
  1269. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.ASTInterpreter)})},
  1270. args: ["aString"],
  1271. 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",
  1272. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  1273. referencedClasses: ["String", "Compiler"]
  1274. }),
  1275. smalltalk.ASTInterpreter);
  1276. smalltalk.addMethod(
  1277. smalltalk.method({
  1278. selector: "hasReturned",
  1279. category: 'testing',
  1280. fn: function (){
  1281. var self=this;
  1282. return smalltalk.withContext(function($ctx1) {
  1283. var $2,$1;
  1284. $2=self["@returned"];
  1285. if(($receiver = $2) == nil || $receiver == undefined){
  1286. $1=false;
  1287. } else {
  1288. $1=$2;
  1289. };
  1290. return $1;
  1291. }, function($ctx1) {$ctx1.fill(self,"hasReturned",{},smalltalk.ASTInterpreter)})},
  1292. args: [],
  1293. source: "hasReturned\x0a\x09^ returned ifNil: [ false ]",
  1294. messageSends: ["ifNil:"],
  1295. referencedClasses: []
  1296. }),
  1297. smalltalk.ASTInterpreter);
  1298. smalltalk.addMethod(
  1299. smalltalk.method({
  1300. selector: "interpret",
  1301. category: 'interpreting',
  1302. fn: function (){
  1303. var self=this;
  1304. return smalltalk.withContext(function($ctx1) {
  1305. self._visit_(self._node());
  1306. return self}, function($ctx1) {$ctx1.fill(self,"interpret",{},smalltalk.ASTInterpreter)})},
  1307. args: [],
  1308. source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
  1309. messageSends: ["visit:", "node"],
  1310. referencedClasses: []
  1311. }),
  1312. smalltalk.ASTInterpreter);
  1313. smalltalk.addMethod(
  1314. smalltalk.method({
  1315. selector: "interpret:",
  1316. category: 'interpreting',
  1317. fn: function (aNode){
  1318. var self=this;
  1319. return smalltalk.withContext(function($ctx1) {
  1320. self._node_(aNode);
  1321. self._interpret();
  1322. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1323. args: ["aNode"],
  1324. source: "interpret: aNode\x0a\x09self node: aNode.\x0a\x09self interpret",
  1325. messageSends: ["node:", "interpret"],
  1326. referencedClasses: []
  1327. }),
  1328. smalltalk.ASTInterpreter);
  1329. smalltalk.addMethod(
  1330. smalltalk.method({
  1331. selector: "messageFromSendNode:arguments:",
  1332. category: 'private',
  1333. fn: function (aSendNode,aCollection){
  1334. var self=this;
  1335. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  1336. return smalltalk.withContext(function($ctx1) {
  1337. var $2,$3,$1;
  1338. $2=_st($Message())._new();
  1339. _st($2)._selector_(_st(aSendNode)._selector());
  1340. _st($2)._arguments_(aCollection);
  1341. $3=_st($2)._yourself();
  1342. $1=$3;
  1343. return $1;
  1344. }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},smalltalk.ASTInterpreter)})},
  1345. args: ["aSendNode", "aCollection"],
  1346. source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
  1347. messageSends: ["selector:", "new", "selector", "arguments:", "yourself"],
  1348. referencedClasses: ["Message"]
  1349. }),
  1350. smalltalk.ASTInterpreter);
  1351. smalltalk.addMethod(
  1352. smalltalk.method({
  1353. selector: "messageNotUnderstood:receiver:",
  1354. category: 'private',
  1355. fn: function (aMessage,anObject){
  1356. var self=this;
  1357. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  1358. return smalltalk.withContext(function($ctx1) {
  1359. var $1,$2;
  1360. $1=_st($MessageNotUnderstood())._new();
  1361. _st($1)._meesage_(aMessage);
  1362. _st($1)._receiver_(anObject);
  1363. $2=_st($1)._signal();
  1364. return self}, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},smalltalk.ASTInterpreter)})},
  1365. args: ["aMessage", "anObject"],
  1366. source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09meesage: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
  1367. messageSends: ["meesage:", "new", "receiver:", "signal"],
  1368. referencedClasses: ["MessageNotUnderstood"]
  1369. }),
  1370. smalltalk.ASTInterpreter);
  1371. smalltalk.addMethod(
  1372. smalltalk.method({
  1373. selector: "next",
  1374. category: 'interpreting',
  1375. fn: function (){
  1376. var self=this;
  1377. return smalltalk.withContext(function($ctx1) {
  1378. self._node_(_st(self._node())._nextNode());
  1379. return self}, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.ASTInterpreter)})},
  1380. args: [],
  1381. source: "next\x0a\x09self node: self node nextNode",
  1382. messageSends: ["node:", "nextNode", "node"],
  1383. referencedClasses: []
  1384. }),
  1385. smalltalk.ASTInterpreter);
  1386. smalltalk.addMethod(
  1387. smalltalk.method({
  1388. selector: "node",
  1389. category: 'accessing',
  1390. fn: function (){
  1391. var self=this;
  1392. return smalltalk.withContext(function($ctx1) {
  1393. var $1;
  1394. $1=self["@node"];
  1395. return $1;
  1396. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.ASTInterpreter)})},
  1397. args: [],
  1398. source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
  1399. messageSends: [],
  1400. referencedClasses: []
  1401. }),
  1402. smalltalk.ASTInterpreter);
  1403. smalltalk.addMethod(
  1404. smalltalk.method({
  1405. selector: "node:",
  1406. category: 'accessing',
  1407. fn: function (aNode){
  1408. var self=this;
  1409. return smalltalk.withContext(function($ctx1) {
  1410. self["@node"]=aNode;
  1411. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1412. args: ["aNode"],
  1413. source: "node: aNode\x0a\x09node := aNode",
  1414. messageSends: [],
  1415. referencedClasses: []
  1416. }),
  1417. smalltalk.ASTInterpreter);
  1418. smalltalk.addMethod(
  1419. smalltalk.method({
  1420. selector: "peek",
  1421. category: 'stack',
  1422. fn: function (){
  1423. var self=this;
  1424. return smalltalk.withContext(function($ctx1) {
  1425. var $1;
  1426. var $early={};
  1427. try {
  1428. _st(self._stack())._ifEmpty_((function(){
  1429. return smalltalk.withContext(function($ctx2) {
  1430. throw $early=[nil];
  1431. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1432. $1=_st(self._stack())._last();
  1433. return $1;
  1434. }
  1435. catch(e) {if(e===$early)return e[0]; throw e}
  1436. }, function($ctx1) {$ctx1.fill(self,"peek",{},smalltalk.ASTInterpreter)})},
  1437. args: [],
  1438. 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",
  1439. messageSends: ["ifEmpty:", "stack", "last"],
  1440. referencedClasses: []
  1441. }),
  1442. smalltalk.ASTInterpreter);
  1443. smalltalk.addMethod(
  1444. smalltalk.method({
  1445. selector: "pop",
  1446. category: 'stack',
  1447. fn: function (){
  1448. var self=this;
  1449. var peekedValue;
  1450. return smalltalk.withContext(function($ctx1) {
  1451. var $1;
  1452. peekedValue=self._peek();
  1453. _st(self._stack())._removeLast();
  1454. $1=peekedValue;
  1455. return $1;
  1456. }, function($ctx1) {$ctx1.fill(self,"pop",{peekedValue:peekedValue},smalltalk.ASTInterpreter)})},
  1457. args: [],
  1458. 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",
  1459. messageSends: ["peek", "removeLast", "stack"],
  1460. referencedClasses: []
  1461. }),
  1462. smalltalk.ASTInterpreter);
  1463. smalltalk.addMethod(
  1464. smalltalk.method({
  1465. selector: "proceed",
  1466. category: 'interpreting',
  1467. fn: function (){
  1468. var self=this;
  1469. return smalltalk.withContext(function($ctx1) {
  1470. _st((function(){
  1471. return smalltalk.withContext(function($ctx2) {
  1472. return self._atEnd();
  1473. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1474. return smalltalk.withContext(function($ctx2) {
  1475. return self._step();
  1476. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1477. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTInterpreter)})},
  1478. args: [],
  1479. source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] whileFalse: [ \x0a\x09\x09self step ]",
  1480. messageSends: ["whileFalse:", "atEnd", "step"],
  1481. referencedClasses: []
  1482. }),
  1483. smalltalk.ASTInterpreter);
  1484. smalltalk.addMethod(
  1485. smalltalk.method({
  1486. selector: "push:",
  1487. category: 'stack',
  1488. fn: function (anObject){
  1489. var self=this;
  1490. return smalltalk.withContext(function($ctx1) {
  1491. var $1;
  1492. $1=_st(self._stack())._add_(anObject);
  1493. return $1;
  1494. }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},smalltalk.ASTInterpreter)})},
  1495. args: ["anObject"],
  1496. source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
  1497. messageSends: ["add:", "stack"],
  1498. referencedClasses: []
  1499. }),
  1500. smalltalk.ASTInterpreter);
  1501. smalltalk.addMethod(
  1502. smalltalk.method({
  1503. selector: "restart",
  1504. category: 'interpreting',
  1505. fn: function (){
  1506. var self=this;
  1507. return smalltalk.withContext(function($ctx1) {
  1508. self._node_(_st(_st(self._context())._ast())._nextChild());
  1509. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTInterpreter)})},
  1510. args: [],
  1511. source: "restart\x0a\x09self node: self context ast nextChild",
  1512. messageSends: ["node:", "nextChild", "ast", "context"],
  1513. referencedClasses: []
  1514. }),
  1515. smalltalk.ASTInterpreter);
  1516. smalltalk.addMethod(
  1517. smalltalk.method({
  1518. selector: "result",
  1519. category: 'accessing',
  1520. fn: function (){
  1521. var self=this;
  1522. return smalltalk.withContext(function($ctx1) {
  1523. var $2,$1;
  1524. $2=self._hasReturned();
  1525. if(smalltalk.assert($2)){
  1526. $1=self._returnValue();
  1527. } else {
  1528. $1=_st(self._context())._receiver();
  1529. };
  1530. return $1;
  1531. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ASTInterpreter)})},
  1532. args: [],
  1533. source: "result\x0a\x09^ self hasReturned \x0a\x09\x09ifTrue: [ self returnValue ] \x0a\x09\x09ifFalse: [ self context receiver ]",
  1534. messageSends: ["ifTrue:ifFalse:", "hasReturned", "returnValue", "receiver", "context"],
  1535. referencedClasses: []
  1536. }),
  1537. smalltalk.ASTInterpreter);
  1538. smalltalk.addMethod(
  1539. smalltalk.method({
  1540. selector: "returnValue",
  1541. category: 'accessing',
  1542. fn: function (){
  1543. var self=this;
  1544. return smalltalk.withContext(function($ctx1) {
  1545. var $1;
  1546. $1=self["@returnValue"];
  1547. return $1;
  1548. }, function($ctx1) {$ctx1.fill(self,"returnValue",{},smalltalk.ASTInterpreter)})},
  1549. args: [],
  1550. source: "returnValue\x0a\x09^ returnValue",
  1551. messageSends: [],
  1552. referencedClasses: []
  1553. }),
  1554. smalltalk.ASTInterpreter);
  1555. smalltalk.addMethod(
  1556. smalltalk.method({
  1557. selector: "returnValue:",
  1558. category: 'accessing',
  1559. fn: function (anObject){
  1560. var self=this;
  1561. return smalltalk.withContext(function($ctx1) {
  1562. self["@returnValue"]=anObject;
  1563. return self}, function($ctx1) {$ctx1.fill(self,"returnValue:",{anObject:anObject},smalltalk.ASTInterpreter)})},
  1564. args: ["anObject"],
  1565. source: "returnValue: anObject\x0a\x09returnValue := anObject",
  1566. messageSends: [],
  1567. referencedClasses: []
  1568. }),
  1569. smalltalk.ASTInterpreter);
  1570. smalltalk.addMethod(
  1571. smalltalk.method({
  1572. selector: "sendMessage:to:superSend:",
  1573. category: 'private',
  1574. fn: function (aMessage,anObject,aBoolean){
  1575. var self=this;
  1576. var method;
  1577. return smalltalk.withContext(function($ctx1) {
  1578. var $1,$2,$3,$4,$5,$6;
  1579. var $early={};
  1580. try {
  1581. $1=aBoolean;
  1582. if(! smalltalk.assert($1)){
  1583. $2=_st(aMessage)._sendTo_(anObject);
  1584. return $2;
  1585. };
  1586. $3=_st(_st(anObject)._class())._superclass();
  1587. if(($receiver = $3) == nil || $receiver == undefined){
  1588. $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1589. return $4;
  1590. } else {
  1591. $3;
  1592. };
  1593. method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
  1594. return smalltalk.withContext(function($ctx2) {
  1595. $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1596. throw $early=[$5];
  1597. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  1598. $6=_st(method)._sendTo_arguments_(anObject,_st(aMessage)._arguments());
  1599. return $6;
  1600. }
  1601. catch(e) {if(e===$early)return e[0]; throw e}
  1602. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.ASTInterpreter)})},
  1603. args: ["aMessage", "anObject", "aBoolean"],
  1604. 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",
  1605. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "sendTo:arguments:", "arguments"],
  1606. referencedClasses: []
  1607. }),
  1608. smalltalk.ASTInterpreter);
  1609. smalltalk.addMethod(
  1610. smalltalk.method({
  1611. selector: "setNonLocalReturnFromContext:",
  1612. category: 'interpreting',
  1613. fn: function (aContext){
  1614. var self=this;
  1615. return smalltalk.withContext(function($ctx1) {
  1616. var $1;
  1617. $1=_st(_st(aContext)._interpreter())._hasReturned();
  1618. if(smalltalk.assert($1)){
  1619. self["@returned"]=true;
  1620. self["@returned"];
  1621. self._returnValue_(_st(_st(aContext)._interpreter())._returnValue());
  1622. };
  1623. return self}, function($ctx1) {$ctx1.fill(self,"setNonLocalReturnFromContext:",{aContext:aContext},smalltalk.ASTInterpreter)})},
  1624. args: ["aContext"],
  1625. source: "setNonLocalReturnFromContext: aContext\x0a\x09aContext interpreter hasReturned ifTrue: [\x0a\x09\x09returned := true.\x0a\x09\x09self returnValue: aContext interpreter returnValue ]",
  1626. messageSends: ["ifTrue:", "hasReturned", "interpreter", "returnValue:", "returnValue"],
  1627. referencedClasses: []
  1628. }),
  1629. smalltalk.ASTInterpreter);
  1630. smalltalk.addMethod(
  1631. smalltalk.method({
  1632. selector: "skip",
  1633. category: 'interpreting',
  1634. fn: function (){
  1635. var self=this;
  1636. return smalltalk.withContext(function($ctx1) {
  1637. self._next();
  1638. return self}, function($ctx1) {$ctx1.fill(self,"skip",{},smalltalk.ASTInterpreter)})},
  1639. args: [],
  1640. source: "skip\x0a\x09self next",
  1641. messageSends: ["next"],
  1642. referencedClasses: []
  1643. }),
  1644. smalltalk.ASTInterpreter);
  1645. smalltalk.addMethod(
  1646. smalltalk.method({
  1647. selector: "stack",
  1648. category: 'accessing',
  1649. fn: function (){
  1650. var self=this;
  1651. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1652. return smalltalk.withContext(function($ctx1) {
  1653. var $2,$1;
  1654. $2=self["@stack"];
  1655. if(($receiver = $2) == nil || $receiver == undefined){
  1656. self["@stack"]=_st($OrderedCollection())._new();
  1657. $1=self["@stack"];
  1658. } else {
  1659. $1=$2;
  1660. };
  1661. return $1;
  1662. }, function($ctx1) {$ctx1.fill(self,"stack",{},smalltalk.ASTInterpreter)})},
  1663. args: [],
  1664. source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
  1665. messageSends: ["ifNil:", "new"],
  1666. referencedClasses: ["OrderedCollection"]
  1667. }),
  1668. smalltalk.ASTInterpreter);
  1669. smalltalk.addMethod(
  1670. smalltalk.method({
  1671. selector: "step",
  1672. category: 'interpreting',
  1673. fn: function (){
  1674. var self=this;
  1675. return smalltalk.withContext(function($ctx1) {
  1676. var $1,$2;
  1677. $1=self;
  1678. _st($1)._interpret();
  1679. $2=_st($1)._next();
  1680. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTInterpreter)})},
  1681. args: [],
  1682. source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
  1683. messageSends: ["interpret", "next"],
  1684. referencedClasses: []
  1685. }),
  1686. smalltalk.ASTInterpreter);
  1687. smalltalk.addMethod(
  1688. smalltalk.method({
  1689. selector: "stepOver",
  1690. category: 'interpreting',
  1691. fn: function (){
  1692. var self=this;
  1693. return smalltalk.withContext(function($ctx1) {
  1694. self._step();
  1695. _st((function(){
  1696. return smalltalk.withContext(function($ctx2) {
  1697. return _st(self._node())._isSteppingNode();
  1698. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  1699. return smalltalk.withContext(function($ctx2) {
  1700. return self._step();
  1701. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1702. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTInterpreter)})},
  1703. args: [],
  1704. source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isSteppingNode ] whileFalse: [ \x0a\x09\x09self step ]",
  1705. messageSends: ["step", "whileFalse:", "isSteppingNode", "node"],
  1706. referencedClasses: []
  1707. }),
  1708. smalltalk.ASTInterpreter);
  1709. smalltalk.addMethod(
  1710. smalltalk.method({
  1711. selector: "visit:",
  1712. category: 'visiting',
  1713. fn: function (aNode){
  1714. var self=this;
  1715. return smalltalk.withContext(function($ctx1) {
  1716. var $1;
  1717. $1=self._hasReturned();
  1718. if(! smalltalk.assert($1)){
  1719. smalltalk.ASTInterpreter.superclass.fn.prototype._visit_.apply(_st(self), [aNode]);
  1720. };
  1721. return self}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1722. args: ["aNode"],
  1723. source: "visit: aNode\x0a\x09self hasReturned ifFalse: [ super visit: aNode ]",
  1724. messageSends: ["ifFalse:", "hasReturned", "visit:"],
  1725. referencedClasses: []
  1726. }),
  1727. smalltalk.ASTInterpreter);
  1728. smalltalk.addMethod(
  1729. smalltalk.method({
  1730. selector: "visitAssignmentNode:",
  1731. category: 'visiting',
  1732. fn: function (aNode){
  1733. var self=this;
  1734. var poppedValue;
  1735. return smalltalk.withContext(function($ctx1) {
  1736. poppedValue=self._pop();
  1737. self._pop();
  1738. self._push_(poppedValue);
  1739. self._assign_to_(_st(aNode)._left(),poppedValue);
  1740. return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,poppedValue:poppedValue},smalltalk.ASTInterpreter)})},
  1741. args: ["aNode"],
  1742. 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",
  1743. messageSends: ["pop", "push:", "assign:to:", "left"],
  1744. referencedClasses: []
  1745. }),
  1746. smalltalk.ASTInterpreter);
  1747. smalltalk.addMethod(
  1748. smalltalk.method({
  1749. selector: "visitBlockNode:",
  1750. category: 'visiting',
  1751. fn: function (aNode){
  1752. var self=this;
  1753. var block;
  1754. function $AIBlockClosure(){return smalltalk.AIBlockClosure||(typeof AIBlockClosure=="undefined"?nil:AIBlockClosure)}
  1755. return smalltalk.withContext(function($ctx1) {
  1756. block=_st($AIBlockClosure())._forContext_node_(self._context(),aNode);
  1757. self._push_(block);
  1758. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,block:block},smalltalk.ASTInterpreter)})},
  1759. args: ["aNode"],
  1760. 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",
  1761. messageSends: ["forContext:node:", "context", "push:"],
  1762. referencedClasses: ["AIBlockClosure"]
  1763. }),
  1764. smalltalk.ASTInterpreter);
  1765. smalltalk.addMethod(
  1766. smalltalk.method({
  1767. selector: "visitClassReferenceNode:",
  1768. category: 'visiting',
  1769. fn: function (aNode){
  1770. var self=this;
  1771. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1772. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1773. return smalltalk.withContext(function($ctx1) {
  1774. self._push_(_st(_st($Smalltalk())._current())._at_ifAbsent_(_st(aNode)._value(),(function(){
  1775. return smalltalk.withContext(function($ctx2) {
  1776. return _st(_st($PlatformInterface())._globals())._at_(_st(aNode)._value());
  1777. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})));
  1778. return self}, function($ctx1) {$ctx1.fill(self,"visitClassReferenceNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1779. args: ["aNode"],
  1780. source: "visitClassReferenceNode: aNode\x0a\x09self push: (Smalltalk current \x0a\x09\x09at: aNode value \x0a\x09\x09ifAbsent: [ PlatformInterface globals at: aNode value ])",
  1781. messageSends: ["push:", "at:ifAbsent:", "current", "value", "at:", "globals"],
  1782. referencedClasses: ["Smalltalk", "PlatformInterface"]
  1783. }),
  1784. smalltalk.ASTInterpreter);
  1785. smalltalk.addMethod(
  1786. smalltalk.method({
  1787. selector: "visitDynamicArrayNode:",
  1788. category: 'visiting',
  1789. fn: function (aNode){
  1790. var self=this;
  1791. var array;
  1792. return smalltalk.withContext(function($ctx1) {
  1793. array=[];
  1794. _st(_st(aNode)._nodes())._do_((function(each){
  1795. return smalltalk.withContext(function($ctx2) {
  1796. return _st(array)._addFirst_(self._pop());
  1797. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1798. self._push_(array);
  1799. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},smalltalk.ASTInterpreter)})},
  1800. args: ["aNode"],
  1801. 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",
  1802. messageSends: ["do:", "nodes", "addFirst:", "pop", "push:"],
  1803. referencedClasses: []
  1804. }),
  1805. smalltalk.ASTInterpreter);
  1806. smalltalk.addMethod(
  1807. smalltalk.method({
  1808. selector: "visitDynamicDictionaryNode:",
  1809. category: 'visiting',
  1810. fn: function (aNode){
  1811. var self=this;
  1812. var hashedCollection;
  1813. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1814. return smalltalk.withContext(function($ctx1) {
  1815. hashedCollection=_st($HashedCollection())._new();
  1816. _st(_st(aNode)._nodes())._do_((function(each){
  1817. return smalltalk.withContext(function($ctx2) {
  1818. return _st(hashedCollection)._add_(self._pop());
  1819. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1820. self._push_(hashedCollection);
  1821. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,hashedCollection:hashedCollection},smalltalk.ASTInterpreter)})},
  1822. args: ["aNode"],
  1823. source: "visitDynamicDictionaryNode: aNode\x0a\x09| hashedCollection |\x0a\x09\x0a\x09hashedCollection := HashedCollection new.\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09hashedCollection add: self pop ].\x0a\x09\x0a\x09self push: hashedCollection",
  1824. messageSends: ["new", "do:", "nodes", "add:", "pop", "push:"],
  1825. referencedClasses: ["HashedCollection"]
  1826. }),
  1827. smalltalk.ASTInterpreter);
  1828. smalltalk.addMethod(
  1829. smalltalk.method({
  1830. selector: "visitJSStatementNode:",
  1831. category: 'visiting',
  1832. fn: function (aNode){
  1833. var self=this;
  1834. return smalltalk.withContext(function($ctx1) {
  1835. self["@returned"]=true;
  1836. self._returnValue_(self._eval_(_st(aNode)._source()));
  1837. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1838. args: ["aNode"],
  1839. source: "visitJSStatementNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: (self eval: aNode source)",
  1840. messageSends: ["returnValue:", "eval:", "source"],
  1841. referencedClasses: []
  1842. }),
  1843. smalltalk.ASTInterpreter);
  1844. smalltalk.addMethod(
  1845. smalltalk.method({
  1846. selector: "visitNode:",
  1847. category: 'visiting',
  1848. fn: function (aNode){
  1849. var self=this;
  1850. return smalltalk.withContext(function($ctx1) {
  1851. return self}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1852. args: ["aNode"],
  1853. source: "visitNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
  1854. messageSends: [],
  1855. referencedClasses: []
  1856. }),
  1857. smalltalk.ASTInterpreter);
  1858. smalltalk.addMethod(
  1859. smalltalk.method({
  1860. selector: "visitReturnNode:",
  1861. category: 'visiting',
  1862. fn: function (aNode){
  1863. var self=this;
  1864. return smalltalk.withContext(function($ctx1) {
  1865. self["@returned"]=true;
  1866. self._returnValue_(self._pop());
  1867. return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1868. args: ["aNode"],
  1869. source: "visitReturnNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: self pop",
  1870. messageSends: ["returnValue:", "pop"],
  1871. referencedClasses: []
  1872. }),
  1873. smalltalk.ASTInterpreter);
  1874. smalltalk.addMethod(
  1875. smalltalk.method({
  1876. selector: "visitSendNode:",
  1877. category: 'visiting',
  1878. fn: function (aNode){
  1879. var self=this;
  1880. var receiver,args,message,result;
  1881. return smalltalk.withContext(function($ctx1) {
  1882. var $1;
  1883. args=_st(_st(aNode)._arguments())._collect_((function(each){
  1884. return smalltalk.withContext(function($ctx2) {
  1885. return self._pop();
  1886. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1887. receiver=self._pop();
  1888. message=self._messageFromSendNode_arguments_(aNode,_st(args)._reversed());
  1889. result=self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend());
  1890. _st(self._context())._pc_(_st(_st(self._context())._pc()).__plus((1)));
  1891. $1=_st(_st(aNode)._isCascadeSendNode())._and_((function(){
  1892. return smalltalk.withContext(function($ctx2) {
  1893. return _st(_st(aNode)._isLastChild())._not();
  1894. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1895. if(smalltalk.assert($1)){
  1896. self._push_(receiver);
  1897. } else {
  1898. self._push_(result);
  1899. };
  1900. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},smalltalk.ASTInterpreter)})},
  1901. args: ["aNode"],
  1902. 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\x09self context pc: self context pc + 1.\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 ]",
  1903. messageSends: ["collect:", "arguments", "pop", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "pc:", "context", "+", "pc", "ifTrue:ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"],
  1904. referencedClasses: []
  1905. }),
  1906. smalltalk.ASTInterpreter);
  1907. smalltalk.addMethod(
  1908. smalltalk.method({
  1909. selector: "visitValueNode:",
  1910. category: 'visiting',
  1911. fn: function (aNode){
  1912. var self=this;
  1913. return smalltalk.withContext(function($ctx1) {
  1914. self._push_(_st(aNode)._value());
  1915. return self}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1916. args: ["aNode"],
  1917. source: "visitValueNode: aNode\x0a\x09self push: aNode value",
  1918. messageSends: ["push:", "value"],
  1919. referencedClasses: []
  1920. }),
  1921. smalltalk.ASTInterpreter);
  1922. smalltalk.addMethod(
  1923. smalltalk.method({
  1924. selector: "visitVariableNode:",
  1925. category: 'visiting',
  1926. fn: function (aNode){
  1927. var self=this;
  1928. function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
  1929. return smalltalk.withContext(function($ctx1) {
  1930. var $1,$2,$3,$5,$4;
  1931. $1=_st(_st(aNode)._binding())._isUnknownVar();
  1932. if(smalltalk.assert($1)){
  1933. $2=self._push_(_st(_st($PlatformInterface())._globals())._at_ifAbsent_(_st(aNode)._value(),(function(){
  1934. return smalltalk.withContext(function($ctx2) {
  1935. return self._error_("Unknown variable");
  1936. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})));
  1937. return $2;
  1938. };
  1939. $3=self;
  1940. $5=_st(_st(aNode)._binding())._isInstanceVar();
  1941. if(smalltalk.assert($5)){
  1942. $4=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
  1943. } else {
  1944. $4=_st(self._context())._localAt_(_st(aNode)._value());
  1945. };
  1946. _st($3)._push_($4);
  1947. return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1948. args: ["aNode"],
  1949. 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 localAt: aNode value ])",
  1950. messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "globals", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:"],
  1951. referencedClasses: ["PlatformInterface"]
  1952. }),
  1953. smalltalk.ASTInterpreter);
  1954. smalltalk.addClass('ASTPCNodeVisitor', smalltalk.NodeVisitor, ['useInlinings', 'pc', 'context', 'blockIndex', 'currentNode'], 'Compiler-Interpreter');
  1955. smalltalk.ASTPCNodeVisitor.comment="I visit an AST until I get to the current pc node 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 corresponding to the `pc` is answered by `#currentNode`";
  1956. smalltalk.addMethod(
  1957. smalltalk.method({
  1958. selector: "blockIndex",
  1959. category: 'accessing',
  1960. fn: function (){
  1961. var self=this;
  1962. return smalltalk.withContext(function($ctx1) {
  1963. var $2,$1;
  1964. $2=self["@blockIndex"];
  1965. if(($receiver = $2) == nil || $receiver == undefined){
  1966. self["@blockIndex"]=(0);
  1967. $1=self["@blockIndex"];
  1968. } else {
  1969. $1=$2;
  1970. };
  1971. return $1;
  1972. }, function($ctx1) {$ctx1.fill(self,"blockIndex",{},smalltalk.ASTPCNodeVisitor)})},
  1973. args: [],
  1974. source: "blockIndex\x0a\x09^ blockIndex ifNil: [ blockIndex := 0 ]",
  1975. messageSends: ["ifNil:"],
  1976. referencedClasses: []
  1977. }),
  1978. smalltalk.ASTPCNodeVisitor);
  1979. smalltalk.addMethod(
  1980. smalltalk.method({
  1981. selector: "context",
  1982. category: 'accessing',
  1983. fn: function (){
  1984. var self=this;
  1985. return smalltalk.withContext(function($ctx1) {
  1986. var $1;
  1987. $1=self["@context"];
  1988. return $1;
  1989. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTPCNodeVisitor)})},
  1990. args: [],
  1991. source: "context\x0a\x09^ context",
  1992. messageSends: [],
  1993. referencedClasses: []
  1994. }),
  1995. smalltalk.ASTPCNodeVisitor);
  1996. smalltalk.addMethod(
  1997. smalltalk.method({
  1998. selector: "context:",
  1999. category: 'accessing',
  2000. fn: function (aContext){
  2001. var self=this;
  2002. return smalltalk.withContext(function($ctx1) {
  2003. self["@context"]=aContext;
  2004. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTPCNodeVisitor)})},
  2005. args: ["aContext"],
  2006. source: "context: aContext\x0a\x09context := aContext",
  2007. messageSends: [],
  2008. referencedClasses: []
  2009. }),
  2010. smalltalk.ASTPCNodeVisitor);
  2011. smalltalk.addMethod(
  2012. smalltalk.method({
  2013. selector: "currentNode",
  2014. category: 'accessing',
  2015. fn: function (){
  2016. var self=this;
  2017. return smalltalk.withContext(function($ctx1) {
  2018. var $1;
  2019. $1=self["@currentNode"];
  2020. return $1;
  2021. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTPCNodeVisitor)})},
  2022. args: [],
  2023. source: "currentNode\x0a\x09^ currentNode",
  2024. messageSends: [],
  2025. referencedClasses: []
  2026. }),
  2027. smalltalk.ASTPCNodeVisitor);
  2028. smalltalk.addMethod(
  2029. smalltalk.method({
  2030. selector: "increaseBlockIndex",
  2031. category: 'accessing',
  2032. fn: function (){
  2033. var self=this;
  2034. return smalltalk.withContext(function($ctx1) {
  2035. self["@blockIndex"]=_st(self._blockIndex()).__plus((1));
  2036. return self}, function($ctx1) {$ctx1.fill(self,"increaseBlockIndex",{},smalltalk.ASTPCNodeVisitor)})},
  2037. args: [],
  2038. source: "increaseBlockIndex\x0a\x09blockIndex := self blockIndex + 1",
  2039. messageSends: ["+", "blockIndex"],
  2040. referencedClasses: []
  2041. }),
  2042. smalltalk.ASTPCNodeVisitor);
  2043. smalltalk.addMethod(
  2044. smalltalk.method({
  2045. selector: "pc",
  2046. category: 'accessing',
  2047. fn: function (){
  2048. var self=this;
  2049. return smalltalk.withContext(function($ctx1) {
  2050. var $2,$1;
  2051. $2=self["@pc"];
  2052. if(($receiver = $2) == nil || $receiver == undefined){
  2053. $1=(0);
  2054. } else {
  2055. $1=$2;
  2056. };
  2057. return $1;
  2058. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.ASTPCNodeVisitor)})},
  2059. args: [],
  2060. source: "pc\x0a\x09^ pc ifNil: [ 0 ]",
  2061. messageSends: ["ifNil:"],
  2062. referencedClasses: []
  2063. }),
  2064. smalltalk.ASTPCNodeVisitor);
  2065. smalltalk.addMethod(
  2066. smalltalk.method({
  2067. selector: "pc:",
  2068. category: 'accessing',
  2069. fn: function (anInteger){
  2070. var self=this;
  2071. return smalltalk.withContext(function($ctx1) {
  2072. self["@pc"]=anInteger;
  2073. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitor)})},
  2074. args: ["anInteger"],
  2075. source: "pc: anInteger\x0a\x09pc := anInteger",
  2076. messageSends: [],
  2077. referencedClasses: []
  2078. }),
  2079. smalltalk.ASTPCNodeVisitor);
  2080. smalltalk.addMethod(
  2081. smalltalk.method({
  2082. selector: "useInlinings",
  2083. category: 'accessing',
  2084. fn: function (){
  2085. var self=this;
  2086. return smalltalk.withContext(function($ctx1) {
  2087. var $2,$1;
  2088. $2=self["@useInlinings"];
  2089. if(($receiver = $2) == nil || $receiver == undefined){
  2090. $1=true;
  2091. } else {
  2092. $1=$2;
  2093. };
  2094. return $1;
  2095. }, function($ctx1) {$ctx1.fill(self,"useInlinings",{},smalltalk.ASTPCNodeVisitor)})},
  2096. args: [],
  2097. source: "useInlinings\x0a\x09^ useInlinings ifNil: [ true ]",
  2098. messageSends: ["ifNil:"],
  2099. referencedClasses: []
  2100. }),
  2101. smalltalk.ASTPCNodeVisitor);
  2102. smalltalk.addMethod(
  2103. smalltalk.method({
  2104. selector: "useInlinings:",
  2105. category: 'accessing',
  2106. fn: function (aBoolean){
  2107. var self=this;
  2108. return smalltalk.withContext(function($ctx1) {
  2109. self["@useInlinings"]=aBoolean;
  2110. return self}, function($ctx1) {$ctx1.fill(self,"useInlinings:",{aBoolean:aBoolean},smalltalk.ASTPCNodeVisitor)})},
  2111. args: ["aBoolean"],
  2112. source: "useInlinings: aBoolean\x0a\x09useInlinings := aBoolean",
  2113. messageSends: [],
  2114. referencedClasses: []
  2115. }),
  2116. smalltalk.ASTPCNodeVisitor);
  2117. smalltalk.addMethod(
  2118. smalltalk.method({
  2119. selector: "visitBlockNode:",
  2120. category: 'visiting',
  2121. fn: function (aNode){
  2122. var self=this;
  2123. return smalltalk.withContext(function($ctx1) {
  2124. var $1,$2;
  2125. $1=_st(_st(_st(aNode)._parent())._isSendNode())._and_((function(){
  2126. return smalltalk.withContext(function($ctx2) {
  2127. return _st(_st(aNode)._parent())._shouldBeInlined();
  2128. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2129. if(smalltalk.assert($1)){
  2130. smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  2131. } else {
  2132. $2=_st(self._blockIndex()).__gt_eq(_st(self._context())._index());
  2133. if(! smalltalk.assert($2)){
  2134. self._increaseBlockIndex();
  2135. smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  2136. };
  2137. };
  2138. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2139. args: ["aNode"],
  2140. source: "visitBlockNode: aNode\x0a\x09\x22Inlined send node. Assume that the block is inlined\x22\x0a\x09(aNode parent isSendNode and: [ aNode parent shouldBeInlined ])\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09self blockIndex >= self context index ifFalse: [\x0a\x09\x09\x09\x09self increaseBlockIndex.\x0a\x09\x09\x09\x09super visitBlockNode: aNode ] ]\x0a\x09\x09ifTrue: [ super visitBlockNode: aNode ]",
  2141. messageSends: ["ifFalse:ifTrue:", "and:", "isSendNode", "parent", "shouldBeInlined", "ifFalse:", ">=", "blockIndex", "index", "context", "increaseBlockIndex", "visitBlockNode:"],
  2142. referencedClasses: []
  2143. }),
  2144. smalltalk.ASTPCNodeVisitor);
  2145. smalltalk.addMethod(
  2146. smalltalk.method({
  2147. selector: "visitJSStatementNode:",
  2148. category: 'visiting',
  2149. fn: function (aNode){
  2150. var self=this;
  2151. return smalltalk.withContext(function($ctx1) {
  2152. self["@currentNode"]=aNode;
  2153. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2154. args: ["aNode"],
  2155. source: "visitJSStatementNode: aNode\x0a\x09currentNode := aNode",
  2156. messageSends: [],
  2157. referencedClasses: []
  2158. }),
  2159. smalltalk.ASTPCNodeVisitor);
  2160. smalltalk.addMethod(
  2161. smalltalk.method({
  2162. selector: "visitSendNode:",
  2163. category: 'visiting',
  2164. fn: function (aNode){
  2165. var self=this;
  2166. return smalltalk.withContext(function($ctx1) {
  2167. var $1,$2,$3;
  2168. smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  2169. $1=_st(self._pc()).__eq(_st(self._context())._pc());
  2170. if(! smalltalk.assert($1)){
  2171. $2=_st(aNode)._shouldBeInlined();
  2172. if(! smalltalk.assert($2)){
  2173. $3=_st(self._blockIndex()).__eq(_st(self._context())._index());
  2174. if(smalltalk.assert($3)){
  2175. self._pc_(_st(self._pc()).__plus((1)));
  2176. self["@currentNode"]=aNode;
  2177. self["@currentNode"];
  2178. };
  2179. };
  2180. };
  2181. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  2182. args: ["aNode"],
  2183. source: "visitSendNode: aNode\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self pc = self context pc ifFalse: [\x0a\x09\x09aNode shouldBeInlined ifFalse: [\x0a\x09\x09\x09self blockIndex = self context index ifTrue: [\x0a\x09\x09\x09\x09self pc: self pc + 1.\x0a\x09\x09\x09\x09currentNode := aNode ] ] ]",
  2184. messageSends: ["visitSendNode:", "ifFalse:", "=", "pc", "context", "shouldBeInlined", "ifTrue:", "blockIndex", "index", "pc:", "+"],
  2185. referencedClasses: []
  2186. }),
  2187. smalltalk.ASTPCNodeVisitor);
  2188. smalltalk.addMethod(
  2189. smalltalk.method({
  2190. selector: "interpreter:continue:",
  2191. category: '*Compiler-Interpreter',
  2192. fn: function (anInterpreter,aBlock){
  2193. var self=this;
  2194. return smalltalk.withContext(function($ctx1) {
  2195. var $1;
  2196. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  2197. return $1;
  2198. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.Node)})},
  2199. args: ["anInterpreter", "aBlock"],
  2200. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  2201. messageSends: ["interpretNode:continue:"],
  2202. referencedClasses: []
  2203. }),
  2204. smalltalk.Node);
  2205. smalltalk.addMethod(
  2206. smalltalk.method({
  2207. selector: "isSteppingNode",
  2208. category: '*Compiler-Interpreter',
  2209. fn: function (){
  2210. var self=this;
  2211. return smalltalk.withContext(function($ctx1) {
  2212. return false;
  2213. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
  2214. args: [],
  2215. source: "isSteppingNode\x0a\x09^ false",
  2216. messageSends: [],
  2217. referencedClasses: []
  2218. }),
  2219. smalltalk.Node);
  2220. smalltalk.addMethod(
  2221. smalltalk.method({
  2222. selector: "interpreter:continue:",
  2223. category: '*Compiler-Interpreter',
  2224. fn: function (anInterpreter,aBlock){
  2225. var self=this;
  2226. return smalltalk.withContext(function($ctx1) {
  2227. var $1;
  2228. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  2229. return $1;
  2230. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.AssignmentNode)})},
  2231. args: ["anInterpreter", "aBlock"],
  2232. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  2233. messageSends: ["interpretAssignmentNode:continue:"],
  2234. referencedClasses: []
  2235. }),
  2236. smalltalk.AssignmentNode);
  2237. smalltalk.addMethod(
  2238. smalltalk.method({
  2239. selector: "isSteppingNode",
  2240. category: '*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.AssignmentNode)})},
  2246. args: [],
  2247. source: "isSteppingNode\x0a\x09^ true",
  2248. messageSends: [],
  2249. referencedClasses: []
  2250. }),
  2251. smalltalk.AssignmentNode);
  2252. smalltalk.addMethod(
  2253. smalltalk.method({
  2254. selector: "interpreter:continue:",
  2255. category: '*Compiler-Interpreter',
  2256. fn: function (anInterpreter,aBlock){
  2257. var self=this;
  2258. return smalltalk.withContext(function($ctx1) {
  2259. var $1;
  2260. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  2261. return $1;
  2262. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockNode)})},
  2263. args: ["anInterpreter", "aBlock"],
  2264. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  2265. messageSends: ["interpretBlockNode:continue:"],
  2266. referencedClasses: []
  2267. }),
  2268. smalltalk.BlockNode);
  2269. smalltalk.addMethod(
  2270. smalltalk.method({
  2271. selector: "isSteppingNode",
  2272. category: '*Compiler-Interpreter',
  2273. fn: function (){
  2274. var self=this;
  2275. return smalltalk.withContext(function($ctx1) {
  2276. return true;
  2277. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
  2278. args: [],
  2279. source: "isSteppingNode\x0a\x09^ true",
  2280. messageSends: [],
  2281. referencedClasses: []
  2282. }),
  2283. smalltalk.BlockNode);
  2284. smalltalk.addMethod(
  2285. smalltalk.method({
  2286. selector: "interpreter:continue:",
  2287. category: '*Compiler-Interpreter',
  2288. fn: function (anInterpreter,aBlock){
  2289. var self=this;
  2290. return smalltalk.withContext(function($ctx1) {
  2291. var $1;
  2292. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  2293. return $1;
  2294. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.CascadeNode)})},
  2295. args: ["anInterpreter", "aBlock"],
  2296. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  2297. messageSends: ["interpretCascadeNode:continue:"],
  2298. referencedClasses: []
  2299. }),
  2300. smalltalk.CascadeNode);
  2301. smalltalk.addMethod(
  2302. smalltalk.method({
  2303. selector: "interpreter:continue:",
  2304. category: '*Compiler-Interpreter',
  2305. fn: function (anInterpreter,aBlock){
  2306. var self=this;
  2307. return smalltalk.withContext(function($ctx1) {
  2308. var $1;
  2309. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  2310. return $1;
  2311. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicArrayNode)})},
  2312. args: ["anInterpreter", "aBlock"],
  2313. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  2314. messageSends: ["interpretDynamicArrayNode:continue:"],
  2315. referencedClasses: []
  2316. }),
  2317. smalltalk.DynamicArrayNode);
  2318. smalltalk.addMethod(
  2319. smalltalk.method({
  2320. selector: "isSteppingNode",
  2321. category: '*Compiler-Interpreter',
  2322. fn: function (){
  2323. var self=this;
  2324. return smalltalk.withContext(function($ctx1) {
  2325. return true;
  2326. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
  2327. args: [],
  2328. source: "isSteppingNode\x0a\x09^ true",
  2329. messageSends: [],
  2330. referencedClasses: []
  2331. }),
  2332. smalltalk.DynamicArrayNode);
  2333. smalltalk.addMethod(
  2334. smalltalk.method({
  2335. selector: "interpreter:continue:",
  2336. category: '*Compiler-Interpreter',
  2337. fn: function (anInterpreter,aBlock){
  2338. var self=this;
  2339. return smalltalk.withContext(function($ctx1) {
  2340. var $1;
  2341. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  2342. return $1;
  2343. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicDictionaryNode)})},
  2344. args: ["anInterpreter", "aBlock"],
  2345. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  2346. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  2347. referencedClasses: []
  2348. }),
  2349. smalltalk.DynamicDictionaryNode);
  2350. smalltalk.addMethod(
  2351. smalltalk.method({
  2352. selector: "isSteppingNode",
  2353. category: '*Compiler-Interpreter',
  2354. fn: function (){
  2355. var self=this;
  2356. return smalltalk.withContext(function($ctx1) {
  2357. return true;
  2358. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
  2359. args: [],
  2360. source: "isSteppingNode\x0a\x09^ true",
  2361. messageSends: [],
  2362. referencedClasses: []
  2363. }),
  2364. smalltalk.DynamicDictionaryNode);
  2365. smalltalk.addMethod(
  2366. smalltalk.method({
  2367. selector: "interpreter:continue:",
  2368. category: '*Compiler-Interpreter',
  2369. fn: function (anInterpreter,aBlock){
  2370. var self=this;
  2371. return smalltalk.withContext(function($ctx1) {
  2372. var $1;
  2373. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  2374. return $1;
  2375. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.JSStatementNode)})},
  2376. args: ["anInterpreter", "aBlock"],
  2377. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  2378. messageSends: ["interpretJSStatementNode:continue:"],
  2379. referencedClasses: []
  2380. }),
  2381. smalltalk.JSStatementNode);
  2382. smalltalk.addMethod(
  2383. smalltalk.method({
  2384. selector: "isSteppingNode",
  2385. category: '*Compiler-Interpreter',
  2386. fn: function (){
  2387. var self=this;
  2388. return smalltalk.withContext(function($ctx1) {
  2389. return true;
  2390. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
  2391. args: [],
  2392. source: "isSteppingNode\x0a\x09^ true",
  2393. messageSends: [],
  2394. referencedClasses: []
  2395. }),
  2396. smalltalk.JSStatementNode);
  2397. smalltalk.addMethod(
  2398. smalltalk.method({
  2399. selector: "interpreter:continue:",
  2400. category: '*Compiler-Interpreter',
  2401. fn: function (anInterpreter,aBlock){
  2402. var self=this;
  2403. return smalltalk.withContext(function($ctx1) {
  2404. var $1;
  2405. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  2406. return $1;
  2407. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.MethodNode)})},
  2408. args: ["anInterpreter", "aBlock"],
  2409. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  2410. messageSends: ["interpretMethodNode:continue:"],
  2411. referencedClasses: []
  2412. }),
  2413. smalltalk.MethodNode);
  2414. smalltalk.addMethod(
  2415. smalltalk.method({
  2416. selector: "interpreter:continue:",
  2417. category: '*Compiler-Interpreter',
  2418. fn: function (anInterpreter,aBlock){
  2419. var self=this;
  2420. return smalltalk.withContext(function($ctx1) {
  2421. var $1;
  2422. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  2423. return $1;
  2424. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ReturnNode)})},
  2425. args: ["anInterpreter", "aBlock"],
  2426. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  2427. messageSends: ["interpretReturnNode:continue:"],
  2428. referencedClasses: []
  2429. }),
  2430. smalltalk.ReturnNode);
  2431. smalltalk.addMethod(
  2432. smalltalk.method({
  2433. selector: "interpreter:continue:",
  2434. category: '*Compiler-Interpreter',
  2435. fn: function (anInterpreter,aBlock){
  2436. var self=this;
  2437. return smalltalk.withContext(function($ctx1) {
  2438. var $1;
  2439. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  2440. return $1;
  2441. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SendNode)})},
  2442. args: ["anInterpreter", "aBlock"],
  2443. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  2444. messageSends: ["interpretSendNode:continue:"],
  2445. referencedClasses: []
  2446. }),
  2447. smalltalk.SendNode);
  2448. smalltalk.addMethod(
  2449. smalltalk.method({
  2450. selector: "isSteppingNode",
  2451. category: '*Compiler-Interpreter',
  2452. fn: function (){
  2453. var self=this;
  2454. return smalltalk.withContext(function($ctx1) {
  2455. return true;
  2456. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
  2457. args: [],
  2458. source: "isSteppingNode\x0a\x09^ true",
  2459. messageSends: [],
  2460. referencedClasses: []
  2461. }),
  2462. smalltalk.SendNode);
  2463. smalltalk.addMethod(
  2464. smalltalk.method({
  2465. selector: "interpreter:continue:",
  2466. category: '*Compiler-Interpreter',
  2467. fn: function (anInterpreter,aBlock){
  2468. var self=this;
  2469. return smalltalk.withContext(function($ctx1) {
  2470. var $1;
  2471. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  2472. return $1;
  2473. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SequenceNode)})},
  2474. args: ["anInterpreter", "aBlock"],
  2475. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  2476. messageSends: ["interpretSequenceNode:continue:"],
  2477. referencedClasses: []
  2478. }),
  2479. smalltalk.SequenceNode);
  2480. smalltalk.addMethod(
  2481. smalltalk.method({
  2482. selector: "interpreter:continue:",
  2483. category: '*Compiler-Interpreter',
  2484. fn: function (anInterpreter,aBlock){
  2485. var self=this;
  2486. return smalltalk.withContext(function($ctx1) {
  2487. var $1;
  2488. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  2489. return $1;
  2490. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockSequenceNode)})},
  2491. args: ["anInterpreter", "aBlock"],
  2492. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  2493. messageSends: ["interpretBlockSequenceNode:continue:"],
  2494. referencedClasses: []
  2495. }),
  2496. smalltalk.BlockSequenceNode);
  2497. smalltalk.addMethod(
  2498. smalltalk.method({
  2499. selector: "interpreter:continue:",
  2500. category: '*Compiler-Interpreter',
  2501. fn: function (anInterpreter,aBlock){
  2502. var self=this;
  2503. return smalltalk.withContext(function($ctx1) {
  2504. var $1;
  2505. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  2506. return $1;
  2507. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ValueNode)})},
  2508. args: ["anInterpreter", "aBlock"],
  2509. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  2510. messageSends: ["interpretValueNode:continue:"],
  2511. referencedClasses: []
  2512. }),
  2513. smalltalk.ValueNode);
  2514. smalltalk.addMethod(
  2515. smalltalk.method({
  2516. selector: "interpreter:continue:",
  2517. category: '*Compiler-Interpreter',
  2518. fn: function (anInterpreter,aBlock){
  2519. var self=this;
  2520. return smalltalk.withContext(function($ctx1) {
  2521. var $1;
  2522. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  2523. return $1;
  2524. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.VariableNode)})},
  2525. args: ["anInterpreter", "aBlock"],
  2526. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  2527. messageSends: ["interpretVariableNode:continue:"],
  2528. referencedClasses: []
  2529. }),
  2530. smalltalk.VariableNode);
  2531. smalltalk.addMethod(
  2532. smalltalk.method({
  2533. selector: "interpreter:continue:",
  2534. category: '*Compiler-Interpreter',
  2535. fn: function (anInterpreter,aBlock){
  2536. var self=this;
  2537. return smalltalk.withContext(function($ctx1) {
  2538. var $1;
  2539. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  2540. return $1;
  2541. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ClassReferenceNode)})},
  2542. args: ["anInterpreter", "aBlock"],
  2543. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  2544. messageSends: ["interpretClassReferenceNode:continue:"],
  2545. referencedClasses: []
  2546. }),
  2547. smalltalk.ClassReferenceNode);
  2548. });