Compiler-Interpreter.js 66 KB

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