Compiler-Interpreter.js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759
  1. smalltalk.addPackage('Compiler-Interpreter');
  2. smalltalk.addClass('AIContext', smalltalk.NodeVisitor, ['outerContext', 'pc', 'locals', 'method'], 'Compiler-Interpreter');
  3. smalltalk.AIContext.comment="AIContext is like a `MethodContext`, used by the `ASTInterpreter`.\x0aUnlike a `MethodContext`, it is not read-only.\x0a\x0aWhen debugging, `AIContext` instances are created by copying the current `MethodContext` (thisContext)"
  4. smalltalk.addMethod(
  5. "_initializeFromMethodContext_",
  6. smalltalk.method({
  7. selector: "initializeFromMethodContext:",
  8. category: 'initialization',
  9. fn: function (aMethodContext){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) {
  12. var $1;
  13. _st(self)._pc_(_st(aMethodContext)._pc());
  14. _st(self)._receiver_(_st(aMethodContext)._receiver());
  15. _st(self)._method_(_st(aMethodContext)._method());
  16. $1=_st(aMethodContext)._outerContext();
  17. if(($receiver = $1) == nil || $receiver == undefined){
  18. $1;
  19. } else {
  20. _st(self)._outerContext_(_st(_st(self)._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
  21. };
  22. _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
  23. return smalltalk.withContext(function($ctx2) {
  24. return _st(_st(self)._locals())._at_put_(key,value);
  25. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  26. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext)})},
  27. args: ["aMethodContext"],
  28. source: "initializeFromMethodContext: aMethodContext\x0a\x09self pc: aMethodContext pc.\x0a\x09self receiver: aMethodContext receiver.\x0a\x09self method: aMethodContext method.\x0a\x09aMethodContext outerContext ifNotNil: [\x0a\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a\x09aMethodContext locals keysAndValuesDo: [ :key :value |\x0a\x09\x09self locals at: key put: value ]",
  29. messageSends: ["pc:", "pc", "receiver:", "receiver", "method:", "method", "ifNotNil:", "outerContext:", "fromMethodContext:", "outerContext", "class", "keysAndValuesDo:", "at:put:", "locals"],
  30. referencedClasses: []
  31. }),
  32. smalltalk.AIContext);
  33. smalltalk.addMethod(
  34. "_localAt_",
  35. smalltalk.method({
  36. selector: "localAt:",
  37. category: 'accessing',
  38. fn: function (aString){
  39. var self=this;
  40. return smalltalk.withContext(function($ctx1) {
  41. var $1;
  42. $1=_st(_st(self)._locals())._at_ifAbsent_(aString,(function(){
  43. return smalltalk.withContext(function($ctx2) {
  44. return nil;
  45. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  46. return $1;
  47. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},smalltalk.AIContext)})},
  48. args: ["aString"],
  49. source: "localAt: aString\x0a\x09^ self locals at: aString ifAbsent: [ nil ]",
  50. messageSends: ["at:ifAbsent:", "locals"],
  51. referencedClasses: []
  52. }),
  53. smalltalk.AIContext);
  54. smalltalk.addMethod(
  55. "_localAt_put_",
  56. smalltalk.method({
  57. selector: "localAt:put:",
  58. category: 'accessing',
  59. fn: function (aString,anObject){
  60. var self=this;
  61. return smalltalk.withContext(function($ctx1) {
  62. _st(_st(self)._locals())._at_put_(aString,anObject);
  63. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},smalltalk.AIContext)})},
  64. args: ["aString", "anObject"],
  65. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  66. messageSends: ["at:put:", "locals"],
  67. referencedClasses: []
  68. }),
  69. smalltalk.AIContext);
  70. smalltalk.addMethod(
  71. "_locals",
  72. smalltalk.method({
  73. selector: "locals",
  74. category: 'accessing',
  75. fn: function (){
  76. var self=this;
  77. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  78. return smalltalk.withContext(function($ctx1) {
  79. var $2,$1;
  80. $2=self["@locals"];
  81. if(($receiver = $2) == nil || $receiver == undefined){
  82. self["@locals"]=_st($Dictionary())._new();
  83. $1=self["@locals"];
  84. } else {
  85. $1=$2;
  86. };
  87. return $1;
  88. }, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.AIContext)})},
  89. args: [],
  90. source: "locals\x0a\x09^ locals ifNil: [ locals := Dictionary new ]",
  91. messageSends: ["ifNil:", "new"],
  92. referencedClasses: ["Dictionary"]
  93. }),
  94. smalltalk.AIContext);
  95. smalltalk.addMethod(
  96. "_method",
  97. smalltalk.method({
  98. selector: "method",
  99. category: 'accessing',
  100. fn: function (){
  101. var self=this;
  102. return smalltalk.withContext(function($ctx1) {
  103. var $1;
  104. $1=self["@method"];
  105. return $1;
  106. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.AIContext)})},
  107. args: [],
  108. source: "method\x0a\x09^ method",
  109. messageSends: [],
  110. referencedClasses: []
  111. }),
  112. smalltalk.AIContext);
  113. smalltalk.addMethod(
  114. "_method_",
  115. smalltalk.method({
  116. selector: "method:",
  117. category: 'accessing',
  118. fn: function (aCompiledMethod){
  119. var self=this;
  120. return smalltalk.withContext(function($ctx1) {
  121. self["@method"]=aCompiledMethod;
  122. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod},smalltalk.AIContext)})},
  123. args: ["aCompiledMethod"],
  124. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  125. messageSends: [],
  126. referencedClasses: []
  127. }),
  128. smalltalk.AIContext);
  129. smalltalk.addMethod(
  130. "_outerContext",
  131. smalltalk.method({
  132. selector: "outerContext",
  133. category: 'accessing',
  134. fn: function (){
  135. var self=this;
  136. return smalltalk.withContext(function($ctx1) {
  137. var $1;
  138. $1=self["@outerContext"];
  139. return $1;
  140. }, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.AIContext)})},
  141. args: [],
  142. source: "outerContext\x0a\x09^ outerContext",
  143. messageSends: [],
  144. referencedClasses: []
  145. }),
  146. smalltalk.AIContext);
  147. smalltalk.addMethod(
  148. "_outerContext_",
  149. smalltalk.method({
  150. selector: "outerContext:",
  151. category: 'accessing',
  152. fn: function (anAIContext){
  153. var self=this;
  154. return smalltalk.withContext(function($ctx1) {
  155. self["@outerContext"]=anAIContext;
  156. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  157. args: ["anAIContext"],
  158. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext",
  159. messageSends: [],
  160. referencedClasses: []
  161. }),
  162. smalltalk.AIContext);
  163. smalltalk.addMethod(
  164. "_pc",
  165. smalltalk.method({
  166. selector: "pc",
  167. category: 'accessing',
  168. fn: function (){
  169. var self=this;
  170. return smalltalk.withContext(function($ctx1) {
  171. var $2,$1;
  172. $2=self["@pc"];
  173. if(($receiver = $2) == nil || $receiver == undefined){
  174. self["@pc"]=(0);
  175. $1=self["@pc"];
  176. } else {
  177. $1=$2;
  178. };
  179. return $1;
  180. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.AIContext)})},
  181. args: [],
  182. source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
  183. messageSends: ["ifNil:"],
  184. referencedClasses: []
  185. }),
  186. smalltalk.AIContext);
  187. smalltalk.addMethod(
  188. "_pc_",
  189. smalltalk.method({
  190. selector: "pc:",
  191. category: 'accessing',
  192. fn: function (anInteger){
  193. var self=this;
  194. return smalltalk.withContext(function($ctx1) {
  195. self["@pc"]=anInteger;
  196. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.AIContext)})},
  197. args: ["anInteger"],
  198. source: "pc: anInteger\x0a\x09pc := anInteger",
  199. messageSends: [],
  200. referencedClasses: []
  201. }),
  202. smalltalk.AIContext);
  203. smalltalk.addMethod(
  204. "_receiver",
  205. smalltalk.method({
  206. selector: "receiver",
  207. category: 'accessing',
  208. fn: function (){
  209. var self=this;
  210. return smalltalk.withContext(function($ctx1) {
  211. var $1;
  212. $1=_st(self)._localAt_("self");
  213. return $1;
  214. }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AIContext)})},
  215. args: [],
  216. source: "receiver\x0a\x09^ self localAt: 'self'",
  217. messageSends: ["localAt:"],
  218. referencedClasses: []
  219. }),
  220. smalltalk.AIContext);
  221. smalltalk.addMethod(
  222. "_receiver_",
  223. smalltalk.method({
  224. selector: "receiver:",
  225. category: 'accessing',
  226. fn: function (anObject){
  227. var self=this;
  228. return smalltalk.withContext(function($ctx1) {
  229. _st(self)._localAt_put_("self",anObject);
  230. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},smalltalk.AIContext)})},
  231. args: ["anObject"],
  232. source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
  233. messageSends: ["localAt:put:"],
  234. referencedClasses: []
  235. }),
  236. smalltalk.AIContext);
  237. smalltalk.addMethod(
  238. "_selector",
  239. smalltalk.method({
  240. selector: "selector",
  241. category: 'accessing',
  242. fn: function (){
  243. var self=this;
  244. return smalltalk.withContext(function($ctx1) {
  245. var $2,$1;
  246. $2=_st(self)._metod();
  247. if(($receiver = $2) == nil || $receiver == undefined){
  248. $1=$2;
  249. } else {
  250. $1=_st(_st(self)._method())._selector();
  251. };
  252. return $1;
  253. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.AIContext)})},
  254. args: [],
  255. source: "selector\x0a\x09^ self metod\x0a\x09\x09ifNotNil: [ self method selector ]",
  256. messageSends: ["ifNotNil:", "selector", "method", "metod"],
  257. referencedClasses: []
  258. }),
  259. smalltalk.AIContext);
  260. smalltalk.addMethod(
  261. "_fromMethodContext_",
  262. smalltalk.method({
  263. selector: "fromMethodContext:",
  264. category: 'instance creation',
  265. fn: function (aMethodContext){
  266. var self=this;
  267. return smalltalk.withContext(function($ctx1) {
  268. var $2,$3,$1;
  269. $2=_st(self)._new();
  270. _st($2)._initializeFromMethodContext_(aMethodContext);
  271. $3=_st($2)._yourself();
  272. $1=$3;
  273. return $1;
  274. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext.klass)})},
  275. args: ["aMethodContext"],
  276. source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
  277. messageSends: ["initializeFromMethodContext:", "new", "yourself"],
  278. referencedClasses: []
  279. }),
  280. smalltalk.AIContext.klass);
  281. smalltalk.addClass('ASTDebugger', smalltalk.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
  282. smalltalk.ASTDebugger.comment="ASTDebugger is a debugger to Amber.\x0aIt uses an AST interpreter to step through the code.\x0a\x0aASTDebugger instances are created from a `MethodContext` with `ASTDebugger class >> context:`.\x0aThey hold an `AIContext` instance internally, recursive copy of the `MethodContext`.\x0a\x0aUse the methods of the 'stepping' protocol to do stepping."
  283. smalltalk.addMethod(
  284. "_buildAST",
  285. smalltalk.method({
  286. selector: "buildAST",
  287. category: 'initialization',
  288. fn: function (){
  289. var self=this;
  290. var ast;
  291. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  292. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  293. return smalltalk.withContext(function($ctx1) {
  294. var $1;
  295. ast=_st(_st($Smalltalk())._current())._parse_(_st(_st(self)._method())._source());
  296. _st(_st($SemanticAnalyzer())._on_(_st(_st(_st(self)._context())._receiver())._class()))._visit_(ast);
  297. $1=ast;
  298. return $1;
  299. }, function($ctx1) {$ctx1.fill(self,"buildAST",{ast:ast},smalltalk.ASTDebugger)})},
  300. args: [],
  301. 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",
  302. messageSends: ["parse:", "source", "method", "current", "visit:", "on:", "class", "receiver", "context"],
  303. referencedClasses: ["Smalltalk", "SemanticAnalyzer"]
  304. }),
  305. smalltalk.ASTDebugger);
  306. smalltalk.addMethod(
  307. "_context",
  308. smalltalk.method({
  309. selector: "context",
  310. category: 'accessing',
  311. fn: function (){
  312. var self=this;
  313. return smalltalk.withContext(function($ctx1) {
  314. var $1;
  315. $1=self["@context"];
  316. return $1;
  317. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTDebugger)})},
  318. args: [],
  319. source: "context\x0a\x09^ context",
  320. messageSends: [],
  321. referencedClasses: []
  322. }),
  323. smalltalk.ASTDebugger);
  324. smalltalk.addMethod(
  325. "_context_",
  326. smalltalk.method({
  327. selector: "context:",
  328. category: 'accessing',
  329. fn: function (aContext){
  330. var self=this;
  331. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  332. return smalltalk.withContext(function($ctx1) {
  333. self["@context"]=_st($AIContext())._new();
  334. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger)})},
  335. args: ["aContext"],
  336. source: "context: aContext\x0a\x09context := AIContext new.",
  337. messageSends: ["new"],
  338. referencedClasses: ["AIContext"]
  339. }),
  340. smalltalk.ASTDebugger);
  341. smalltalk.addMethod(
  342. "_defaultInterpreterClass",
  343. smalltalk.method({
  344. selector: "defaultInterpreterClass",
  345. category: 'defaults',
  346. fn: function (){
  347. var self=this;
  348. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  349. return smalltalk.withContext(function($ctx1) {
  350. var $1;
  351. $1=$ASTSteppingInterpreter();
  352. return $1;
  353. }, function($ctx1) {$ctx1.fill(self,"defaultInterpreterClass",{},smalltalk.ASTDebugger)})},
  354. args: [],
  355. source: "defaultInterpreterClass\x0a\x09^ ASTSteppingInterpreter",
  356. messageSends: [],
  357. referencedClasses: ["ASTSteppingInterpreter"]
  358. }),
  359. smalltalk.ASTDebugger);
  360. smalltalk.addMethod(
  361. "_initializeInterpreter",
  362. smalltalk.method({
  363. selector: "initializeInterpreter",
  364. category: 'initialization',
  365. fn: function (){
  366. var self=this;
  367. return smalltalk.withContext(function($ctx1) {
  368. _st(_st(self)._interpreter())._interpret_(_st(_st(_st(self)._buildAST())._nodes())._first());
  369. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},smalltalk.ASTDebugger)})},
  370. args: [],
  371. source: "initializeInterpreter\x0a\x09self interpreter interpret: self buildAST nodes first",
  372. messageSends: ["interpret:", "first", "nodes", "buildAST", "interpreter"],
  373. referencedClasses: []
  374. }),
  375. smalltalk.ASTDebugger);
  376. smalltalk.addMethod(
  377. "_initializeWithContext_",
  378. smalltalk.method({
  379. selector: "initializeWithContext:",
  380. category: 'initialization',
  381. fn: function (aMethodContext){
  382. var self=this;
  383. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  384. return smalltalk.withContext(function($ctx1) {
  385. _st(self)._context_(_st($AIContext())._fromMethodContext_(aMethodContext));
  386. _st(self)._initializeInterpreter();
  387. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:",{aMethodContext:aMethodContext},smalltalk.ASTDebugger)})},
  388. args: ["aMethodContext"],
  389. source: "initializeWithContext: aMethodContext\x0a\x09\x22TODO: do we need to handle block contexts?\x22\x0a\x09\x0a\x09self context: (AIContext fromMethodContext: aMethodContext).\x0a\x09self initializeInterpreter",
  390. messageSends: ["context:", "fromMethodContext:", "initializeInterpreter"],
  391. referencedClasses: ["AIContext"]
  392. }),
  393. smalltalk.ASTDebugger);
  394. smalltalk.addMethod(
  395. "_interpreter",
  396. smalltalk.method({
  397. selector: "interpreter",
  398. category: 'accessing',
  399. fn: function (){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) {
  402. var $2,$1;
  403. $2=self["@interpreter"];
  404. if(($receiver = $2) == nil || $receiver == undefined){
  405. self["@interpreter"]=_st(_st(self)._defaultInterpreterClass())._new();
  406. $1=self["@interpreter"];
  407. } else {
  408. $1=$2;
  409. };
  410. return $1;
  411. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTDebugger)})},
  412. args: [],
  413. source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := self defaultInterpreterClass new ]",
  414. messageSends: ["ifNil:", "new", "defaultInterpreterClass"],
  415. referencedClasses: []
  416. }),
  417. smalltalk.ASTDebugger);
  418. smalltalk.addMethod(
  419. "_interpreter_",
  420. smalltalk.method({
  421. selector: "interpreter:",
  422. category: 'accessing',
  423. fn: function (anInterpreter){
  424. var self=this;
  425. return smalltalk.withContext(function($ctx1) {
  426. self["@interpreter"]=anInterpreter;
  427. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.ASTDebugger)})},
  428. args: ["anInterpreter"],
  429. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  430. messageSends: [],
  431. referencedClasses: []
  432. }),
  433. smalltalk.ASTDebugger);
  434. smalltalk.addMethod(
  435. "_method",
  436. smalltalk.method({
  437. selector: "method",
  438. category: 'accessing',
  439. fn: function (){
  440. var self=this;
  441. return smalltalk.withContext(function($ctx1) {
  442. var $1;
  443. $1=_st(_st(self)._context())._method();
  444. return $1;
  445. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.ASTDebugger)})},
  446. args: [],
  447. source: "method\x0a\x09^ self context method",
  448. messageSends: ["method", "context"],
  449. referencedClasses: []
  450. }),
  451. smalltalk.ASTDebugger);
  452. smalltalk.addMethod(
  453. "_restart",
  454. smalltalk.method({
  455. selector: "restart",
  456. category: 'stepping',
  457. fn: function (){
  458. var self=this;
  459. return smalltalk.withContext(function($ctx1) {
  460. _st(self)._shouldBeImplemented();
  461. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTDebugger)})},
  462. args: [],
  463. source: "restart\x0a\x09self shouldBeImplemented",
  464. messageSends: ["shouldBeImplemented"],
  465. referencedClasses: []
  466. }),
  467. smalltalk.ASTDebugger);
  468. smalltalk.addMethod(
  469. "_resume",
  470. smalltalk.method({
  471. selector: "resume",
  472. category: 'stepping',
  473. fn: function (){
  474. var self=this;
  475. return smalltalk.withContext(function($ctx1) {
  476. _st(self)._shouldBeImplemented();
  477. return self}, function($ctx1) {$ctx1.fill(self,"resume",{},smalltalk.ASTDebugger)})},
  478. args: [],
  479. source: "resume\x0a\x09self shouldBeImplemented",
  480. messageSends: ["shouldBeImplemented"],
  481. referencedClasses: []
  482. }),
  483. smalltalk.ASTDebugger);
  484. smalltalk.addMethod(
  485. "_step",
  486. smalltalk.method({
  487. selector: "step",
  488. category: 'stepping',
  489. fn: function (){
  490. var self=this;
  491. return smalltalk.withContext(function($ctx1) {
  492. _st((function(){
  493. return smalltalk.withContext(function($ctx2) {
  494. return _st(_st(_st(_st(_st(self)._interpreter())._nextNode())._notNil())._and_((function(){
  495. return smalltalk.withContext(function($ctx3) {
  496. return _st(_st(_st(self)._interpreter())._nextNode())._stopOnStepping();
  497. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})})))._or_((function(){
  498. return smalltalk.withContext(function($ctx3) {
  499. return _st(_st(_st(self)._interpreter())._atEnd())._not();
  500. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  501. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  502. return smalltalk.withContext(function($ctx2) {
  503. _st(_st(self)._interpreter())._step();
  504. return _st(self)._step();
  505. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  506. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTDebugger)})},
  507. args: [],
  508. 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 ]",
  509. messageSends: ["whileFalse:", "step", "interpreter", "or:", "not", "atEnd", "and:", "stopOnStepping", "nextNode", "notNil"],
  510. referencedClasses: []
  511. }),
  512. smalltalk.ASTDebugger);
  513. smalltalk.addMethod(
  514. "_stepInto",
  515. smalltalk.method({
  516. selector: "stepInto",
  517. category: 'stepping',
  518. fn: function (){
  519. var self=this;
  520. return smalltalk.withContext(function($ctx1) {
  521. _st(self)._shouldBeImplemented();
  522. return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},smalltalk.ASTDebugger)})},
  523. args: [],
  524. source: "stepInto\x0a\x09self shouldBeImplemented",
  525. messageSends: ["shouldBeImplemented"],
  526. referencedClasses: []
  527. }),
  528. smalltalk.ASTDebugger);
  529. smalltalk.addMethod(
  530. "_stepOver",
  531. smalltalk.method({
  532. selector: "stepOver",
  533. category: 'stepping',
  534. fn: function (){
  535. var self=this;
  536. return smalltalk.withContext(function($ctx1) {
  537. _st(self)._step();
  538. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTDebugger)})},
  539. args: [],
  540. source: "stepOver\x0a\x09self step",
  541. messageSends: ["step"],
  542. referencedClasses: []
  543. }),
  544. smalltalk.ASTDebugger);
  545. smalltalk.addMethod(
  546. "_context_",
  547. smalltalk.method({
  548. selector: "context:",
  549. category: 'instance creation',
  550. fn: function (aMethodContext){
  551. var self=this;
  552. return smalltalk.withContext(function($ctx1) {
  553. var $2,$3,$1;
  554. $2=_st(self)._new();
  555. _st($2)._initializeWithContext_(aMethodContext);
  556. $3=_st($2)._yourself();
  557. $1=$3;
  558. return $1;
  559. }, function($ctx1) {$ctx1.fill(self,"context:",{aMethodContext:aMethodContext},smalltalk.ASTDebugger.klass)})},
  560. args: ["aMethodContext"],
  561. source: "context: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aMethodContext;\x0a\x09\x09yourself",
  562. messageSends: ["initializeWithContext:", "new", "yourself"],
  563. referencedClasses: []
  564. }),
  565. smalltalk.ASTDebugger.klass);
  566. smalltalk.addClass('ASTInterpreter', smalltalk.Object, ['currentNode', 'context', 'shouldReturn', 'result'], 'Compiler-Interpreter');
  567. smalltalk.ASTInterpreter.comment="ASTIntepreter is like a `NodeVisitor`, interpreting nodes one after each other.\x0aIt is built using Continuation Passing Style for stepping purposes.\x0a\x0aUsage example:\x0a\x0a\x09| ast interpreter |\x0a\x09ast := Smalltalk current parse: 'foo 1+2+4'.\x0a\x09(SemanticAnalyzer on: Object) visit: ast.\x0a\x0a\x09ASTInterpreter new\x0a\x09\x09interpret: ast nodes first;\x0a\x09\x09result \x22Answers 7\x22"
  568. smalltalk.addMethod(
  569. "_assign_to_",
  570. smalltalk.method({
  571. selector: "assign:to:",
  572. category: 'private',
  573. fn: function (aNode,anObject){
  574. var self=this;
  575. return smalltalk.withContext(function($ctx1) {
  576. var $2,$1;
  577. $2=_st(_st(aNode)._binding())._isInstanceVar();
  578. if(smalltalk.assert($2)){
  579. $1=_st(_st(_st(self)._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  580. } else {
  581. $1=_st(_st(self)._context())._localAt_put_(_st(aNode)._value(),anObject);
  582. };
  583. return $1;
  584. }, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.ASTInterpreter)})},
  585. args: ["aNode", "anObject"],
  586. source: "assign: aNode to: anObject\x0a\x09^ aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value put: anObject ]",
  587. messageSends: ["ifTrue:ifFalse:", "instVarAt:put:", "value", "receiver", "context", "localAt:put:", "isInstanceVar", "binding"],
  588. referencedClasses: []
  589. }),
  590. smalltalk.ASTInterpreter);
  591. smalltalk.addMethod(
  592. "_context",
  593. smalltalk.method({
  594. selector: "context",
  595. category: 'accessing',
  596. fn: function (){
  597. var self=this;
  598. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  599. return smalltalk.withContext(function($ctx1) {
  600. var $2,$1;
  601. $2=self["@context"];
  602. if(($receiver = $2) == nil || $receiver == undefined){
  603. self["@context"]=_st($AIContext())._new();
  604. $1=self["@context"];
  605. } else {
  606. $1=$2;
  607. };
  608. return $1;
  609. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTInterpreter)})},
  610. args: [],
  611. source: "context\x0a\x09^ context ifNil: [ context := AIContext new ]",
  612. messageSends: ["ifNil:", "new"],
  613. referencedClasses: ["AIContext"]
  614. }),
  615. smalltalk.ASTInterpreter);
  616. smalltalk.addMethod(
  617. "_context_",
  618. smalltalk.method({
  619. selector: "context:",
  620. category: 'accessing',
  621. fn: function (anAIContext){
  622. var self=this;
  623. return smalltalk.withContext(function($ctx1) {
  624. self["@context"]=anAIContext;
  625. return self}, function($ctx1) {$ctx1.fill(self,"context:",{anAIContext:anAIContext},smalltalk.ASTInterpreter)})},
  626. args: ["anAIContext"],
  627. source: "context: anAIContext\x0a\x09context := anAIContext",
  628. messageSends: [],
  629. referencedClasses: []
  630. }),
  631. smalltalk.ASTInterpreter);
  632. smalltalk.addMethod(
  633. "_continue_value_",
  634. smalltalk.method({
  635. selector: "continue:value:",
  636. category: 'private',
  637. fn: function (aBlock,anObject){
  638. var self=this;
  639. return smalltalk.withContext(function($ctx1) {
  640. self["@result"]=anObject;
  641. _st(aBlock)._value_(anObject);
  642. return self}, function($ctx1) {$ctx1.fill(self,"continue:value:",{aBlock:aBlock,anObject:anObject},smalltalk.ASTInterpreter)})},
  643. args: ["aBlock", "anObject"],
  644. source: "continue: aBlock value: anObject\x0a\x09result := anObject.\x0a\x09aBlock value: anObject",
  645. messageSends: ["value:"],
  646. referencedClasses: []
  647. }),
  648. smalltalk.ASTInterpreter);
  649. smalltalk.addMethod(
  650. "_currentNode",
  651. smalltalk.method({
  652. selector: "currentNode",
  653. category: 'accessing',
  654. fn: function (){
  655. var self=this;
  656. return smalltalk.withContext(function($ctx1) {
  657. var $1;
  658. $1=self["@currentNode"];
  659. return $1;
  660. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTInterpreter)})},
  661. args: [],
  662. source: "currentNode\x0a\x09^ currentNode",
  663. messageSends: [],
  664. referencedClasses: []
  665. }),
  666. smalltalk.ASTInterpreter);
  667. smalltalk.addMethod(
  668. "_eval_",
  669. smalltalk.method({
  670. selector: "eval:",
  671. category: 'private',
  672. fn: function (aString){
  673. var self=this;
  674. var source,function_;
  675. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  676. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  677. return smalltalk.withContext(function($ctx1) {
  678. var $1,$2,$3;
  679. source=_st($String())._streamContents_((function(str){
  680. return smalltalk.withContext(function($ctx2) {
  681. _st(str)._nextPutAll_("(function(");
  682. _st(_st(_st(_st(self)._context())._locals())._keys())._do_separatedBy_((function(each){
  683. return smalltalk.withContext(function($ctx3) {
  684. return _st(str)._nextPutAll_(each);
  685. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}),(function(){
  686. return smalltalk.withContext(function($ctx3) {
  687. return _st(str)._nextPutAll_(",");
  688. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  689. $1=str;
  690. _st($1)._nextPutAll_("){ return (function() {");
  691. _st($1)._nextPutAll_(aString);
  692. $2=_st($1)._nextPutAll_("})() })");
  693. return $2;
  694. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
  695. function_=_st(_st($Compiler())._new())._eval_(source);
  696. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(_st(self)._context())._locals())._values());
  697. return $3;
  698. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.ASTInterpreter)})},
  699. args: ["aString"],
  700. 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",
  701. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  702. referencedClasses: ["String", "Compiler"]
  703. }),
  704. smalltalk.ASTInterpreter);
  705. smalltalk.addMethod(
  706. "_initialize",
  707. smalltalk.method({
  708. selector: "initialize",
  709. category: 'initialization',
  710. fn: function (){
  711. var self=this;
  712. return smalltalk.withContext(function($ctx1) {
  713. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  714. self["@shouldReturn"]=false;
  715. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ASTInterpreter)})},
  716. args: [],
  717. source: "initialize\x0a\x09super initialize.\x0a\x09shouldReturn := false",
  718. messageSends: ["initialize"],
  719. referencedClasses: []
  720. }),
  721. smalltalk.ASTInterpreter);
  722. smalltalk.addMethod(
  723. "_interpret_",
  724. smalltalk.method({
  725. selector: "interpret:",
  726. category: 'interpreting',
  727. fn: function (aNode){
  728. var self=this;
  729. return smalltalk.withContext(function($ctx1) {
  730. self["@shouldReturn"]=false;
  731. _st(self)._interpret_continue_(aNode,(function(value){
  732. return smalltalk.withContext(function($ctx2) {
  733. self["@result"]=value;
  734. return self["@result"];
  735. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  736. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  737. args: ["aNode"],
  738. source: "interpret: aNode\x0a\x09shouldReturn := false.\x0a\x09self interpret: aNode continue: [ :value |\x0a\x09\x09result := value ]",
  739. messageSends: ["interpret:continue:"],
  740. referencedClasses: []
  741. }),
  742. smalltalk.ASTInterpreter);
  743. smalltalk.addMethod(
  744. "_interpret_continue_",
  745. smalltalk.method({
  746. selector: "interpret:continue:",
  747. category: 'interpreting',
  748. fn: function (aNode,aBlock){
  749. var self=this;
  750. return smalltalk.withContext(function($ctx1) {
  751. var $1,$2,$3;
  752. $1=self["@shouldReturn"];
  753. if(smalltalk.assert($1)){
  754. $2=self;
  755. return $2;
  756. };
  757. $3=_st(aNode)._isNode();
  758. if(smalltalk.assert($3)){
  759. self["@currentNode"]=aNode;
  760. self["@currentNode"];
  761. _st(self)._interpretNode_continue_(aNode,(function(value){
  762. return smalltalk.withContext(function($ctx2) {
  763. return _st(self)._continue_value_(aBlock,value);
  764. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  765. } else {
  766. _st(self)._continue_value_(aBlock,aNode);
  767. };
  768. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  769. args: ["aNode", "aBlock"],
  770. source: "interpret: aNode continue: aBlock\x0a\x09shouldReturn ifTrue: [ ^ self ].\x0a\x0a\x09aNode isNode\x0a\x09\x09ifTrue: [\x0a\x09\x09\x09currentNode := aNode.\x0a\x09\x09\x09self interpretNode: aNode continue: [ :value |\x0a\x09\x09\x09\x09self continue: aBlock value: value ] ]\x0a\x09\x09ifFalse: [ self continue: aBlock value: aNode ]",
  771. messageSends: ["ifTrue:", "ifTrue:ifFalse:", "interpretNode:continue:", "continue:value:", "isNode"],
  772. referencedClasses: []
  773. }),
  774. smalltalk.ASTInterpreter);
  775. smalltalk.addMethod(
  776. "_interpretAll_continue_",
  777. smalltalk.method({
  778. selector: "interpretAll:continue:",
  779. category: 'private',
  780. fn: function (aCollection,aBlock){
  781. var self=this;
  782. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  783. return smalltalk.withContext(function($ctx1) {
  784. _st(self)._interpretAll_continue_result_(aCollection,aBlock,_st($OrderedCollection())._new());
  785. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:",{aCollection:aCollection,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  786. args: ["aCollection", "aBlock"],
  787. source: "interpretAll: aCollection continue: aBlock\x0a\x09self\x0a\x09\x09interpretAll: aCollection\x0a\x09\x09continue: aBlock\x0a\x09\x09result: OrderedCollection new",
  788. messageSends: ["interpretAll:continue:result:", "new"],
  789. referencedClasses: ["OrderedCollection"]
  790. }),
  791. smalltalk.ASTInterpreter);
  792. smalltalk.addMethod(
  793. "_interpretAll_continue_result_",
  794. smalltalk.method({
  795. selector: "interpretAll:continue:result:",
  796. category: 'private',
  797. fn: function (nodes,aBlock,aCollection){
  798. var self=this;
  799. return smalltalk.withContext(function($ctx1) {
  800. var $1;
  801. $1=_st(nodes)._isEmpty();
  802. if(smalltalk.assert($1)){
  803. _st(self)._continue_value_(aBlock,aCollection);
  804. } else {
  805. _st(self)._interpret_continue_(_st(nodes)._first(),(function(value){
  806. return smalltalk.withContext(function($ctx2) {
  807. return _st(self)._interpretAll_continue_result_(_st(nodes)._allButFirst(),aBlock,_st(aCollection).__comma([value]));
  808. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  809. };
  810. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:result:",{nodes:nodes,aBlock:aBlock,aCollection:aCollection},smalltalk.ASTInterpreter)})},
  811. args: ["nodes", "aBlock", "aCollection"],
  812. source: "interpretAll: nodes continue: aBlock result: aCollection\x0a\x09nodes isEmpty\x0a\x09\x09ifTrue: [ self continue: aBlock value: aCollection ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09self interpret: nodes first continue: [:value |\x0a\x09\x09\x09\x09self\x0a\x09\x09\x09\x09\x09interpretAll: nodes allButFirst\x0a\x09\x09\x09\x09\x09continue: aBlock\x0a\x09\x09\x09\x09\x09result: aCollection, { value } ] ]",
  813. messageSends: ["ifTrue:ifFalse:", "continue:value:", "interpret:continue:", "first", "interpretAll:continue:result:", "allButFirst", ",", "isEmpty"],
  814. referencedClasses: []
  815. }),
  816. smalltalk.ASTInterpreter);
  817. smalltalk.addMethod(
  818. "_interpretAssignmentNode_continue_",
  819. smalltalk.method({
  820. selector: "interpretAssignmentNode:continue:",
  821. category: 'interpreting',
  822. fn: function (aNode,aBlock){
  823. var self=this;
  824. return smalltalk.withContext(function($ctx1) {
  825. _st(self)._interpret_continue_(_st(aNode)._right(),(function(value){
  826. return smalltalk.withContext(function($ctx2) {
  827. return _st(self)._continue_value_(aBlock,_st(self)._assign_to_(_st(aNode)._left(),value));
  828. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  829. return self}, function($ctx1) {$ctx1.fill(self,"interpretAssignmentNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  830. args: ["aNode", "aBlock"],
  831. source: "interpretAssignmentNode: aNode continue: aBlock\x0a\x09self interpret: aNode right continue: [ :value |\x0a\x09\x09self\x0a\x09\x09\x09continue: aBlock\x0a\x09\x09\x09value: (self assign: aNode left to: value) ]",
  832. messageSends: ["interpret:continue:", "right", "continue:value:", "assign:to:", "left"],
  833. referencedClasses: []
  834. }),
  835. smalltalk.ASTInterpreter);
  836. smalltalk.addMethod(
  837. "_interpretBlockNode_continue_",
  838. smalltalk.method({
  839. selector: "interpretBlockNode:continue:",
  840. category: 'interpreting',
  841. fn: function (aNode,aBlock){
  842. var self=this;
  843. return smalltalk.withContext(function($ctx1) {
  844. var $1,$2;
  845. _st(self)._continue_value_(aBlock,(function(){
  846. return smalltalk.withContext(function($ctx2) {
  847. $1=self;
  848. _st($1)._interpret_(_st(_st(aNode)._nodes())._first());
  849. $2=_st($1)._result();
  850. return $2;
  851. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  852. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  853. args: ["aNode", "aBlock"],
  854. source: "interpretBlockNode: aNode continue: aBlock\x0a\x09\x22TODO: Context should be set\x22\x0a\x09\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: [ self interpret: aNode nodes first; result ]",
  855. messageSends: ["continue:value:", "interpret:", "first", "nodes", "result"],
  856. referencedClasses: []
  857. }),
  858. smalltalk.ASTInterpreter);
  859. smalltalk.addMethod(
  860. "_interpretBlockSequenceNode_continue_",
  861. smalltalk.method({
  862. selector: "interpretBlockSequenceNode:continue:",
  863. category: 'interpreting',
  864. fn: function (aNode,aBlock){
  865. var self=this;
  866. return smalltalk.withContext(function($ctx1) {
  867. _st(self)._interpretSequenceNode_continue_(aNode,aBlock);
  868. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockSequenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  869. args: ["aNode", "aBlock"],
  870. source: "interpretBlockSequenceNode: aNode continue: aBlock\x0a\x09self interpretSequenceNode: aNode continue: aBlock",
  871. messageSends: ["interpretSequenceNode:continue:"],
  872. referencedClasses: []
  873. }),
  874. smalltalk.ASTInterpreter);
  875. smalltalk.addMethod(
  876. "_interpretCascadeNode_continue_",
  877. smalltalk.method({
  878. selector: "interpretCascadeNode:continue:",
  879. category: 'interpreting',
  880. fn: function (aNode,aBlock){
  881. var self=this;
  882. return smalltalk.withContext(function($ctx1) {
  883. _st(self)._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  884. return smalltalk.withContext(function($ctx2) {
  885. _st(_st(aNode)._nodes())._do_((function(each){
  886. return smalltalk.withContext(function($ctx3) {
  887. return _st(each)._receiver_(receiver);
  888. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  889. return _st(self)._interpretAll_continue_(_st(_st(aNode)._nodes())._allButLast(),(function(){
  890. return smalltalk.withContext(function($ctx3) {
  891. return _st(self)._interpret_continue_(_st(_st(aNode)._nodes())._last(),(function(val){
  892. return smalltalk.withContext(function($ctx4) {
  893. return _st(self)._continue_value_(aBlock,val);
  894. }, function($ctx4) {$ctx4.fillBlock({val:val},$ctx1)})}));
  895. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  896. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  897. return self}, function($ctx1) {$ctx1.fill(self,"interpretCascadeNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  898. args: ["aNode", "aBlock"],
  899. source: "interpretCascadeNode: aNode continue: aBlock\x0a\x09\x22TODO: Handle super sends\x22\x0a\x09\x0a\x09self interpret: aNode receiver continue: [ :receiver |\x0a\x09\x09\x22Only interpret the receiver once\x22\x0a\x09\x09aNode nodes do: [ :each | each receiver: receiver ].\x0a\x0a\x09\x09self\x0a\x09\x09\x09interpretAll: aNode nodes allButLast\x0a\x09\x09\x09continue: [\x0a\x09\x09\x09\x09self\x0a\x09\x09\x09\x09\x09interpret: aNode nodes last\x0a\x09\x09\x09\x09\x09continue: [ :val | self continue: aBlock value: val ] ] ]",
  900. messageSends: ["interpret:continue:", "receiver", "do:", "receiver:", "nodes", "interpretAll:continue:", "allButLast", "last", "continue:value:"],
  901. referencedClasses: []
  902. }),
  903. smalltalk.ASTInterpreter);
  904. smalltalk.addMethod(
  905. "_interpretClassReferenceNode_continue_",
  906. smalltalk.method({
  907. selector: "interpretClassReferenceNode:continue:",
  908. category: 'interpreting',
  909. fn: function (aNode,aBlock){
  910. var self=this;
  911. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  912. return smalltalk.withContext(function($ctx1) {
  913. _st(self)._continue_value_(aBlock,_st(_st($Smalltalk())._current())._at_(_st(aNode)._value()));
  914. return self}, function($ctx1) {$ctx1.fill(self,"interpretClassReferenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  915. args: ["aNode", "aBlock"],
  916. source: "interpretClassReferenceNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: (Smalltalk current at: aNode value)",
  917. messageSends: ["continue:value:", "at:", "value", "current"],
  918. referencedClasses: ["Smalltalk"]
  919. }),
  920. smalltalk.ASTInterpreter);
  921. smalltalk.addMethod(
  922. "_interpretDynamicArrayNode_continue_",
  923. smalltalk.method({
  924. selector: "interpretDynamicArrayNode:continue:",
  925. category: 'interpreting',
  926. fn: function (aNode,aBlock){
  927. var self=this;
  928. return smalltalk.withContext(function($ctx1) {
  929. _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  930. return smalltalk.withContext(function($ctx2) {
  931. return _st(self)._continue_value_(aBlock,array);
  932. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  933. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicArrayNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  934. args: ["aNode", "aBlock"],
  935. source: "interpretDynamicArrayNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self\x0a\x09\x09\x09continue: aBlock\x0a\x09\x09\x09value: array ]",
  936. messageSends: ["interpretAll:continue:", "nodes", "continue:value:"],
  937. referencedClasses: []
  938. }),
  939. smalltalk.ASTInterpreter);
  940. smalltalk.addMethod(
  941. "_interpretDynamicDictionaryNode_continue_",
  942. smalltalk.method({
  943. selector: "interpretDynamicDictionaryNode:continue:",
  944. category: 'interpreting',
  945. fn: function (aNode,aBlock){
  946. var self=this;
  947. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  948. return smalltalk.withContext(function($ctx1) {
  949. _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  950. var hashedCollection;
  951. return smalltalk.withContext(function($ctx2) {
  952. hashedCollection=_st($HashedCollection())._new();
  953. hashedCollection;
  954. _st(array)._do_((function(each){
  955. return smalltalk.withContext(function($ctx3) {
  956. return _st(hashedCollection)._add_(each);
  957. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  958. return _st(self)._continue_value_(aBlock,hashedCollection);
  959. }, function($ctx2) {$ctx2.fillBlock({array:array,hashedCollection:hashedCollection},$ctx1)})}));
  960. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicDictionaryNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  961. args: ["aNode", "aBlock"],
  962. source: "interpretDynamicDictionaryNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array | | hashedCollection |\x0a\x09\x09hashedCollection := HashedCollection new.\x0a\x09\x09array do: [ :each | hashedCollection add: each ].\x0a\x09\x09self\x0a\x09\x09\x09continue: aBlock\x0a\x09\x09\x09value: hashedCollection ]",
  963. messageSends: ["interpretAll:continue:", "nodes", "new", "do:", "add:", "continue:value:"],
  964. referencedClasses: ["HashedCollection"]
  965. }),
  966. smalltalk.ASTInterpreter);
  967. smalltalk.addMethod(
  968. "_interpretJSStatementNode_continue_",
  969. smalltalk.method({
  970. selector: "interpretJSStatementNode:continue:",
  971. category: 'interpreting',
  972. fn: function (aNode,aBlock){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. self["@shouldReturn"]=true;
  976. _st(self)._continue_value_(aBlock,_st(self)._eval_(_st(aNode)._source()));
  977. return self}, function($ctx1) {$ctx1.fill(self,"interpretJSStatementNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  978. args: ["aNode", "aBlock"],
  979. source: "interpretJSStatementNode: aNode continue: aBlock\x0a\x09shouldReturn := true.\x0a\x09self continue: aBlock value: (self eval: aNode source)",
  980. messageSends: ["continue:value:", "eval:", "source"],
  981. referencedClasses: []
  982. }),
  983. smalltalk.ASTInterpreter);
  984. smalltalk.addMethod(
  985. "_interpretMethodNode_continue_",
  986. smalltalk.method({
  987. selector: "interpretMethodNode:continue:",
  988. category: 'interpreting',
  989. fn: function (aNode,aBlock){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  993. return smalltalk.withContext(function($ctx2) {
  994. return _st(self)._continue_value_(aBlock,_st(array)._first());
  995. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  996. return self}, function($ctx1) {$ctx1.fill(self,"interpretMethodNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  997. args: ["aNode", "aBlock"],
  998. source: "interpretMethodNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self continue: aBlock value: array first ]",
  999. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "first"],
  1000. referencedClasses: []
  1001. }),
  1002. smalltalk.ASTInterpreter);
  1003. smalltalk.addMethod(
  1004. "_interpretNode_continue_",
  1005. smalltalk.method({
  1006. selector: "interpretNode:continue:",
  1007. category: 'interpreting',
  1008. fn: function (aNode,aBlock){
  1009. var self=this;
  1010. return smalltalk.withContext(function($ctx1) {
  1011. _st(aNode)._interpreter_continue_(self,aBlock);
  1012. return self}, function($ctx1) {$ctx1.fill(self,"interpretNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1013. args: ["aNode", "aBlock"],
  1014. source: "interpretNode: aNode continue: aBlock\x0a\x09aNode interpreter: self continue: aBlock",
  1015. messageSends: ["interpreter:continue:"],
  1016. referencedClasses: []
  1017. }),
  1018. smalltalk.ASTInterpreter);
  1019. smalltalk.addMethod(
  1020. "_interpretReturnNode_continue_",
  1021. smalltalk.method({
  1022. selector: "interpretReturnNode:continue:",
  1023. category: 'interpreting',
  1024. fn: function (aNode,aBlock){
  1025. var self=this;
  1026. return smalltalk.withContext(function($ctx1) {
  1027. _st(self)._interpret_continue_(_st(_st(aNode)._nodes())._first(),(function(value){
  1028. return smalltalk.withContext(function($ctx2) {
  1029. self["@shouldReturn"]=true;
  1030. self["@shouldReturn"];
  1031. return _st(self)._continue_value_(aBlock,value);
  1032. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1033. return self}, function($ctx1) {$ctx1.fill(self,"interpretReturnNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1034. args: ["aNode", "aBlock"],
  1035. source: "interpretReturnNode: aNode continue: aBlock\x0a\x09self interpret: aNode nodes first continue: [ :value |\x0a\x09\x09shouldReturn := true.\x0a\x09\x09self continue: aBlock value: value ]",
  1036. messageSends: ["interpret:continue:", "first", "nodes", "continue:value:"],
  1037. referencedClasses: []
  1038. }),
  1039. smalltalk.ASTInterpreter);
  1040. smalltalk.addMethod(
  1041. "_interpretSendNode_continue_",
  1042. smalltalk.method({
  1043. selector: "interpretSendNode:continue:",
  1044. category: 'interpreting',
  1045. fn: function (aNode,aBlock){
  1046. var self=this;
  1047. return smalltalk.withContext(function($ctx1) {
  1048. _st(self)._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  1049. return smalltalk.withContext(function($ctx2) {
  1050. return _st(self)._interpretAll_continue_(_st(aNode)._arguments(),(function(args){
  1051. return smalltalk.withContext(function($ctx3) {
  1052. return _st(self)._messageFromSendNode_arguments_do_(aNode,args,(function(message){
  1053. return smalltalk.withContext(function($ctx4) {
  1054. _st(_st(self)._context())._pc_(_st(_st(_st(self)._context())._pc()).__plus((1)));
  1055. return _st(self)._continue_value_(aBlock,_st(message)._sendTo_(receiver));
  1056. }, function($ctx4) {$ctx4.fillBlock({message:message},$ctx1)})}));
  1057. }, function($ctx3) {$ctx3.fillBlock({args:args},$ctx1)})}));
  1058. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  1059. return self}, function($ctx1) {$ctx1.fill(self,"interpretSendNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1060. args: ["aNode", "aBlock"],
  1061. source: "interpretSendNode: aNode continue: aBlock\x0a\x09\x22TODO: Handle super sends\x22\x0a\x09\x0a\x09self interpret: aNode receiver continue: [ :receiver |\x0a\x09\x09self interpretAll: aNode arguments continue: [ :args |\x0a\x09\x09\x09self\x0a\x09\x09\x09\x09messageFromSendNode: aNode\x0a\x09\x09\x09\x09arguments: args\x0a\x09\x09\x09\x09do: [ :message |\x0a\x09\x09\x09\x09\x09self context pc: self context pc + 1.\x0a\x09\x09\x09\x09\x09self\x0a\x09\x09\x09\x09\x09\x09continue: aBlock\x0a\x09\x09\x09\x09\x09\x09value: (message sendTo: receiver) ] ] ]",
  1062. messageSends: ["interpret:continue:", "receiver", "interpretAll:continue:", "arguments", "messageFromSendNode:arguments:do:", "pc:", "+", "pc", "context", "continue:value:", "sendTo:"],
  1063. referencedClasses: []
  1064. }),
  1065. smalltalk.ASTInterpreter);
  1066. smalltalk.addMethod(
  1067. "_interpretSequenceNode_continue_",
  1068. smalltalk.method({
  1069. selector: "interpretSequenceNode:continue:",
  1070. category: 'interpreting',
  1071. fn: function (aNode,aBlock){
  1072. var self=this;
  1073. return smalltalk.withContext(function($ctx1) {
  1074. _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1075. return smalltalk.withContext(function($ctx2) {
  1076. return _st(self)._continue_value_(aBlock,_st(array)._last());
  1077. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  1078. return self}, function($ctx1) {$ctx1.fill(self,"interpretSequenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1079. args: ["aNode", "aBlock"],
  1080. source: "interpretSequenceNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self continue: aBlock value: array last ]",
  1081. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "last"],
  1082. referencedClasses: []
  1083. }),
  1084. smalltalk.ASTInterpreter);
  1085. smalltalk.addMethod(
  1086. "_interpretValueNode_continue_",
  1087. smalltalk.method({
  1088. selector: "interpretValueNode:continue:",
  1089. category: 'interpreting',
  1090. fn: function (aNode,aBlock){
  1091. var self=this;
  1092. return smalltalk.withContext(function($ctx1) {
  1093. _st(self)._continue_value_(aBlock,_st(aNode)._value());
  1094. return self}, function($ctx1) {$ctx1.fill(self,"interpretValueNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1095. args: ["aNode", "aBlock"],
  1096. source: "interpretValueNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: aNode value",
  1097. messageSends: ["continue:value:", "value"],
  1098. referencedClasses: []
  1099. }),
  1100. smalltalk.ASTInterpreter);
  1101. smalltalk.addMethod(
  1102. "_interpretVariableNode_continue_",
  1103. smalltalk.method({
  1104. selector: "interpretVariableNode:continue:",
  1105. category: 'interpreting',
  1106. fn: function (aNode,aBlock){
  1107. var self=this;
  1108. return smalltalk.withContext(function($ctx1) {
  1109. var $1,$2,$4,$3;
  1110. $1=self;
  1111. $2=aBlock;
  1112. $4=_st(_st(aNode)._binding())._isInstanceVar();
  1113. if(smalltalk.assert($4)){
  1114. $3=_st(_st(_st(self)._context())._receiver())._instVarAt_(_st(aNode)._value());
  1115. } else {
  1116. $3=_st(_st(self)._context())._localAt_(_st(aNode)._value());
  1117. };
  1118. _st($1)._continue_value_($2,$3);
  1119. return self}, function($ctx1) {$ctx1.fill(self,"interpretVariableNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1120. args: ["aNode", "aBlock"],
  1121. source: "interpretVariableNode: aNode continue: aBlock\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: (aNode binding isInstanceVar\x0a\x09\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09\x09ifFalse: [ self context localAt: aNode value ])",
  1122. messageSends: ["continue:value:", "ifTrue:ifFalse:", "instVarAt:", "value", "receiver", "context", "localAt:", "isInstanceVar", "binding"],
  1123. referencedClasses: []
  1124. }),
  1125. smalltalk.ASTInterpreter);
  1126. smalltalk.addMethod(
  1127. "_messageFromSendNode_arguments_do_",
  1128. smalltalk.method({
  1129. selector: "messageFromSendNode:arguments:do:",
  1130. category: 'private',
  1131. fn: function (aSendNode,aCollection,aBlock){
  1132. var self=this;
  1133. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  1134. return smalltalk.withContext(function($ctx1) {
  1135. var $1,$2;
  1136. $1=_st($Message())._new();
  1137. _st($1)._selector_(_st(aSendNode)._selector());
  1138. _st($1)._arguments_(aCollection);
  1139. $2=_st($1)._yourself();
  1140. _st(self)._continue_value_(aBlock,$2);
  1141. return self}, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:do:",{aSendNode:aSendNode,aCollection:aCollection,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1142. args: ["aSendNode", "aCollection", "aBlock"],
  1143. source: "messageFromSendNode: aSendNode arguments: aCollection do: aBlock\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: (Message new\x0a\x09\x09\x09selector: aSendNode selector;\x0a\x09\x09\x09arguments: aCollection;\x0a\x09\x09\x09yourself)",
  1144. messageSends: ["continue:value:", "selector:", "selector", "new", "arguments:", "yourself"],
  1145. referencedClasses: ["Message"]
  1146. }),
  1147. smalltalk.ASTInterpreter);
  1148. smalltalk.addMethod(
  1149. "_result",
  1150. smalltalk.method({
  1151. selector: "result",
  1152. category: 'accessing',
  1153. fn: function (){
  1154. var self=this;
  1155. return smalltalk.withContext(function($ctx1) {
  1156. var $1;
  1157. $1=self["@result"];
  1158. return $1;
  1159. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ASTInterpreter)})},
  1160. args: [],
  1161. source: "result\x0a\x09^ result",
  1162. messageSends: [],
  1163. referencedClasses: []
  1164. }),
  1165. smalltalk.ASTInterpreter);
  1166. smalltalk.addMethod(
  1167. "_shouldReturn",
  1168. smalltalk.method({
  1169. selector: "shouldReturn",
  1170. category: 'testing',
  1171. fn: function (){
  1172. var self=this;
  1173. return smalltalk.withContext(function($ctx1) {
  1174. var $2,$1;
  1175. $2=self["@shouldReturn"];
  1176. if(($receiver = $2) == nil || $receiver == undefined){
  1177. $1=false;
  1178. } else {
  1179. $1=$2;
  1180. };
  1181. return $1;
  1182. }, function($ctx1) {$ctx1.fill(self,"shouldReturn",{},smalltalk.ASTInterpreter)})},
  1183. args: [],
  1184. source: "shouldReturn\x0a\x09^ shouldReturn ifNil: [ false ]",
  1185. messageSends: ["ifNil:"],
  1186. referencedClasses: []
  1187. }),
  1188. smalltalk.ASTInterpreter);
  1189. smalltalk.addClass('ASTSteppingInterpreter', smalltalk.ASTInterpreter, ['continuation', 'nextNode'], 'Compiler-Interpreter');
  1190. smalltalk.ASTSteppingInterpreter.comment="ASTSteppingInterpreter is an interpreter with stepping capabilities.\x0aUse `#step` to actually interpret the next node.\x0a\x0aUsage example:\x0a\x0a\x09| ast interpreter |\x0a\x09ast := Smalltalk current parse: 'foo 1+2+4'.\x0a\x09(SemanticAnalyzer on: Object) visit: ast.\x0a\x0a\x09interpreter := ASTSteppingInterpreter new\x0a\x09\x09interpret: ast nodes first;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09debugger step; step.\x0a\x09debugger step; step.\x0a\x09debugger result.\x22Answers 1\x22\x0a\x09debugger step.\x0a\x09debugger result. \x22Answers 3\x22\x0a\x09debugger step.\x0a\x09debugger result. \x22Answers 7\x22"
  1191. smalltalk.addMethod(
  1192. "_atEnd",
  1193. smalltalk.method({
  1194. selector: "atEnd",
  1195. category: 'testing',
  1196. fn: function (){
  1197. var self=this;
  1198. return smalltalk.withContext(function($ctx1) {
  1199. var $1;
  1200. $1=_st(_st(self)._shouldReturn())._or_((function(){
  1201. return smalltalk.withContext(function($ctx2) {
  1202. return _st(_st(self)._nextNode()).__eq_eq(_st(self)._currentNode());
  1203. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1204. return $1;
  1205. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTSteppingInterpreter)})},
  1206. args: [],
  1207. source: "atEnd\x0a\x09^ self shouldReturn or: [ self nextNode == self currentNode ]",
  1208. messageSends: ["or:", "==", "currentNode", "nextNode", "shouldReturn"],
  1209. referencedClasses: []
  1210. }),
  1211. smalltalk.ASTSteppingInterpreter);
  1212. smalltalk.addMethod(
  1213. "_initialize",
  1214. smalltalk.method({
  1215. selector: "initialize",
  1216. category: 'initialization',
  1217. fn: function (){
  1218. var self=this;
  1219. return smalltalk.withContext(function($ctx1) {
  1220. smalltalk.ASTInterpreter.fn.prototype._initialize.apply(_st(self), []);
  1221. self["@continuation"]=(function(){
  1222. return smalltalk.withContext(function($ctx2) {
  1223. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  1224. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ASTSteppingInterpreter)})},
  1225. args: [],
  1226. source: "initialize\x0a\x09super initialize.\x0a\x09continuation := []",
  1227. messageSends: ["initialize"],
  1228. referencedClasses: []
  1229. }),
  1230. smalltalk.ASTSteppingInterpreter);
  1231. smalltalk.addMethod(
  1232. "_interpret_continue_",
  1233. smalltalk.method({
  1234. selector: "interpret:continue:",
  1235. category: 'interpreting',
  1236. fn: function (aNode,aBlock){
  1237. var self=this;
  1238. return smalltalk.withContext(function($ctx1) {
  1239. self["@nextNode"]=aNode;
  1240. self["@continuation"]=(function(){
  1241. return smalltalk.withContext(function($ctx2) {
  1242. return smalltalk.ASTInterpreter.fn.prototype._interpret_continue_.apply(_st(self), [aNode,aBlock]);
  1243. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  1244. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTSteppingInterpreter)})},
  1245. args: ["aNode", "aBlock"],
  1246. source: "interpret: aNode continue: aBlock\x0a\x09nextNode := aNode.\x0a\x09continuation := [\x0a\x09\x09super interpret: aNode continue: aBlock ]",
  1247. messageSends: ["interpret:continue:"],
  1248. referencedClasses: []
  1249. }),
  1250. smalltalk.ASTSteppingInterpreter);
  1251. smalltalk.addMethod(
  1252. "_nextNode",
  1253. smalltalk.method({
  1254. selector: "nextNode",
  1255. category: 'accessing',
  1256. fn: function (){
  1257. var self=this;
  1258. return smalltalk.withContext(function($ctx1) {
  1259. var $1;
  1260. $1=self["@nextNode"];
  1261. return $1;
  1262. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTSteppingInterpreter)})},
  1263. args: [],
  1264. source: "nextNode\x0a\x09^ nextNode",
  1265. messageSends: [],
  1266. referencedClasses: []
  1267. }),
  1268. smalltalk.ASTSteppingInterpreter);
  1269. smalltalk.addMethod(
  1270. "_step",
  1271. smalltalk.method({
  1272. selector: "step",
  1273. category: 'stepping',
  1274. fn: function (){
  1275. var self=this;
  1276. return smalltalk.withContext(function($ctx1) {
  1277. _st(self["@continuation"])._value();
  1278. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTSteppingInterpreter)})},
  1279. args: [],
  1280. source: "step\x0a\x09continuation value",
  1281. messageSends: ["value"],
  1282. referencedClasses: []
  1283. }),
  1284. smalltalk.ASTSteppingInterpreter);
  1285. smalltalk.addMethod(
  1286. "_interpreter_continue_",
  1287. smalltalk.method({
  1288. selector: "interpreter:continue:",
  1289. category: '*Compiler-Interpreter',
  1290. fn: function (anInterpreter,aBlock){
  1291. var self=this;
  1292. return smalltalk.withContext(function($ctx1) {
  1293. var $1;
  1294. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  1295. return $1;
  1296. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.Node)})},
  1297. args: ["anInterpreter", "aBlock"],
  1298. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  1299. messageSends: ["interpretNode:continue:"],
  1300. referencedClasses: []
  1301. }),
  1302. smalltalk.Node);
  1303. smalltalk.addMethod(
  1304. "_isSteppingNode",
  1305. smalltalk.method({
  1306. selector: "isSteppingNode",
  1307. category: '*Compiler-Interpreter',
  1308. fn: function (){
  1309. var self=this;
  1310. return smalltalk.withContext(function($ctx1) {
  1311. return false;
  1312. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
  1313. args: [],
  1314. source: "isSteppingNode\x0a\x09^ false",
  1315. messageSends: [],
  1316. referencedClasses: []
  1317. }),
  1318. smalltalk.Node);
  1319. smalltalk.addMethod(
  1320. "_interpreter_continue_",
  1321. smalltalk.method({
  1322. selector: "interpreter:continue:",
  1323. category: '*Compiler-Interpreter',
  1324. fn: function (anInterpreter,aBlock){
  1325. var self=this;
  1326. return smalltalk.withContext(function($ctx1) {
  1327. var $1;
  1328. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  1329. return $1;
  1330. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.AssignmentNode)})},
  1331. args: ["anInterpreter", "aBlock"],
  1332. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  1333. messageSends: ["interpretAssignmentNode:continue:"],
  1334. referencedClasses: []
  1335. }),
  1336. smalltalk.AssignmentNode);
  1337. smalltalk.addMethod(
  1338. "_isSteppingNode",
  1339. smalltalk.method({
  1340. selector: "isSteppingNode",
  1341. category: '*Compiler-Interpreter',
  1342. fn: function (){
  1343. var self=this;
  1344. return smalltalk.withContext(function($ctx1) {
  1345. return true;
  1346. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.AssignmentNode)})},
  1347. args: [],
  1348. source: "isSteppingNode\x0a\x09^ true",
  1349. messageSends: [],
  1350. referencedClasses: []
  1351. }),
  1352. smalltalk.AssignmentNode);
  1353. smalltalk.addMethod(
  1354. "_interpreter_continue_",
  1355. smalltalk.method({
  1356. selector: "interpreter:continue:",
  1357. category: '*Compiler-Interpreter',
  1358. fn: function (anInterpreter,aBlock){
  1359. var self=this;
  1360. return smalltalk.withContext(function($ctx1) {
  1361. var $1;
  1362. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  1363. return $1;
  1364. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockNode)})},
  1365. args: ["anInterpreter", "aBlock"],
  1366. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  1367. messageSends: ["interpretBlockNode:continue:"],
  1368. referencedClasses: []
  1369. }),
  1370. smalltalk.BlockNode);
  1371. smalltalk.addMethod(
  1372. "_isSteppingNode",
  1373. smalltalk.method({
  1374. selector: "isSteppingNode",
  1375. category: '*Compiler-Interpreter',
  1376. fn: function (){
  1377. var self=this;
  1378. return smalltalk.withContext(function($ctx1) {
  1379. return true;
  1380. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
  1381. args: [],
  1382. source: "isSteppingNode\x0a\x09^ true",
  1383. messageSends: [],
  1384. referencedClasses: []
  1385. }),
  1386. smalltalk.BlockNode);
  1387. smalltalk.addMethod(
  1388. "_interpreter_continue_",
  1389. smalltalk.method({
  1390. selector: "interpreter:continue:",
  1391. category: '*Compiler-Interpreter',
  1392. fn: function (anInterpreter,aBlock){
  1393. var self=this;
  1394. return smalltalk.withContext(function($ctx1) {
  1395. var $1;
  1396. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  1397. return $1;
  1398. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.CascadeNode)})},
  1399. args: ["anInterpreter", "aBlock"],
  1400. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  1401. messageSends: ["interpretCascadeNode:continue:"],
  1402. referencedClasses: []
  1403. }),
  1404. smalltalk.CascadeNode);
  1405. smalltalk.addMethod(
  1406. "_interpreter_continue_",
  1407. smalltalk.method({
  1408. selector: "interpreter:continue:",
  1409. category: '*Compiler-Interpreter',
  1410. fn: function (anInterpreter,aBlock){
  1411. var self=this;
  1412. return smalltalk.withContext(function($ctx1) {
  1413. var $1;
  1414. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  1415. return $1;
  1416. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicArrayNode)})},
  1417. args: ["anInterpreter", "aBlock"],
  1418. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  1419. messageSends: ["interpretDynamicArrayNode:continue:"],
  1420. referencedClasses: []
  1421. }),
  1422. smalltalk.DynamicArrayNode);
  1423. smalltalk.addMethod(
  1424. "_isSteppingNode",
  1425. smalltalk.method({
  1426. selector: "isSteppingNode",
  1427. category: '*Compiler-Interpreter',
  1428. fn: function (){
  1429. var self=this;
  1430. return smalltalk.withContext(function($ctx1) {
  1431. return true;
  1432. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
  1433. args: [],
  1434. source: "isSteppingNode\x0a\x09^ true",
  1435. messageSends: [],
  1436. referencedClasses: []
  1437. }),
  1438. smalltalk.DynamicArrayNode);
  1439. smalltalk.addMethod(
  1440. "_interpreter_continue_",
  1441. smalltalk.method({
  1442. selector: "interpreter:continue:",
  1443. category: '*Compiler-Interpreter',
  1444. fn: function (anInterpreter,aBlock){
  1445. var self=this;
  1446. return smalltalk.withContext(function($ctx1) {
  1447. var $1;
  1448. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  1449. return $1;
  1450. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicDictionaryNode)})},
  1451. args: ["anInterpreter", "aBlock"],
  1452. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  1453. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  1454. referencedClasses: []
  1455. }),
  1456. smalltalk.DynamicDictionaryNode);
  1457. smalltalk.addMethod(
  1458. "_isSteppingNode",
  1459. smalltalk.method({
  1460. selector: "isSteppingNode",
  1461. category: '*Compiler-Interpreter',
  1462. fn: function (){
  1463. var self=this;
  1464. return smalltalk.withContext(function($ctx1) {
  1465. return true;
  1466. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
  1467. args: [],
  1468. source: "isSteppingNode\x0a\x09^ true",
  1469. messageSends: [],
  1470. referencedClasses: []
  1471. }),
  1472. smalltalk.DynamicDictionaryNode);
  1473. smalltalk.addMethod(
  1474. "_interpreter_continue_",
  1475. smalltalk.method({
  1476. selector: "interpreter:continue:",
  1477. category: '*Compiler-Interpreter',
  1478. fn: function (anInterpreter,aBlock){
  1479. var self=this;
  1480. return smalltalk.withContext(function($ctx1) {
  1481. var $1;
  1482. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  1483. return $1;
  1484. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.JSStatementNode)})},
  1485. args: ["anInterpreter", "aBlock"],
  1486. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  1487. messageSends: ["interpretJSStatementNode:continue:"],
  1488. referencedClasses: []
  1489. }),
  1490. smalltalk.JSStatementNode);
  1491. smalltalk.addMethod(
  1492. "_isSteppingNode",
  1493. smalltalk.method({
  1494. selector: "isSteppingNode",
  1495. category: '*Compiler-Interpreter',
  1496. fn: function (){
  1497. var self=this;
  1498. return smalltalk.withContext(function($ctx1) {
  1499. return true;
  1500. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
  1501. args: [],
  1502. source: "isSteppingNode\x0a\x09^ true",
  1503. messageSends: [],
  1504. referencedClasses: []
  1505. }),
  1506. smalltalk.JSStatementNode);
  1507. smalltalk.addMethod(
  1508. "_interpreter_continue_",
  1509. smalltalk.method({
  1510. selector: "interpreter:continue:",
  1511. category: '*Compiler-Interpreter',
  1512. fn: function (anInterpreter,aBlock){
  1513. var self=this;
  1514. return smalltalk.withContext(function($ctx1) {
  1515. var $1;
  1516. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  1517. return $1;
  1518. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.MethodNode)})},
  1519. args: ["anInterpreter", "aBlock"],
  1520. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  1521. messageSends: ["interpretMethodNode:continue:"],
  1522. referencedClasses: []
  1523. }),
  1524. smalltalk.MethodNode);
  1525. smalltalk.addMethod(
  1526. "_interpreter_continue_",
  1527. smalltalk.method({
  1528. selector: "interpreter:continue:",
  1529. category: '*Compiler-Interpreter',
  1530. fn: function (anInterpreter,aBlock){
  1531. var self=this;
  1532. return smalltalk.withContext(function($ctx1) {
  1533. var $1;
  1534. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  1535. return $1;
  1536. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ReturnNode)})},
  1537. args: ["anInterpreter", "aBlock"],
  1538. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  1539. messageSends: ["interpretReturnNode:continue:"],
  1540. referencedClasses: []
  1541. }),
  1542. smalltalk.ReturnNode);
  1543. smalltalk.addMethod(
  1544. "_interpreter_continue_",
  1545. smalltalk.method({
  1546. selector: "interpreter:continue:",
  1547. category: '*Compiler-Interpreter',
  1548. fn: function (anInterpreter,aBlock){
  1549. var self=this;
  1550. return smalltalk.withContext(function($ctx1) {
  1551. var $1;
  1552. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  1553. return $1;
  1554. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SendNode)})},
  1555. args: ["anInterpreter", "aBlock"],
  1556. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  1557. messageSends: ["interpretSendNode:continue:"],
  1558. referencedClasses: []
  1559. }),
  1560. smalltalk.SendNode);
  1561. smalltalk.addMethod(
  1562. "_isSteppingNode",
  1563. smalltalk.method({
  1564. selector: "isSteppingNode",
  1565. category: '*Compiler-Interpreter',
  1566. fn: function (){
  1567. var self=this;
  1568. return smalltalk.withContext(function($ctx1) {
  1569. return true;
  1570. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
  1571. args: [],
  1572. source: "isSteppingNode\x0a\x09^ true",
  1573. messageSends: [],
  1574. referencedClasses: []
  1575. }),
  1576. smalltalk.SendNode);
  1577. smalltalk.addMethod(
  1578. "_interpreter_continue_",
  1579. smalltalk.method({
  1580. selector: "interpreter:continue:",
  1581. category: '*Compiler-Interpreter',
  1582. fn: function (anInterpreter,aBlock){
  1583. var self=this;
  1584. return smalltalk.withContext(function($ctx1) {
  1585. var $1;
  1586. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  1587. return $1;
  1588. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SequenceNode)})},
  1589. args: ["anInterpreter", "aBlock"],
  1590. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  1591. messageSends: ["interpretSequenceNode:continue:"],
  1592. referencedClasses: []
  1593. }),
  1594. smalltalk.SequenceNode);
  1595. smalltalk.addMethod(
  1596. "_interpreter_continue_",
  1597. smalltalk.method({
  1598. selector: "interpreter:continue:",
  1599. category: '*Compiler-Interpreter',
  1600. fn: function (anInterpreter,aBlock){
  1601. var self=this;
  1602. return smalltalk.withContext(function($ctx1) {
  1603. var $1;
  1604. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  1605. return $1;
  1606. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockSequenceNode)})},
  1607. args: ["anInterpreter", "aBlock"],
  1608. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  1609. messageSends: ["interpretBlockSequenceNode:continue:"],
  1610. referencedClasses: []
  1611. }),
  1612. smalltalk.BlockSequenceNode);
  1613. smalltalk.addMethod(
  1614. "_interpreter_continue_",
  1615. smalltalk.method({
  1616. selector: "interpreter:continue:",
  1617. category: '*Compiler-Interpreter',
  1618. fn: function (anInterpreter,aBlock){
  1619. var self=this;
  1620. return smalltalk.withContext(function($ctx1) {
  1621. var $1;
  1622. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  1623. return $1;
  1624. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ValueNode)})},
  1625. args: ["anInterpreter", "aBlock"],
  1626. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  1627. messageSends: ["interpretValueNode:continue:"],
  1628. referencedClasses: []
  1629. }),
  1630. smalltalk.ValueNode);
  1631. smalltalk.addMethod(
  1632. "_interpreter_continue_",
  1633. smalltalk.method({
  1634. selector: "interpreter:continue:",
  1635. category: '*Compiler-Interpreter',
  1636. fn: function (anInterpreter,aBlock){
  1637. var self=this;
  1638. return smalltalk.withContext(function($ctx1) {
  1639. var $1;
  1640. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  1641. return $1;
  1642. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.VariableNode)})},
  1643. args: ["anInterpreter", "aBlock"],
  1644. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  1645. messageSends: ["interpretVariableNode:continue:"],
  1646. referencedClasses: []
  1647. }),
  1648. smalltalk.VariableNode);
  1649. smalltalk.addMethod(
  1650. "_interpreter_continue_",
  1651. smalltalk.method({
  1652. selector: "interpreter:continue:",
  1653. category: '*Compiler-Interpreter',
  1654. fn: function (anInterpreter,aBlock){
  1655. var self=this;
  1656. return smalltalk.withContext(function($ctx1) {
  1657. var $1;
  1658. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  1659. return $1;
  1660. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ClassReferenceNode)})},
  1661. args: ["anInterpreter", "aBlock"],
  1662. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  1663. messageSends: ["interpretClassReferenceNode:continue:"],
  1664. referencedClasses: []
  1665. }),
  1666. smalltalk.ClassReferenceNode);