Compiler-Interpreter.js 95 KB

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