Compiler-Interpreter.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. smalltalk.addPackage('Compiler-Interpreter', {});
  2. smalltalk.addClass('AIContext', smalltalk.NodeVisitor, ['outerContext', 'pc', 'locals', 'selector'], '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) { var $1;
  12. _st(self)._pc_(_st(aMethodContext)._pc());
  13. _st(self)._receiver_(_st(aMethodContext)._receiver());
  14. _st(self)._selector_(_st(aMethodContext)._selector());
  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) { return _st(_st(self)._locals())._at_put_(key,value);
  23. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  24. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext}, smalltalk.AIContext)})},
  25. args: ["aMethodContext"],
  26. source: "initializeFromMethodContext: aMethodContext\x0a\x09self pc: aMethodContext pc.\x0a self receiver: aMethodContext receiver.\x0a self selector: aMethodContext selector.\x0a aMethodContext outerContext ifNotNil: [\x0a\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a aMethodContext locals keysAndValuesDo: [ :key :value |\x0a \x09self locals at: key put: value ]\x0a ",
  27. messageSends: ["pc:", "pc", "receiver:", "receiver", "selector:", "selector", "ifNotNil:", "outerContext:", "fromMethodContext:", "outerContext", "class", "keysAndValuesDo:", "at:put:", "locals"],
  28. referencedClasses: []
  29. }),
  30. smalltalk.AIContext);
  31. smalltalk.addMethod(
  32. "_localAt_",
  33. smalltalk.method({
  34. selector: "localAt:",
  35. category: 'accessing',
  36. fn: function (aString){
  37. var self=this;
  38. return smalltalk.withContext(function($ctx1) { var $1;
  39. $1=_st(_st(self)._locals())._at_ifAbsent_(aString,(function(){
  40. return smalltalk.withContext(function($ctx2) { return nil;
  41. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  42. return $1;
  43. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString}, smalltalk.AIContext)})},
  44. args: ["aString"],
  45. source: "localAt: aString\x0a\x09^ self locals at: aString ifAbsent: [ nil ]",
  46. messageSends: ["at:ifAbsent:", "locals"],
  47. referencedClasses: []
  48. }),
  49. smalltalk.AIContext);
  50. smalltalk.addMethod(
  51. "_localAt_put_",
  52. smalltalk.method({
  53. selector: "localAt:put:",
  54. category: 'accessing',
  55. fn: function (aString,anObject){
  56. var self=this;
  57. return smalltalk.withContext(function($ctx1) { _st(_st(self)._locals())._at_put_(aString,anObject);
  58. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject}, smalltalk.AIContext)})},
  59. args: ["aString", "anObject"],
  60. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  61. messageSends: ["at:put:", "locals"],
  62. referencedClasses: []
  63. }),
  64. smalltalk.AIContext);
  65. smalltalk.addMethod(
  66. "_locals",
  67. smalltalk.method({
  68. selector: "locals",
  69. category: 'accessing',
  70. fn: function (){
  71. var self=this;
  72. return smalltalk.withContext(function($ctx1) { var $2,$1;
  73. $2=self["@locals"];
  74. if(($receiver = $2) == nil || $receiver == undefined){
  75. self["@locals"]=_st((smalltalk.Dictionary || Dictionary))._new();
  76. $1=self["@locals"];
  77. } else {
  78. $1=$2;
  79. };
  80. return $1;
  81. }, function($ctx1) {$ctx1.fill(self,"locals",{}, smalltalk.AIContext)})},
  82. args: [],
  83. source: "locals\x0a\x09^ locals ifNil: [ locals := Dictionary new ]",
  84. messageSends: ["ifNil:", "new"],
  85. referencedClasses: ["Dictionary"]
  86. }),
  87. smalltalk.AIContext);
  88. smalltalk.addMethod(
  89. "_outerContext",
  90. smalltalk.method({
  91. selector: "outerContext",
  92. category: 'accessing',
  93. fn: function (){
  94. var self=this;
  95. return smalltalk.withContext(function($ctx1) { var $1;
  96. $1=self["@outerContext"];
  97. return $1;
  98. }, function($ctx1) {$ctx1.fill(self,"outerContext",{}, smalltalk.AIContext)})},
  99. args: [],
  100. source: "outerContext\x0a\x09^ outerContext",
  101. messageSends: [],
  102. referencedClasses: []
  103. }),
  104. smalltalk.AIContext);
  105. smalltalk.addMethod(
  106. "_outerContext_",
  107. smalltalk.method({
  108. selector: "outerContext:",
  109. category: 'accessing',
  110. fn: function (anAIContext){
  111. var self=this;
  112. return smalltalk.withContext(function($ctx1) { self["@outerContext"]=anAIContext;
  113. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext}, smalltalk.AIContext)})},
  114. args: ["anAIContext"],
  115. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext",
  116. messageSends: [],
  117. referencedClasses: []
  118. }),
  119. smalltalk.AIContext);
  120. smalltalk.addMethod(
  121. "_pc",
  122. smalltalk.method({
  123. selector: "pc",
  124. category: 'accessing',
  125. fn: function (){
  126. var self=this;
  127. return smalltalk.withContext(function($ctx1) { var $2,$1;
  128. $2=self["@pc"];
  129. if(($receiver = $2) == nil || $receiver == undefined){
  130. self["@pc"]=(0);
  131. $1=self["@pc"];
  132. } else {
  133. $1=$2;
  134. };
  135. return $1;
  136. }, function($ctx1) {$ctx1.fill(self,"pc",{}, smalltalk.AIContext)})},
  137. args: [],
  138. source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
  139. messageSends: ["ifNil:"],
  140. referencedClasses: []
  141. }),
  142. smalltalk.AIContext);
  143. smalltalk.addMethod(
  144. "_pc_",
  145. smalltalk.method({
  146. selector: "pc:",
  147. category: 'accessing',
  148. fn: function (anInteger){
  149. var self=this;
  150. return smalltalk.withContext(function($ctx1) { self["@pc"]=anInteger;
  151. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger}, smalltalk.AIContext)})},
  152. args: ["anInteger"],
  153. source: "pc: anInteger\x0a\x09pc := anInteger",
  154. messageSends: [],
  155. referencedClasses: []
  156. }),
  157. smalltalk.AIContext);
  158. smalltalk.addMethod(
  159. "_receiver",
  160. smalltalk.method({
  161. selector: "receiver",
  162. category: 'accessing',
  163. fn: function (){
  164. var self=this;
  165. return smalltalk.withContext(function($ctx1) { var $1;
  166. $1=_st(self)._localAt_("self");
  167. return $1;
  168. }, function($ctx1) {$ctx1.fill(self,"receiver",{}, smalltalk.AIContext)})},
  169. args: [],
  170. source: "receiver\x0a\x09^ self localAt: 'self'",
  171. messageSends: ["localAt:"],
  172. referencedClasses: []
  173. }),
  174. smalltalk.AIContext);
  175. smalltalk.addMethod(
  176. "_receiver_",
  177. smalltalk.method({
  178. selector: "receiver:",
  179. category: 'accessing',
  180. fn: function (anObject){
  181. var self=this;
  182. return smalltalk.withContext(function($ctx1) { _st(self)._localAt_put_("self",anObject);
  183. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject}, smalltalk.AIContext)})},
  184. args: ["anObject"],
  185. source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
  186. messageSends: ["localAt:put:"],
  187. referencedClasses: []
  188. }),
  189. smalltalk.AIContext);
  190. smalltalk.addClass('ASTInterpreter', smalltalk.Object, ['currentNode', 'context', 'shouldReturn', 'result'], 'Compiler-Interpreter');
  191. 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 | ast interpreter |\x0a ast := Smalltalk current parse: 'foo 1+2+4'.\x0a (SemanticAnalyzer on: Object) visit: ast.\x0a\x0a ASTInterpreter new\x0a interpret: ast nodes first;\x0a result \x22Answers 7\x22"
  192. smalltalk.addMethod(
  193. "_assign_to_",
  194. smalltalk.method({
  195. selector: "assign:to:",
  196. category: 'private',
  197. fn: function (aNode,anObject){
  198. var self=this;
  199. return smalltalk.withContext(function($ctx1) { var $2,$1;
  200. $2=_st(_st(aNode)._binding())._isInstanceVar();
  201. if(smalltalk.assert($2)){
  202. $1=_st(_st(_st(self)._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  203. } else {
  204. $1=_st(_st(self)._context())._localAt_put_(_st(aNode)._value(),anObject);
  205. };
  206. return $1;
  207. }, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject}, smalltalk.ASTInterpreter)})},
  208. args: ["aNode", "anObject"],
  209. source: "assign: aNode to: anObject\x0a\x09^ aNode binding isInstanceVar \x0a \x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a \x09ifFalse: [ self context localAt: aNode value put: anObject ]",
  210. messageSends: ["ifTrue:ifFalse:", "instVarAt:put:", "value", "receiver", "context", "localAt:put:", "isInstanceVar", "binding"],
  211. referencedClasses: []
  212. }),
  213. smalltalk.ASTInterpreter);
  214. smalltalk.addMethod(
  215. "_context",
  216. smalltalk.method({
  217. selector: "context",
  218. category: 'accessing',
  219. fn: function (){
  220. var self=this;
  221. return smalltalk.withContext(function($ctx1) { var $2,$1;
  222. $2=self["@context"];
  223. if(($receiver = $2) == nil || $receiver == undefined){
  224. self["@context"]=_st((smalltalk.AIContext || AIContext))._new();
  225. $1=self["@context"];
  226. } else {
  227. $1=$2;
  228. };
  229. return $1;
  230. }, function($ctx1) {$ctx1.fill(self,"context",{}, smalltalk.ASTInterpreter)})},
  231. args: [],
  232. source: "context\x0a\x09^ context ifNil: [ context := AIContext new ]",
  233. messageSends: ["ifNil:", "new"],
  234. referencedClasses: ["AIContext"]
  235. }),
  236. smalltalk.ASTInterpreter);
  237. smalltalk.addMethod(
  238. "_context_",
  239. smalltalk.method({
  240. selector: "context:",
  241. category: 'accessing',
  242. fn: function (anAIContext){
  243. var self=this;
  244. return smalltalk.withContext(function($ctx1) { self["@context"]=anAIContext;
  245. return self}, function($ctx1) {$ctx1.fill(self,"context:",{anAIContext:anAIContext}, smalltalk.ASTInterpreter)})},
  246. args: ["anAIContext"],
  247. source: "context: anAIContext\x0a\x09context := anAIContext",
  248. messageSends: [],
  249. referencedClasses: []
  250. }),
  251. smalltalk.ASTInterpreter);
  252. smalltalk.addMethod(
  253. "_continue_value_",
  254. smalltalk.method({
  255. selector: "continue:value:",
  256. category: 'private',
  257. fn: function (aBlock,anObject){
  258. var self=this;
  259. return smalltalk.withContext(function($ctx1) { self["@result"]=anObject;
  260. _st(aBlock)._value_(anObject);
  261. return self}, function($ctx1) {$ctx1.fill(self,"continue:value:",{aBlock:aBlock,anObject:anObject}, smalltalk.ASTInterpreter)})},
  262. args: ["aBlock", "anObject"],
  263. source: "continue: aBlock value: anObject\x0a\x09result := anObject.\x0a aBlock value: anObject",
  264. messageSends: ["value:"],
  265. referencedClasses: []
  266. }),
  267. smalltalk.ASTInterpreter);
  268. smalltalk.addMethod(
  269. "_currentNode",
  270. smalltalk.method({
  271. selector: "currentNode",
  272. category: 'accessing',
  273. fn: function (){
  274. var self=this;
  275. return smalltalk.withContext(function($ctx1) { var $1;
  276. $1=self["@currentNode"];
  277. return $1;
  278. }, function($ctx1) {$ctx1.fill(self,"currentNode",{}, smalltalk.ASTInterpreter)})},
  279. args: [],
  280. source: "currentNode\x0a\x09^ currentNode",
  281. messageSends: [],
  282. referencedClasses: []
  283. }),
  284. smalltalk.ASTInterpreter);
  285. smalltalk.addMethod(
  286. "_eval_",
  287. smalltalk.method({
  288. selector: "eval:",
  289. category: 'private',
  290. fn: function (aString){
  291. var self=this;
  292. var source,function_;
  293. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  294. source=_st((smalltalk.String || String))._streamContents_((function(str){
  295. return smalltalk.withContext(function($ctx2) { _st(str)._nextPutAll_("(function(");
  296. _st(_st(_st(_st(self)._context())._locals())._keys())._do_separatedBy_((function(each){
  297. return smalltalk.withContext(function($ctx3) { return _st(str)._nextPutAll_(each);
  298. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}),(function(){
  299. return smalltalk.withContext(function($ctx3) { return _st(str)._nextPutAll_(",");
  300. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  301. $1=str;
  302. _st($1)._nextPutAll_("){ return (function() {");
  303. _st($1)._nextPutAll_(aString);
  304. $2=_st($1)._nextPutAll_("})() })");
  305. return $2;
  306. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
  307. function_=_st(_st((smalltalk.Compiler || Compiler))._new())._eval_(source);
  308. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(_st(self)._context())._locals())._values());
  309. return $3;
  310. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_}, smalltalk.ASTInterpreter)})},
  311. args: ["aString"],
  312. source: "eval: aString\x0a\x09\x22Evaluate aString as JS source inside an JS function. \x0a aString is not sandboxed.\x22\x0a \x0a | source function |\x0a \x0a source := String streamContents: [ :str |\x0a \x09str nextPutAll: '(function('.\x0a self context locals keys \x0a \x09do: [ :each | str nextPutAll: each ]\x0a \x09separatedBy: [ str nextPutAll: ',' ].\x0a str \x0a \x09nextPutAll: '){ return (function() {';\x0a \x09nextPutAll: aString;\x0a nextPutAll: '})() })' ].\x0a \x0a\x09function := Compiler new eval: source.\x0a \x0a\x09^ function valueWithPossibleArguments: self context locals values",
  313. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  314. referencedClasses: ["String", "Compiler"]
  315. }),
  316. smalltalk.ASTInterpreter);
  317. smalltalk.addMethod(
  318. "_initialize",
  319. smalltalk.method({
  320. selector: "initialize",
  321. category: 'initialization',
  322. fn: function (){
  323. var self=this;
  324. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  325. self["@shouldReturn"]=false;
  326. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.ASTInterpreter)})},
  327. args: [],
  328. source: "initialize\x0a\x09super initialize.\x0a shouldReturn := false",
  329. messageSends: ["initialize"],
  330. referencedClasses: []
  331. }),
  332. smalltalk.ASTInterpreter);
  333. smalltalk.addMethod(
  334. "_interpret_",
  335. smalltalk.method({
  336. selector: "interpret:",
  337. category: 'interpreting',
  338. fn: function (aNode){
  339. var self=this;
  340. return smalltalk.withContext(function($ctx1) { self["@shouldReturn"]=false;
  341. _st(self)._interpret_continue_(aNode,(function(value){
  342. return smalltalk.withContext(function($ctx2) { self["@result"]=value;
  343. return self["@result"];
  344. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  345. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
  346. args: ["aNode"],
  347. source: "interpret: aNode\x0a\x09shouldReturn := false.\x0a self interpret: aNode continue: [ :value |\x0a \x09result := value ]",
  348. messageSends: ["interpret:continue:"],
  349. referencedClasses: []
  350. }),
  351. smalltalk.ASTInterpreter);
  352. smalltalk.addMethod(
  353. "_interpret_continue_",
  354. smalltalk.method({
  355. selector: "interpret:continue:",
  356. category: 'interpreting',
  357. fn: function (aNode,aBlock){
  358. var self=this;
  359. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  360. $1=self["@shouldReturn"];
  361. if(smalltalk.assert($1)){
  362. $2=self;
  363. return $2;
  364. };
  365. $3=_st(aNode)._isNode();
  366. if(smalltalk.assert($3)){
  367. self["@currentNode"]=aNode;
  368. self["@currentNode"];
  369. _st(console)._log_(aNode);
  370. _st(self)._interpretNode_continue_(aNode,(function(value){
  371. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,value);
  372. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  373. } else {
  374. _st(self)._continue_value_(aBlock,aNode);
  375. };
  376. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  377. args: ["aNode", "aBlock"],
  378. source: "interpret: aNode continue: aBlock\x0a\x09shouldReturn ifTrue: [ ^ self ].\x0a\x0a\x09aNode isNode \x0a \x09ifTrue: [ \x09\x0a \x09currentNode := aNode.\x0a console log: aNode.\x0a self interpretNode: aNode continue: [ :value |\x0a \x09\x09\x09\x09self continue: aBlock value: value] ]\x0a ifFalse: [ self continue: aBlock value: aNode ]",
  379. messageSends: ["ifTrue:", "ifTrue:ifFalse:", "log:", "interpretNode:continue:", "continue:value:", "isNode"],
  380. referencedClasses: []
  381. }),
  382. smalltalk.ASTInterpreter);
  383. smalltalk.addMethod(
  384. "_interpretAll_continue_",
  385. smalltalk.method({
  386. selector: "interpretAll:continue:",
  387. category: 'private',
  388. fn: function (aCollection,aBlock){
  389. var self=this;
  390. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_result_(aCollection,aBlock,_st((smalltalk.OrderedCollection || OrderedCollection))._new());
  391. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:",{aCollection:aCollection,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  392. args: ["aCollection", "aBlock"],
  393. source: "interpretAll: aCollection continue: aBlock\x0a\x09self \x0a \x09interpretAll: aCollection \x0a continue: aBlock \x0a result: OrderedCollection new",
  394. messageSends: ["interpretAll:continue:result:", "new"],
  395. referencedClasses: ["OrderedCollection"]
  396. }),
  397. smalltalk.ASTInterpreter);
  398. smalltalk.addMethod(
  399. "_interpretAll_continue_result_",
  400. smalltalk.method({
  401. selector: "interpretAll:continue:result:",
  402. category: 'private',
  403. fn: function (nodes,aBlock,aCollection){
  404. var self=this;
  405. return smalltalk.withContext(function($ctx1) { var $1;
  406. $1=_st(nodes)._isEmpty();
  407. if(smalltalk.assert($1)){
  408. _st(self)._continue_value_(aBlock,aCollection);
  409. } else {
  410. _st(self)._interpret_continue_(_st(nodes)._first(),(function(value){
  411. return smalltalk.withContext(function($ctx2) { return _st(self)._interpretAll_continue_result_(_st(nodes)._allButFirst(),aBlock,_st(aCollection).__comma([value]));
  412. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  413. };
  414. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:result:",{nodes:nodes,aBlock:aBlock,aCollection:aCollection}, smalltalk.ASTInterpreter)})},
  415. args: ["nodes", "aBlock", "aCollection"],
  416. source: "interpretAll: nodes continue: aBlock result: aCollection\x0a\x09nodes isEmpty \x0a \x09ifTrue: [ self continue: aBlock value: aCollection ]\x0a \x09ifFalse: [\x0a \x09\x09self interpret: nodes first continue: [:value |\x0a \x09\x09\x09self \x0a \x09interpretAll: nodes allButFirst \x0a continue: aBlock\x0a \x09\x09\x09\x09\x09result: aCollection, { value } ] ]",
  417. messageSends: ["ifTrue:ifFalse:", "continue:value:", "interpret:continue:", "first", "interpretAll:continue:result:", "allButFirst", ",", "isEmpty"],
  418. referencedClasses: []
  419. }),
  420. smalltalk.ASTInterpreter);
  421. smalltalk.addMethod(
  422. "_interpretAssignmentNode_continue_",
  423. smalltalk.method({
  424. selector: "interpretAssignmentNode:continue:",
  425. category: 'interpreting',
  426. fn: function (aNode,aBlock){
  427. var self=this;
  428. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(aNode)._right(),(function(value){
  429. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,_st(self)._assign_to_(_st(aNode)._left(),value));
  430. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  431. return self}, function($ctx1) {$ctx1.fill(self,"interpretAssignmentNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  432. args: ["aNode", "aBlock"],
  433. source: "interpretAssignmentNode: aNode continue: aBlock\x0a\x09self interpret: aNode right continue: [ :value |\x0a \x09self \x0a \x09continue: aBlock\x0a value: (self assign: aNode left to: value) ]",
  434. messageSends: ["interpret:continue:", "right", "continue:value:", "assign:to:", "left"],
  435. referencedClasses: []
  436. }),
  437. smalltalk.ASTInterpreter);
  438. smalltalk.addMethod(
  439. "_interpretBlockNode_continue_",
  440. smalltalk.method({
  441. selector: "interpretBlockNode:continue:",
  442. category: 'interpreting',
  443. fn: function (aNode,aBlock){
  444. var self=this;
  445. return smalltalk.withContext(function($ctx1) { var $1,$2;
  446. _st(self)._continue_value_(aBlock,(function(){
  447. return smalltalk.withContext(function($ctx2) { $1=self;
  448. _st($1)._interpret_(_st(_st(aNode)._nodes())._first());
  449. $2=_st($1)._result();
  450. return $2;
  451. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  452. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  453. args: ["aNode", "aBlock"],
  454. source: "interpretBlockNode: aNode continue: aBlock\x0a\x09\x22TODO: Context should be set\x22\x0a \x0a self \x0a \x09continue: aBlock \x0a value: [ self interpret: aNode nodes first; result ]",
  455. messageSends: ["continue:value:", "interpret:", "first", "nodes", "result"],
  456. referencedClasses: []
  457. }),
  458. smalltalk.ASTInterpreter);
  459. smalltalk.addMethod(
  460. "_interpretBlockSequenceNode_continue_",
  461. smalltalk.method({
  462. selector: "interpretBlockSequenceNode:continue:",
  463. category: 'interpreting',
  464. fn: function (aNode,aBlock){
  465. var self=this;
  466. return smalltalk.withContext(function($ctx1) { _st(self)._interpretSequenceNode_continue_(aNode,aBlock);
  467. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockSequenceNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  468. args: ["aNode", "aBlock"],
  469. source: "interpretBlockSequenceNode: aNode continue: aBlock\x0a\x09self interpretSequenceNode: aNode continue: aBlock",
  470. messageSends: ["interpretSequenceNode:continue:"],
  471. referencedClasses: []
  472. }),
  473. smalltalk.ASTInterpreter);
  474. smalltalk.addMethod(
  475. "_interpretCascadeNode_continue_",
  476. smalltalk.method({
  477. selector: "interpretCascadeNode:continue:",
  478. category: 'interpreting',
  479. fn: function (aNode,aBlock){
  480. var self=this;
  481. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  482. return smalltalk.withContext(function($ctx2) { _st(_st(aNode)._nodes())._do_((function(each){
  483. return smalltalk.withContext(function($ctx3) { return _st(each)._receiver_(receiver);
  484. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  485. return _st(self)._interpretAll_continue_(_st(_st(aNode)._nodes())._allButLast(),(function(){
  486. return smalltalk.withContext(function($ctx3) { return _st(self)._interpret_continue_(_st(_st(aNode)._nodes())._last(),(function(val){
  487. return smalltalk.withContext(function($ctx4) { return _st(self)._continue_value_(aBlock,val);
  488. }, function($ctx4) {$ctx4.fillBlock({val:val},$ctx1)})}));
  489. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  490. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  491. return self}, function($ctx1) {$ctx1.fill(self,"interpretCascadeNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  492. args: ["aNode", "aBlock"],
  493. source: "interpretCascadeNode: aNode continue: aBlock\x0a\x09\x22TODO: Handle super sends\x22\x0a\x09\x0a self interpret: aNode receiver continue: [ :receiver |\x0a\x09\x09\x22Only interpret the receiver once\x22\x0a aNode nodes do: [ :each | each receiver: receiver ].\x0a \x0a \x09self \x0a \x09interpretAll: aNode nodes allButLast\x0a \x09\x09continue: [\x0a \x09self \x0a \x09interpret: aNode nodes last\x0a \x09continue: [ :val | self continue: aBlock value: val ] ] ]",
  494. messageSends: ["interpret:continue:", "receiver", "do:", "receiver:", "nodes", "interpretAll:continue:", "allButLast", "last", "continue:value:"],
  495. referencedClasses: []
  496. }),
  497. smalltalk.ASTInterpreter);
  498. smalltalk.addMethod(
  499. "_interpretClassReferenceNode_continue_",
  500. smalltalk.method({
  501. selector: "interpretClassReferenceNode:continue:",
  502. category: 'interpreting',
  503. fn: function (aNode,aBlock){
  504. var self=this;
  505. return smalltalk.withContext(function($ctx1) { _st(self)._continue_value_(aBlock,_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(_st(aNode)._value()));
  506. return self}, function($ctx1) {$ctx1.fill(self,"interpretClassReferenceNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  507. args: ["aNode", "aBlock"],
  508. source: "interpretClassReferenceNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: (Smalltalk current at: aNode value)",
  509. messageSends: ["continue:value:", "at:", "value", "current"],
  510. referencedClasses: ["Smalltalk"]
  511. }),
  512. smalltalk.ASTInterpreter);
  513. smalltalk.addMethod(
  514. "_interpretDynamicArrayNode_continue_",
  515. smalltalk.method({
  516. selector: "interpretDynamicArrayNode:continue:",
  517. category: 'interpreting',
  518. fn: function (aNode,aBlock){
  519. var self=this;
  520. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  521. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,array);
  522. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  523. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicArrayNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  524. args: ["aNode", "aBlock"],
  525. source: "interpretDynamicArrayNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a \x09self \x0a \x09continue: aBlock\x0a\x09\x09\x09value: array ]",
  526. messageSends: ["interpretAll:continue:", "nodes", "continue:value:"],
  527. referencedClasses: []
  528. }),
  529. smalltalk.ASTInterpreter);
  530. smalltalk.addMethod(
  531. "_interpretDynamicDictionaryNode_continue_",
  532. smalltalk.method({
  533. selector: "interpretDynamicDictionaryNode:continue:",
  534. category: 'interpreting',
  535. fn: function (aNode,aBlock){
  536. var self=this;
  537. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  538. var hashedCollection;
  539. return smalltalk.withContext(function($ctx2) { hashedCollection=_st((smalltalk.HashedCollection || HashedCollection))._new();
  540. hashedCollection;
  541. _st(array)._do_((function(each){
  542. return smalltalk.withContext(function($ctx3) { return _st(hashedCollection)._add_(each);
  543. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  544. return _st(self)._continue_value_(aBlock,hashedCollection);
  545. }, function($ctx2) {$ctx2.fillBlock({array:array,hashedCollection:hashedCollection},$ctx1)})}));
  546. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicDictionaryNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  547. args: ["aNode", "aBlock"],
  548. source: "interpretDynamicDictionaryNode: aNode continue: aBlock\x0a self interpretAll: aNode nodes continue: [ :array | | hashedCollection |\x0a \x09hashedCollection := HashedCollection new.\x0a array do: [ :each | hashedCollection add: each ].\x0a self \x09\x0a \x09continue: aBlock\x0a value: hashedCollection ]",
  549. messageSends: ["interpretAll:continue:", "nodes", "new", "do:", "add:", "continue:value:"],
  550. referencedClasses: ["HashedCollection"]
  551. }),
  552. smalltalk.ASTInterpreter);
  553. smalltalk.addMethod(
  554. "_interpretJSStatementNode_continue_",
  555. smalltalk.method({
  556. selector: "interpretJSStatementNode:continue:",
  557. category: 'interpreting',
  558. fn: function (aNode,aBlock){
  559. var self=this;
  560. return smalltalk.withContext(function($ctx1) { self["@shouldReturn"]=true;
  561. _st(self)._continue_value_(aBlock,_st(self)._eval_(_st(aNode)._source()));
  562. return self}, function($ctx1) {$ctx1.fill(self,"interpretJSStatementNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  563. args: ["aNode", "aBlock"],
  564. source: "interpretJSStatementNode: aNode continue: aBlock\x0a\x09shouldReturn := true.\x0a\x09self continue: aBlock value: (self eval: aNode source)",
  565. messageSends: ["continue:value:", "eval:", "source"],
  566. referencedClasses: []
  567. }),
  568. smalltalk.ASTInterpreter);
  569. smalltalk.addMethod(
  570. "_interpretMethodNode_continue_",
  571. smalltalk.method({
  572. selector: "interpretMethodNode:continue:",
  573. category: 'interpreting',
  574. fn: function (aNode,aBlock){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  577. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,_st(array)._first());
  578. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  579. return self}, function($ctx1) {$ctx1.fill(self,"interpretMethodNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  580. args: ["aNode", "aBlock"],
  581. source: "interpretMethodNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a \x09self continue: aBlock value: array first ]",
  582. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "first"],
  583. referencedClasses: []
  584. }),
  585. smalltalk.ASTInterpreter);
  586. smalltalk.addMethod(
  587. "_interpretNode_continue_",
  588. smalltalk.method({
  589. selector: "interpretNode:continue:",
  590. category: 'interpreting',
  591. fn: function (aNode,aBlock){
  592. var self=this;
  593. return smalltalk.withContext(function($ctx1) { _st(aNode)._interpreter_continue_(self,aBlock);
  594. return self}, function($ctx1) {$ctx1.fill(self,"interpretNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  595. args: ["aNode", "aBlock"],
  596. source: "interpretNode: aNode continue: aBlock\x0a aNode interpreter: self continue: aBlock",
  597. messageSends: ["interpreter:continue:"],
  598. referencedClasses: []
  599. }),
  600. smalltalk.ASTInterpreter);
  601. smalltalk.addMethod(
  602. "_interpretReturnNode_continue_",
  603. smalltalk.method({
  604. selector: "interpretReturnNode:continue:",
  605. category: 'interpreting',
  606. fn: function (aNode,aBlock){
  607. var self=this;
  608. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(_st(aNode)._nodes())._first(),(function(value){
  609. return smalltalk.withContext(function($ctx2) { self["@shouldReturn"]=true;
  610. self["@shouldReturn"];
  611. return _st(self)._continue_value_(aBlock,value);
  612. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  613. return self}, function($ctx1) {$ctx1.fill(self,"interpretReturnNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  614. args: ["aNode", "aBlock"],
  615. source: "interpretReturnNode: aNode continue: aBlock\x0a self interpret: aNode nodes first continue: [ :value |\x0a \x09shouldReturn := true.\x0a\x09\x09self continue: aBlock value: value ]",
  616. messageSends: ["interpret:continue:", "first", "nodes", "continue:value:"],
  617. referencedClasses: []
  618. }),
  619. smalltalk.ASTInterpreter);
  620. smalltalk.addMethod(
  621. "_interpretSendNode_continue_",
  622. smalltalk.method({
  623. selector: "interpretSendNode:continue:",
  624. category: 'interpreting',
  625. fn: function (aNode,aBlock){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  628. return smalltalk.withContext(function($ctx2) { return _st(self)._interpretAll_continue_(_st(aNode)._arguments(),(function(args){
  629. return smalltalk.withContext(function($ctx3) { return _st(self)._messageFromSendNode_arguments_do_(aNode,args,(function(message){
  630. return smalltalk.withContext(function($ctx4) { _st(_st(self)._context())._pc_(_st(_st(_st(self)._context())._pc()).__plus((1)));
  631. return _st(self)._continue_value_(aBlock,_st(message)._sendTo_(receiver));
  632. }, function($ctx4) {$ctx4.fillBlock({message:message},$ctx1)})}));
  633. }, function($ctx3) {$ctx3.fillBlock({args:args},$ctx1)})}));
  634. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  635. return self}, function($ctx1) {$ctx1.fill(self,"interpretSendNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  636. args: ["aNode", "aBlock"],
  637. source: "interpretSendNode: aNode continue: aBlock\x0a\x09\x22TODO: Handle super sends\x22\x0a \x0a self interpret: aNode receiver continue: [ :receiver |\x0a \x09self interpretAll: aNode arguments continue: [ :args |\x0a \x09\x09self \x0a \x09messageFromSendNode: aNode \x0a arguments: args\x0a do: [ :message |\x0a \x09\x09\x09self context pc: self context pc + 1.\x0a \x09\x09\x09self \x0a \x09\x09\x09continue: aBlock \x0a \x09\x09value: (message sendTo: receiver) ] ] ]",
  638. messageSends: ["interpret:continue:", "receiver", "interpretAll:continue:", "arguments", "messageFromSendNode:arguments:do:", "pc:", "+", "pc", "context", "continue:value:", "sendTo:"],
  639. referencedClasses: []
  640. }),
  641. smalltalk.ASTInterpreter);
  642. smalltalk.addMethod(
  643. "_interpretSequenceNode_continue_",
  644. smalltalk.method({
  645. selector: "interpretSequenceNode:continue:",
  646. category: 'interpreting',
  647. fn: function (aNode,aBlock){
  648. var self=this;
  649. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  650. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,_st(array)._last());
  651. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  652. return self}, function($ctx1) {$ctx1.fill(self,"interpretSequenceNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  653. args: ["aNode", "aBlock"],
  654. source: "interpretSequenceNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a \x09self continue: aBlock value: array last ]",
  655. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "last"],
  656. referencedClasses: []
  657. }),
  658. smalltalk.ASTInterpreter);
  659. smalltalk.addMethod(
  660. "_interpretValueNode_continue_",
  661. smalltalk.method({
  662. selector: "interpretValueNode:continue:",
  663. category: 'interpreting',
  664. fn: function (aNode,aBlock){
  665. var self=this;
  666. return smalltalk.withContext(function($ctx1) { _st(self)._continue_value_(aBlock,_st(aNode)._value());
  667. return self}, function($ctx1) {$ctx1.fill(self,"interpretValueNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  668. args: ["aNode", "aBlock"],
  669. source: "interpretValueNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: aNode value",
  670. messageSends: ["continue:value:", "value"],
  671. referencedClasses: []
  672. }),
  673. smalltalk.ASTInterpreter);
  674. smalltalk.addMethod(
  675. "_interpretVariableNode_continue_",
  676. smalltalk.method({
  677. selector: "interpretVariableNode:continue:",
  678. category: 'interpreting',
  679. fn: function (aNode,aBlock){
  680. var self=this;
  681. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$3;
  682. $1=self;
  683. $2=aBlock;
  684. $4=_st(_st(aNode)._binding())._isInstanceVar();
  685. if(smalltalk.assert($4)){
  686. $3=_st(_st(_st(self)._context())._receiver())._instVarAt_(_st(aNode)._value());
  687. } else {
  688. $3=_st(_st(self)._context())._localAt_(_st(aNode)._value());
  689. };
  690. _st($1)._continue_value_($2,$3);
  691. return self}, function($ctx1) {$ctx1.fill(self,"interpretVariableNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  692. args: ["aNode", "aBlock"],
  693. source: "interpretVariableNode: aNode continue: aBlock\x0a self \x0a \x09continue: aBlock\x0a value: (aNode binding isInstanceVar\x0a\x09\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09\x09ifFalse: [ self context localAt: aNode value ])",
  694. messageSends: ["continue:value:", "ifTrue:ifFalse:", "instVarAt:", "value", "receiver", "context", "localAt:", "isInstanceVar", "binding"],
  695. referencedClasses: []
  696. }),
  697. smalltalk.ASTInterpreter);
  698. smalltalk.addMethod(
  699. "_messageFromSendNode_arguments_do_",
  700. smalltalk.method({
  701. selector: "messageFromSendNode:arguments:do:",
  702. category: 'private',
  703. fn: function (aSendNode,aCollection,aBlock){
  704. var self=this;
  705. return smalltalk.withContext(function($ctx1) { var $1,$2;
  706. $1=_st((smalltalk.Message || Message))._new();
  707. _st($1)._selector_(_st(aSendNode)._selector());
  708. _st($1)._arguments_(aCollection);
  709. $2=_st($1)._yourself();
  710. _st(self)._continue_value_(aBlock,$2);
  711. return self}, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:do:",{aSendNode:aSendNode,aCollection:aCollection,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  712. args: ["aSendNode", "aCollection", "aBlock"],
  713. source: "messageFromSendNode: aSendNode arguments: aCollection do: aBlock\x0a self \x0a continue: aBlock\x0a value: (Message new\x0a \x09\x09selector: aSendNode selector;\x0a \x09arguments: aCollection;\x0a \x09yourself)",
  714. messageSends: ["continue:value:", "selector:", "selector", "new", "arguments:", "yourself"],
  715. referencedClasses: ["Message"]
  716. }),
  717. smalltalk.ASTInterpreter);
  718. smalltalk.addMethod(
  719. "_result",
  720. smalltalk.method({
  721. selector: "result",
  722. category: 'accessing',
  723. fn: function (){
  724. var self=this;
  725. return smalltalk.withContext(function($ctx1) { var $1;
  726. $1=self["@result"];
  727. return $1;
  728. }, function($ctx1) {$ctx1.fill(self,"result",{}, smalltalk.ASTInterpreter)})},
  729. args: [],
  730. source: "result\x0a\x09^ result",
  731. messageSends: [],
  732. referencedClasses: []
  733. }),
  734. smalltalk.ASTInterpreter);
  735. smalltalk.addClass('ASTSteppingInterpreter', smalltalk.ASTInterpreter, ['continuation'], 'Compiler-Interpreter');
  736. smalltalk.ASTSteppingInterpreter.comment="ASTSteppingInterpreter is an interpreter with stepping capabilities.\x0aUse `#step` to actually interpret the next node.\x0a\x0aUsage example:\x0a\x0a | ast interpreter |\x0a ast := Smalltalk current parse: 'foo 1+2+4'.\x0a (SemanticAnalyzer on: Object) visit: ast.\x0a\x0a interpreter := ASTSteppingInterpreter new\x0a interpret: ast nodes first;\x0a yourself.\x0a \x0a debugger step; step.\x0a debugger step; step.\x0a debugger result.\x22Answers 1\x22\x0a debugger step.\x0a debugger result. \x22Answers 3\x22\x0a debugger step.\x0a debugger result. \x22Answers 7\x22\x0a "
  737. smalltalk.addMethod(
  738. "_initialize",
  739. smalltalk.method({
  740. selector: "initialize",
  741. category: 'initialization',
  742. fn: function (){
  743. var self=this;
  744. return smalltalk.withContext(function($ctx1) { smalltalk.ASTInterpreter.fn.prototype._initialize.apply(_st(self), []);
  745. self["@continuation"]=(function(){
  746. return smalltalk.withContext(function($ctx2) { }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  747. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.ASTDebugger)})},
  748. args: [],
  749. source: "initialize\x0a\x09super initialize.\x0a continuation := [ ]",
  750. messageSends: ["initialize"],
  751. referencedClasses: []
  752. }),
  753. smalltalk.ASTSteppingInterpreter);
  754. smalltalk.addMethod(
  755. "_interpret_continue_",
  756. smalltalk.method({
  757. selector: "interpret:continue:",
  758. category: 'interpreting',
  759. fn: function (aNode,aBlock){
  760. var self=this;
  761. return smalltalk.withContext(function($ctx1) { self["@continuation"]=(function(){
  762. return smalltalk.withContext(function($ctx2) { return smalltalk.ASTInterpreter.fn.prototype._interpret_continue_.apply(_st(self), [aNode,aBlock]);
  763. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  764. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTDebugger)})},
  765. args: ["aNode", "aBlock"],
  766. source: "interpret: aNode continue: aBlock\x0a\x09continuation := [ super interpret: aNode continue: aBlock ]",
  767. messageSends: ["interpret:continue:"],
  768. referencedClasses: []
  769. }),
  770. smalltalk.ASTSteppingInterpreter);
  771. smalltalk.addMethod(
  772. "_step",
  773. smalltalk.method({
  774. selector: "step",
  775. category: 'stepping',
  776. fn: function (){
  777. var self=this;
  778. return smalltalk.withContext(function($ctx1) { _st(self["@continuation"])._value();
  779. return self}, function($ctx1) {$ctx1.fill(self,"step",{}, smalltalk.ASTDebugger)})},
  780. args: [],
  781. source: "step\x0a\x09continuation value",
  782. messageSends: ["value"],
  783. referencedClasses: []
  784. }),
  785. smalltalk.ASTSteppingInterpreter);
  786. smalltalk.addMethod(
  787. "_interpreter_continue_",
  788. smalltalk.method({
  789. selector: "interpreter:continue:",
  790. category: '*Compiler-Interpreter',
  791. fn: function (anInterpreter,aBlock){
  792. var self=this;
  793. return smalltalk.withContext(function($ctx1) { var $1;
  794. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  795. return $1;
  796. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.Node)})},
  797. args: ["anInterpreter", "aBlock"],
  798. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  799. messageSends: ["interpretNode:continue:"],
  800. referencedClasses: []
  801. }),
  802. smalltalk.Node);
  803. smalltalk.addMethod(
  804. "_interpreter_continue_",
  805. smalltalk.method({
  806. selector: "interpreter:continue:",
  807. category: '*Compiler-Interpreter',
  808. fn: function (anInterpreter,aBlock){
  809. var self=this;
  810. return smalltalk.withContext(function($ctx1) { var $1;
  811. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  812. return $1;
  813. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.AssignmentNode)})},
  814. args: ["anInterpreter", "aBlock"],
  815. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  816. messageSends: ["interpretAssignmentNode:continue:"],
  817. referencedClasses: []
  818. }),
  819. smalltalk.AssignmentNode);
  820. smalltalk.addMethod(
  821. "_interpreter_continue_",
  822. smalltalk.method({
  823. selector: "interpreter:continue:",
  824. category: '*Compiler-Interpreter',
  825. fn: function (anInterpreter,aBlock){
  826. var self=this;
  827. return smalltalk.withContext(function($ctx1) { var $1;
  828. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  829. return $1;
  830. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.BlockNode)})},
  831. args: ["anInterpreter", "aBlock"],
  832. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  833. messageSends: ["interpretBlockNode:continue:"],
  834. referencedClasses: []
  835. }),
  836. smalltalk.BlockNode);
  837. smalltalk.addMethod(
  838. "_interpreter_continue_",
  839. smalltalk.method({
  840. selector: "interpreter:continue:",
  841. category: '*Compiler-Interpreter',
  842. fn: function (anInterpreter,aBlock){
  843. var self=this;
  844. return smalltalk.withContext(function($ctx1) { var $1;
  845. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  846. return $1;
  847. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.CascadeNode)})},
  848. args: ["anInterpreter", "aBlock"],
  849. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  850. messageSends: ["interpretCascadeNode:continue:"],
  851. referencedClasses: []
  852. }),
  853. smalltalk.CascadeNode);
  854. smalltalk.addMethod(
  855. "_interpreter_continue_",
  856. smalltalk.method({
  857. selector: "interpreter:continue:",
  858. category: '*Compiler-Interpreter',
  859. fn: function (anInterpreter,aBlock){
  860. var self=this;
  861. return smalltalk.withContext(function($ctx1) { var $1;
  862. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  863. return $1;
  864. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.DynamicArrayNode)})},
  865. args: ["anInterpreter", "aBlock"],
  866. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  867. messageSends: ["interpretDynamicArrayNode:continue:"],
  868. referencedClasses: []
  869. }),
  870. smalltalk.DynamicArrayNode);
  871. smalltalk.addMethod(
  872. "_interpreter_continue_",
  873. smalltalk.method({
  874. selector: "interpreter:continue:",
  875. category: '*Compiler-Interpreter',
  876. fn: function (anInterpreter,aBlock){
  877. var self=this;
  878. return smalltalk.withContext(function($ctx1) { var $1;
  879. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  880. return $1;
  881. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.DynamicDictionaryNode)})},
  882. args: ["anInterpreter", "aBlock"],
  883. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  884. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  885. referencedClasses: []
  886. }),
  887. smalltalk.DynamicDictionaryNode);
  888. smalltalk.addMethod(
  889. "_interpreter_continue_",
  890. smalltalk.method({
  891. selector: "interpreter:continue:",
  892. category: '*Compiler-Interpreter',
  893. fn: function (anInterpreter,aBlock){
  894. var self=this;
  895. return smalltalk.withContext(function($ctx1) { var $1;
  896. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  897. return $1;
  898. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.JSStatementNode)})},
  899. args: ["anInterpreter", "aBlock"],
  900. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  901. messageSends: ["interpretJSStatementNode:continue:"],
  902. referencedClasses: []
  903. }),
  904. smalltalk.JSStatementNode);
  905. smalltalk.addMethod(
  906. "_interpreter_continue_",
  907. smalltalk.method({
  908. selector: "interpreter:continue:",
  909. category: '*Compiler-Interpreter',
  910. fn: function (anInterpreter,aBlock){
  911. var self=this;
  912. return smalltalk.withContext(function($ctx1) { var $1;
  913. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  914. return $1;
  915. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.MethodNode)})},
  916. args: ["anInterpreter", "aBlock"],
  917. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  918. messageSends: ["interpretMethodNode:continue:"],
  919. referencedClasses: []
  920. }),
  921. smalltalk.MethodNode);
  922. smalltalk.addMethod(
  923. "_interpreter_continue_",
  924. smalltalk.method({
  925. selector: "interpreter:continue:",
  926. category: '*Compiler-Interpreter',
  927. fn: function (anInterpreter,aBlock){
  928. var self=this;
  929. return smalltalk.withContext(function($ctx1) { var $1;
  930. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  931. return $1;
  932. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.ReturnNode)})},
  933. args: ["anInterpreter", "aBlock"],
  934. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  935. messageSends: ["interpretReturnNode:continue:"],
  936. referencedClasses: []
  937. }),
  938. smalltalk.ReturnNode);
  939. smalltalk.addMethod(
  940. "_interpreter_continue_",
  941. smalltalk.method({
  942. selector: "interpreter:continue:",
  943. category: '*Compiler-Interpreter',
  944. fn: function (anInterpreter,aBlock){
  945. var self=this;
  946. return smalltalk.withContext(function($ctx1) { var $1;
  947. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  948. return $1;
  949. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.SendNode)})},
  950. args: ["anInterpreter", "aBlock"],
  951. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  952. messageSends: ["interpretSendNode:continue:"],
  953. referencedClasses: []
  954. }),
  955. smalltalk.SendNode);
  956. smalltalk.addMethod(
  957. "_interpreter_continue_",
  958. smalltalk.method({
  959. selector: "interpreter:continue:",
  960. category: '*Compiler-Interpreter',
  961. fn: function (anInterpreter,aBlock){
  962. var self=this;
  963. return smalltalk.withContext(function($ctx1) { var $1;
  964. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  965. return $1;
  966. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.SequenceNode)})},
  967. args: ["anInterpreter", "aBlock"],
  968. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  969. messageSends: ["interpretSequenceNode:continue:"],
  970. referencedClasses: []
  971. }),
  972. smalltalk.SequenceNode);
  973. smalltalk.addMethod(
  974. "_interpreter_continue_",
  975. smalltalk.method({
  976. selector: "interpreter:continue:",
  977. category: '*Compiler-Interpreter',
  978. fn: function (anInterpreter,aBlock){
  979. var self=this;
  980. return smalltalk.withContext(function($ctx1) { var $1;
  981. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  982. return $1;
  983. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.BlockSequenceNode)})},
  984. args: ["anInterpreter", "aBlock"],
  985. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  986. messageSends: ["interpretBlockSequenceNode:continue:"],
  987. referencedClasses: []
  988. }),
  989. smalltalk.BlockSequenceNode);
  990. smalltalk.addMethod(
  991. "_interpreter_continue_",
  992. smalltalk.method({
  993. selector: "interpreter:continue:",
  994. category: '*Compiler-Interpreter',
  995. fn: function (anInterpreter,aBlock){
  996. var self=this;
  997. return smalltalk.withContext(function($ctx1) { var $1;
  998. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  999. return $1;
  1000. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.ValueNode)})},
  1001. args: ["anInterpreter", "aBlock"],
  1002. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  1003. messageSends: ["interpretValueNode:continue:"],
  1004. referencedClasses: []
  1005. }),
  1006. smalltalk.ValueNode);
  1007. smalltalk.addMethod(
  1008. "_interpreter_continue_",
  1009. smalltalk.method({
  1010. selector: "interpreter:continue:",
  1011. category: '*Compiler-Interpreter',
  1012. fn: function (anInterpreter,aBlock){
  1013. var self=this;
  1014. return smalltalk.withContext(function($ctx1) { var $1;
  1015. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  1016. return $1;
  1017. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.VariableNode)})},
  1018. args: ["anInterpreter", "aBlock"],
  1019. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  1020. messageSends: ["interpretVariableNode:continue:"],
  1021. referencedClasses: []
  1022. }),
  1023. smalltalk.VariableNode);
  1024. smalltalk.addMethod(
  1025. "_interpreter_continue_",
  1026. smalltalk.method({
  1027. selector: "interpreter:continue:",
  1028. category: '*Compiler-Interpreter',
  1029. fn: function (anInterpreter,aBlock){
  1030. var self=this;
  1031. return smalltalk.withContext(function($ctx1) { var $1;
  1032. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  1033. return $1;
  1034. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.ClassReferenceNode)})},
  1035. args: ["anInterpreter", "aBlock"],
  1036. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  1037. messageSends: ["interpretClassReferenceNode:continue:"],
  1038. referencedClasses: []
  1039. }),
  1040. smalltalk.ClassReferenceNode);