Compiler-Interpreter.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  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(self)._interpretNode_continue_(aNode,(function(value){
  370. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,value);
  371. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  372. } else {
  373. _st(self)._continue_value_(aBlock,aNode);
  374. };
  375. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  376. args: ["aNode", "aBlock"],
  377. source: "interpret: aNode continue: aBlock\x0a\x09shouldReturn ifTrue: [ ^ self ].\x0a\x0a\x09aNode isNode \x0a \x09ifTrue: [ \x09\x0a \x09currentNode := aNode.\x0a self interpretNode: aNode continue: [ :value |\x0a \x09\x09\x09\x09self continue: aBlock value: value] ]\x0a ifFalse: [ self continue: aBlock value: aNode ]",
  378. messageSends: ["ifTrue:", "ifTrue:ifFalse:", "interpretNode:continue:", "continue:value:", "isNode"],
  379. referencedClasses: []
  380. }),
  381. smalltalk.ASTInterpreter);
  382. smalltalk.addMethod(
  383. "_interpretAll_continue_",
  384. smalltalk.method({
  385. selector: "interpretAll:continue:",
  386. category: 'private',
  387. fn: function (aCollection,aBlock){
  388. var self=this;
  389. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_result_(aCollection,aBlock,_st((smalltalk.OrderedCollection || OrderedCollection))._new());
  390. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:",{aCollection:aCollection,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  391. args: ["aCollection", "aBlock"],
  392. source: "interpretAll: aCollection continue: aBlock\x0a\x09self \x0a \x09interpretAll: aCollection \x0a continue: aBlock \x0a result: OrderedCollection new",
  393. messageSends: ["interpretAll:continue:result:", "new"],
  394. referencedClasses: ["OrderedCollection"]
  395. }),
  396. smalltalk.ASTInterpreter);
  397. smalltalk.addMethod(
  398. "_interpretAll_continue_result_",
  399. smalltalk.method({
  400. selector: "interpretAll:continue:result:",
  401. category: 'private',
  402. fn: function (nodes,aBlock,aCollection){
  403. var self=this;
  404. return smalltalk.withContext(function($ctx1) { var $1;
  405. $1=_st(nodes)._isEmpty();
  406. if(smalltalk.assert($1)){
  407. _st(self)._continue_value_(aBlock,aCollection);
  408. } else {
  409. _st(self)._interpret_continue_(_st(nodes)._first(),(function(value){
  410. return smalltalk.withContext(function($ctx2) { return _st(self)._interpretAll_continue_result_(_st(nodes)._allButFirst(),aBlock,_st(aCollection).__comma([value]));
  411. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  412. };
  413. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:result:",{nodes:nodes,aBlock:aBlock,aCollection:aCollection}, smalltalk.ASTInterpreter)})},
  414. args: ["nodes", "aBlock", "aCollection"],
  415. 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 } ] ]",
  416. messageSends: ["ifTrue:ifFalse:", "continue:value:", "interpret:continue:", "first", "interpretAll:continue:result:", "allButFirst", ",", "isEmpty"],
  417. referencedClasses: []
  418. }),
  419. smalltalk.ASTInterpreter);
  420. smalltalk.addMethod(
  421. "_interpretAssignmentNode_continue_",
  422. smalltalk.method({
  423. selector: "interpretAssignmentNode:continue:",
  424. category: 'interpreting',
  425. fn: function (aNode,aBlock){
  426. var self=this;
  427. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(aNode)._right(),(function(value){
  428. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,_st(self)._assign_to_(_st(aNode)._left(),value));
  429. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  430. return self}, function($ctx1) {$ctx1.fill(self,"interpretAssignmentNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  431. args: ["aNode", "aBlock"],
  432. 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) ]",
  433. messageSends: ["interpret:continue:", "right", "continue:value:", "assign:to:", "left"],
  434. referencedClasses: []
  435. }),
  436. smalltalk.ASTInterpreter);
  437. smalltalk.addMethod(
  438. "_interpretBlockNode_continue_",
  439. smalltalk.method({
  440. selector: "interpretBlockNode:continue:",
  441. category: 'interpreting',
  442. fn: function (aNode,aBlock){
  443. var self=this;
  444. return smalltalk.withContext(function($ctx1) { var $1,$2;
  445. _st(self)._continue_value_(aBlock,(function(){
  446. return smalltalk.withContext(function($ctx2) { $1=self;
  447. _st($1)._interpret_(_st(_st(aNode)._nodes())._first());
  448. $2=_st($1)._result();
  449. return $2;
  450. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  451. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  452. args: ["aNode", "aBlock"],
  453. 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 ]",
  454. messageSends: ["continue:value:", "interpret:", "first", "nodes", "result"],
  455. referencedClasses: []
  456. }),
  457. smalltalk.ASTInterpreter);
  458. smalltalk.addMethod(
  459. "_interpretBlockSequenceNode_continue_",
  460. smalltalk.method({
  461. selector: "interpretBlockSequenceNode:continue:",
  462. category: 'interpreting',
  463. fn: function (aNode,aBlock){
  464. var self=this;
  465. return smalltalk.withContext(function($ctx1) { _st(self)._interpretSequenceNode_continue_(aNode,aBlock);
  466. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockSequenceNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  467. args: ["aNode", "aBlock"],
  468. source: "interpretBlockSequenceNode: aNode continue: aBlock\x0a\x09self interpretSequenceNode: aNode continue: aBlock",
  469. messageSends: ["interpretSequenceNode:continue:"],
  470. referencedClasses: []
  471. }),
  472. smalltalk.ASTInterpreter);
  473. smalltalk.addMethod(
  474. "_interpretCascadeNode_continue_",
  475. smalltalk.method({
  476. selector: "interpretCascadeNode:continue:",
  477. category: 'interpreting',
  478. fn: function (aNode,aBlock){
  479. var self=this;
  480. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  481. return smalltalk.withContext(function($ctx2) { _st(_st(aNode)._nodes())._do_((function(each){
  482. return smalltalk.withContext(function($ctx3) { return _st(each)._receiver_(receiver);
  483. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  484. return _st(self)._interpretAll_continue_(_st(_st(aNode)._nodes())._allButLast(),(function(){
  485. return smalltalk.withContext(function($ctx3) { return _st(self)._interpret_continue_(_st(_st(aNode)._nodes())._last(),(function(val){
  486. return smalltalk.withContext(function($ctx4) { return _st(self)._continue_value_(aBlock,val);
  487. }, function($ctx4) {$ctx4.fillBlock({val:val},$ctx1)})}));
  488. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  489. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  490. return self}, function($ctx1) {$ctx1.fill(self,"interpretCascadeNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  491. args: ["aNode", "aBlock"],
  492. 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 ] ] ]",
  493. messageSends: ["interpret:continue:", "receiver", "do:", "receiver:", "nodes", "interpretAll:continue:", "allButLast", "last", "continue:value:"],
  494. referencedClasses: []
  495. }),
  496. smalltalk.ASTInterpreter);
  497. smalltalk.addMethod(
  498. "_interpretClassReferenceNode_continue_",
  499. smalltalk.method({
  500. selector: "interpretClassReferenceNode:continue:",
  501. category: 'interpreting',
  502. fn: function (aNode,aBlock){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx1) { _st(self)._continue_value_(aBlock,_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(_st(aNode)._value()));
  505. return self}, function($ctx1) {$ctx1.fill(self,"interpretClassReferenceNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  506. args: ["aNode", "aBlock"],
  507. source: "interpretClassReferenceNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: (Smalltalk current at: aNode value)",
  508. messageSends: ["continue:value:", "at:", "value", "current"],
  509. referencedClasses: ["Smalltalk"]
  510. }),
  511. smalltalk.ASTInterpreter);
  512. smalltalk.addMethod(
  513. "_interpretDynamicArrayNode_continue_",
  514. smalltalk.method({
  515. selector: "interpretDynamicArrayNode:continue:",
  516. category: 'interpreting',
  517. fn: function (aNode,aBlock){
  518. var self=this;
  519. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  520. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,array);
  521. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  522. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicArrayNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  523. args: ["aNode", "aBlock"],
  524. source: "interpretDynamicArrayNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a \x09self \x0a \x09continue: aBlock\x0a\x09\x09\x09value: array ]",
  525. messageSends: ["interpretAll:continue:", "nodes", "continue:value:"],
  526. referencedClasses: []
  527. }),
  528. smalltalk.ASTInterpreter);
  529. smalltalk.addMethod(
  530. "_interpretDynamicDictionaryNode_continue_",
  531. smalltalk.method({
  532. selector: "interpretDynamicDictionaryNode:continue:",
  533. category: 'interpreting',
  534. fn: function (aNode,aBlock){
  535. var self=this;
  536. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  537. var hashedCollection;
  538. return smalltalk.withContext(function($ctx2) { hashedCollection=_st((smalltalk.HashedCollection || HashedCollection))._new();
  539. hashedCollection;
  540. _st(array)._do_((function(each){
  541. return smalltalk.withContext(function($ctx3) { return _st(hashedCollection)._add_(each);
  542. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  543. return _st(self)._continue_value_(aBlock,hashedCollection);
  544. }, function($ctx2) {$ctx2.fillBlock({array:array,hashedCollection:hashedCollection},$ctx1)})}));
  545. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicDictionaryNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  546. args: ["aNode", "aBlock"],
  547. 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 ]",
  548. messageSends: ["interpretAll:continue:", "nodes", "new", "do:", "add:", "continue:value:"],
  549. referencedClasses: ["HashedCollection"]
  550. }),
  551. smalltalk.ASTInterpreter);
  552. smalltalk.addMethod(
  553. "_interpretJSStatementNode_continue_",
  554. smalltalk.method({
  555. selector: "interpretJSStatementNode:continue:",
  556. category: 'interpreting',
  557. fn: function (aNode,aBlock){
  558. var self=this;
  559. return smalltalk.withContext(function($ctx1) { self["@shouldReturn"]=true;
  560. _st(self)._continue_value_(aBlock,_st(self)._eval_(_st(aNode)._source()));
  561. return self}, function($ctx1) {$ctx1.fill(self,"interpretJSStatementNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  562. args: ["aNode", "aBlock"],
  563. source: "interpretJSStatementNode: aNode continue: aBlock\x0a\x09shouldReturn := true.\x0a\x09self continue: aBlock value: (self eval: aNode source)",
  564. messageSends: ["continue:value:", "eval:", "source"],
  565. referencedClasses: []
  566. }),
  567. smalltalk.ASTInterpreter);
  568. smalltalk.addMethod(
  569. "_interpretMethodNode_continue_",
  570. smalltalk.method({
  571. selector: "interpretMethodNode:continue:",
  572. category: 'interpreting',
  573. fn: function (aNode,aBlock){
  574. var self=this;
  575. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  576. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,_st(array)._first());
  577. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  578. return self}, function($ctx1) {$ctx1.fill(self,"interpretMethodNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  579. args: ["aNode", "aBlock"],
  580. source: "interpretMethodNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a \x09self continue: aBlock value: array first ]",
  581. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "first"],
  582. referencedClasses: []
  583. }),
  584. smalltalk.ASTInterpreter);
  585. smalltalk.addMethod(
  586. "_interpretNode_continue_",
  587. smalltalk.method({
  588. selector: "interpretNode:continue:",
  589. category: 'interpreting',
  590. fn: function (aNode,aBlock){
  591. var self=this;
  592. return smalltalk.withContext(function($ctx1) { _st(aNode)._interpreter_continue_(self,aBlock);
  593. return self}, function($ctx1) {$ctx1.fill(self,"interpretNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  594. args: ["aNode", "aBlock"],
  595. source: "interpretNode: aNode continue: aBlock\x0a aNode interpreter: self continue: aBlock",
  596. messageSends: ["interpreter:continue:"],
  597. referencedClasses: []
  598. }),
  599. smalltalk.ASTInterpreter);
  600. smalltalk.addMethod(
  601. "_interpretReturnNode_continue_",
  602. smalltalk.method({
  603. selector: "interpretReturnNode:continue:",
  604. category: 'interpreting',
  605. fn: function (aNode,aBlock){
  606. var self=this;
  607. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(_st(aNode)._nodes())._first(),(function(value){
  608. return smalltalk.withContext(function($ctx2) { self["@shouldReturn"]=true;
  609. self["@shouldReturn"];
  610. return _st(self)._continue_value_(aBlock,value);
  611. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  612. return self}, function($ctx1) {$ctx1.fill(self,"interpretReturnNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  613. args: ["aNode", "aBlock"],
  614. source: "interpretReturnNode: aNode continue: aBlock\x0a self interpret: aNode nodes first continue: [ :value |\x0a \x09shouldReturn := true.\x0a\x09\x09self continue: aBlock value: value ]",
  615. messageSends: ["interpret:continue:", "first", "nodes", "continue:value:"],
  616. referencedClasses: []
  617. }),
  618. smalltalk.ASTInterpreter);
  619. smalltalk.addMethod(
  620. "_interpretSendNode_continue_",
  621. smalltalk.method({
  622. selector: "interpretSendNode:continue:",
  623. category: 'interpreting',
  624. fn: function (aNode,aBlock){
  625. var self=this;
  626. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  627. return smalltalk.withContext(function($ctx2) { return _st(self)._interpretAll_continue_(_st(aNode)._arguments(),(function(args){
  628. return smalltalk.withContext(function($ctx3) { return _st(self)._messageFromSendNode_arguments_do_(aNode,args,(function(message){
  629. return smalltalk.withContext(function($ctx4) { _st(_st(self)._context())._pc_(_st(_st(_st(self)._context())._pc()).__plus((1)));
  630. return _st(self)._continue_value_(aBlock,_st(message)._sendTo_(receiver));
  631. }, function($ctx4) {$ctx4.fillBlock({message:message},$ctx1)})}));
  632. }, function($ctx3) {$ctx3.fillBlock({args:args},$ctx1)})}));
  633. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  634. return self}, function($ctx1) {$ctx1.fill(self,"interpretSendNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  635. args: ["aNode", "aBlock"],
  636. 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) ] ] ]",
  637. messageSends: ["interpret:continue:", "receiver", "interpretAll:continue:", "arguments", "messageFromSendNode:arguments:do:", "pc:", "+", "pc", "context", "continue:value:", "sendTo:"],
  638. referencedClasses: []
  639. }),
  640. smalltalk.ASTInterpreter);
  641. smalltalk.addMethod(
  642. "_interpretSequenceNode_continue_",
  643. smalltalk.method({
  644. selector: "interpretSequenceNode:continue:",
  645. category: 'interpreting',
  646. fn: function (aNode,aBlock){
  647. var self=this;
  648. return smalltalk.withContext(function($ctx1) { _st(self)._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  649. return smalltalk.withContext(function($ctx2) { return _st(self)._continue_value_(aBlock,_st(array)._last());
  650. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  651. return self}, function($ctx1) {$ctx1.fill(self,"interpretSequenceNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  652. args: ["aNode", "aBlock"],
  653. source: "interpretSequenceNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a \x09self continue: aBlock value: array last ]",
  654. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "last"],
  655. referencedClasses: []
  656. }),
  657. smalltalk.ASTInterpreter);
  658. smalltalk.addMethod(
  659. "_interpretValueNode_continue_",
  660. smalltalk.method({
  661. selector: "interpretValueNode:continue:",
  662. category: 'interpreting',
  663. fn: function (aNode,aBlock){
  664. var self=this;
  665. return smalltalk.withContext(function($ctx1) { _st(self)._continue_value_(aBlock,_st(aNode)._value());
  666. return self}, function($ctx1) {$ctx1.fill(self,"interpretValueNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  667. args: ["aNode", "aBlock"],
  668. source: "interpretValueNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: aNode value",
  669. messageSends: ["continue:value:", "value"],
  670. referencedClasses: []
  671. }),
  672. smalltalk.ASTInterpreter);
  673. smalltalk.addMethod(
  674. "_interpretVariableNode_continue_",
  675. smalltalk.method({
  676. selector: "interpretVariableNode:continue:",
  677. category: 'interpreting',
  678. fn: function (aNode,aBlock){
  679. var self=this;
  680. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$3;
  681. $1=self;
  682. $2=aBlock;
  683. $4=_st(_st(aNode)._binding())._isInstanceVar();
  684. if(smalltalk.assert($4)){
  685. $3=_st(_st(_st(self)._context())._receiver())._instVarAt_(_st(aNode)._value());
  686. } else {
  687. $3=_st(_st(self)._context())._localAt_(_st(aNode)._value());
  688. };
  689. _st($1)._continue_value_($2,$3);
  690. return self}, function($ctx1) {$ctx1.fill(self,"interpretVariableNode:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  691. args: ["aNode", "aBlock"],
  692. 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 ])",
  693. messageSends: ["continue:value:", "ifTrue:ifFalse:", "instVarAt:", "value", "receiver", "context", "localAt:", "isInstanceVar", "binding"],
  694. referencedClasses: []
  695. }),
  696. smalltalk.ASTInterpreter);
  697. smalltalk.addMethod(
  698. "_messageFromSendNode_arguments_do_",
  699. smalltalk.method({
  700. selector: "messageFromSendNode:arguments:do:",
  701. category: 'private',
  702. fn: function (aSendNode,aCollection,aBlock){
  703. var self=this;
  704. return smalltalk.withContext(function($ctx1) { var $1,$2;
  705. $1=_st((smalltalk.Message || Message))._new();
  706. _st($1)._selector_(_st(aSendNode)._selector());
  707. _st($1)._arguments_(aCollection);
  708. $2=_st($1)._yourself();
  709. _st(self)._continue_value_(aBlock,$2);
  710. return self}, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:do:",{aSendNode:aSendNode,aCollection:aCollection,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
  711. args: ["aSendNode", "aCollection", "aBlock"],
  712. 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)",
  713. messageSends: ["continue:value:", "selector:", "selector", "new", "arguments:", "yourself"],
  714. referencedClasses: ["Message"]
  715. }),
  716. smalltalk.ASTInterpreter);
  717. smalltalk.addMethod(
  718. "_result",
  719. smalltalk.method({
  720. selector: "result",
  721. category: 'accessing',
  722. fn: function (){
  723. var self=this;
  724. return smalltalk.withContext(function($ctx1) { var $1;
  725. $1=self["@result"];
  726. return $1;
  727. }, function($ctx1) {$ctx1.fill(self,"result",{}, smalltalk.ASTInterpreter)})},
  728. args: [],
  729. source: "result\x0a\x09^ result",
  730. messageSends: [],
  731. referencedClasses: []
  732. }),
  733. smalltalk.ASTInterpreter);
  734. smalltalk.addClass('ASTSteppingInterpreter', smalltalk.ASTInterpreter, ['continuation'], 'Compiler-Interpreter');
  735. 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 "
  736. smalltalk.addMethod(
  737. "_initialize",
  738. smalltalk.method({
  739. selector: "initialize",
  740. category: 'initialization',
  741. fn: function (){
  742. var self=this;
  743. return smalltalk.withContext(function($ctx1) { smalltalk.ASTInterpreter.fn.prototype._initialize.apply(_st(self), []);
  744. self["@continuation"]=(function(){
  745. return smalltalk.withContext(function($ctx2) { }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  746. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.ASTDebugger)})},
  747. args: [],
  748. source: "initialize\x0a\x09super initialize.\x0a continuation := [ ]",
  749. messageSends: ["initialize"],
  750. referencedClasses: []
  751. }),
  752. smalltalk.ASTSteppingInterpreter);
  753. smalltalk.addMethod(
  754. "_interpret_continue_",
  755. smalltalk.method({
  756. selector: "interpret:continue:",
  757. category: 'interpreting',
  758. fn: function (aNode,aBlock){
  759. var self=this;
  760. return smalltalk.withContext(function($ctx1) { self["@continuation"]=(function(){
  761. return smalltalk.withContext(function($ctx2) { return smalltalk.ASTInterpreter.fn.prototype._interpret_continue_.apply(_st(self), [aNode,aBlock]);
  762. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  763. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTDebugger)})},
  764. args: ["aNode", "aBlock"],
  765. source: "interpret: aNode continue: aBlock\x0a\x09continuation := [ super interpret: aNode continue: aBlock ]",
  766. messageSends: ["interpret:continue:"],
  767. referencedClasses: []
  768. }),
  769. smalltalk.ASTSteppingInterpreter);
  770. smalltalk.addMethod(
  771. "_step",
  772. smalltalk.method({
  773. selector: "step",
  774. category: 'stepping',
  775. fn: function (){
  776. var self=this;
  777. return smalltalk.withContext(function($ctx1) { _st(self["@continuation"])._value();
  778. return self}, function($ctx1) {$ctx1.fill(self,"step",{}, smalltalk.ASTDebugger)})},
  779. args: [],
  780. source: "step\x0a\x09continuation value",
  781. messageSends: ["value"],
  782. referencedClasses: []
  783. }),
  784. smalltalk.ASTSteppingInterpreter);
  785. smalltalk.addMethod(
  786. "_interpreter_continue_",
  787. smalltalk.method({
  788. selector: "interpreter:continue:",
  789. category: '*Compiler-Interpreter',
  790. fn: function (anInterpreter,aBlock){
  791. var self=this;
  792. return smalltalk.withContext(function($ctx1) { var $1;
  793. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  794. return $1;
  795. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.Node)})},
  796. args: ["anInterpreter", "aBlock"],
  797. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  798. messageSends: ["interpretNode:continue:"],
  799. referencedClasses: []
  800. }),
  801. smalltalk.Node);
  802. smalltalk.addMethod(
  803. "_interpreter_continue_",
  804. smalltalk.method({
  805. selector: "interpreter:continue:",
  806. category: '*Compiler-Interpreter',
  807. fn: function (anInterpreter,aBlock){
  808. var self=this;
  809. return smalltalk.withContext(function($ctx1) { var $1;
  810. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  811. return $1;
  812. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.AssignmentNode)})},
  813. args: ["anInterpreter", "aBlock"],
  814. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  815. messageSends: ["interpretAssignmentNode:continue:"],
  816. referencedClasses: []
  817. }),
  818. smalltalk.AssignmentNode);
  819. smalltalk.addMethod(
  820. "_interpreter_continue_",
  821. smalltalk.method({
  822. selector: "interpreter:continue:",
  823. category: '*Compiler-Interpreter',
  824. fn: function (anInterpreter,aBlock){
  825. var self=this;
  826. return smalltalk.withContext(function($ctx1) { var $1;
  827. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  828. return $1;
  829. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.BlockNode)})},
  830. args: ["anInterpreter", "aBlock"],
  831. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  832. messageSends: ["interpretBlockNode:continue:"],
  833. referencedClasses: []
  834. }),
  835. smalltalk.BlockNode);
  836. smalltalk.addMethod(
  837. "_interpreter_continue_",
  838. smalltalk.method({
  839. selector: "interpreter:continue:",
  840. category: '*Compiler-Interpreter',
  841. fn: function (anInterpreter,aBlock){
  842. var self=this;
  843. return smalltalk.withContext(function($ctx1) { var $1;
  844. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  845. return $1;
  846. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.CascadeNode)})},
  847. args: ["anInterpreter", "aBlock"],
  848. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  849. messageSends: ["interpretCascadeNode:continue:"],
  850. referencedClasses: []
  851. }),
  852. smalltalk.CascadeNode);
  853. smalltalk.addMethod(
  854. "_interpreter_continue_",
  855. smalltalk.method({
  856. selector: "interpreter:continue:",
  857. category: '*Compiler-Interpreter',
  858. fn: function (anInterpreter,aBlock){
  859. var self=this;
  860. return smalltalk.withContext(function($ctx1) { var $1;
  861. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  862. return $1;
  863. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.DynamicArrayNode)})},
  864. args: ["anInterpreter", "aBlock"],
  865. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  866. messageSends: ["interpretDynamicArrayNode:continue:"],
  867. referencedClasses: []
  868. }),
  869. smalltalk.DynamicArrayNode);
  870. smalltalk.addMethod(
  871. "_interpreter_continue_",
  872. smalltalk.method({
  873. selector: "interpreter:continue:",
  874. category: '*Compiler-Interpreter',
  875. fn: function (anInterpreter,aBlock){
  876. var self=this;
  877. return smalltalk.withContext(function($ctx1) { var $1;
  878. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  879. return $1;
  880. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.DynamicDictionaryNode)})},
  881. args: ["anInterpreter", "aBlock"],
  882. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  883. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  884. referencedClasses: []
  885. }),
  886. smalltalk.DynamicDictionaryNode);
  887. smalltalk.addMethod(
  888. "_interpreter_continue_",
  889. smalltalk.method({
  890. selector: "interpreter:continue:",
  891. category: '*Compiler-Interpreter',
  892. fn: function (anInterpreter,aBlock){
  893. var self=this;
  894. return smalltalk.withContext(function($ctx1) { var $1;
  895. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  896. return $1;
  897. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.JSStatementNode)})},
  898. args: ["anInterpreter", "aBlock"],
  899. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  900. messageSends: ["interpretJSStatementNode:continue:"],
  901. referencedClasses: []
  902. }),
  903. smalltalk.JSStatementNode);
  904. smalltalk.addMethod(
  905. "_interpreter_continue_",
  906. smalltalk.method({
  907. selector: "interpreter:continue:",
  908. category: '*Compiler-Interpreter',
  909. fn: function (anInterpreter,aBlock){
  910. var self=this;
  911. return smalltalk.withContext(function($ctx1) { var $1;
  912. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  913. return $1;
  914. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.MethodNode)})},
  915. args: ["anInterpreter", "aBlock"],
  916. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  917. messageSends: ["interpretMethodNode:continue:"],
  918. referencedClasses: []
  919. }),
  920. smalltalk.MethodNode);
  921. smalltalk.addMethod(
  922. "_interpreter_continue_",
  923. smalltalk.method({
  924. selector: "interpreter:continue:",
  925. category: '*Compiler-Interpreter',
  926. fn: function (anInterpreter,aBlock){
  927. var self=this;
  928. return smalltalk.withContext(function($ctx1) { var $1;
  929. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  930. return $1;
  931. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.ReturnNode)})},
  932. args: ["anInterpreter", "aBlock"],
  933. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  934. messageSends: ["interpretReturnNode:continue:"],
  935. referencedClasses: []
  936. }),
  937. smalltalk.ReturnNode);
  938. smalltalk.addMethod(
  939. "_interpreter_continue_",
  940. smalltalk.method({
  941. selector: "interpreter:continue:",
  942. category: '*Compiler-Interpreter',
  943. fn: function (anInterpreter,aBlock){
  944. var self=this;
  945. return smalltalk.withContext(function($ctx1) { var $1;
  946. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  947. return $1;
  948. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.SendNode)})},
  949. args: ["anInterpreter", "aBlock"],
  950. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  951. messageSends: ["interpretSendNode:continue:"],
  952. referencedClasses: []
  953. }),
  954. smalltalk.SendNode);
  955. smalltalk.addMethod(
  956. "_interpreter_continue_",
  957. smalltalk.method({
  958. selector: "interpreter:continue:",
  959. category: '*Compiler-Interpreter',
  960. fn: function (anInterpreter,aBlock){
  961. var self=this;
  962. return smalltalk.withContext(function($ctx1) { var $1;
  963. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  964. return $1;
  965. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.SequenceNode)})},
  966. args: ["anInterpreter", "aBlock"],
  967. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  968. messageSends: ["interpretSequenceNode:continue:"],
  969. referencedClasses: []
  970. }),
  971. smalltalk.SequenceNode);
  972. smalltalk.addMethod(
  973. "_interpreter_continue_",
  974. smalltalk.method({
  975. selector: "interpreter:continue:",
  976. category: '*Compiler-Interpreter',
  977. fn: function (anInterpreter,aBlock){
  978. var self=this;
  979. return smalltalk.withContext(function($ctx1) { var $1;
  980. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  981. return $1;
  982. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.BlockSequenceNode)})},
  983. args: ["anInterpreter", "aBlock"],
  984. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  985. messageSends: ["interpretBlockSequenceNode:continue:"],
  986. referencedClasses: []
  987. }),
  988. smalltalk.BlockSequenceNode);
  989. smalltalk.addMethod(
  990. "_interpreter_continue_",
  991. smalltalk.method({
  992. selector: "interpreter:continue:",
  993. category: '*Compiler-Interpreter',
  994. fn: function (anInterpreter,aBlock){
  995. var self=this;
  996. return smalltalk.withContext(function($ctx1) { var $1;
  997. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  998. return $1;
  999. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.ValueNode)})},
  1000. args: ["anInterpreter", "aBlock"],
  1001. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  1002. messageSends: ["interpretValueNode:continue:"],
  1003. referencedClasses: []
  1004. }),
  1005. smalltalk.ValueNode);
  1006. smalltalk.addMethod(
  1007. "_interpreter_continue_",
  1008. smalltalk.method({
  1009. selector: "interpreter:continue:",
  1010. category: '*Compiler-Interpreter',
  1011. fn: function (anInterpreter,aBlock){
  1012. var self=this;
  1013. return smalltalk.withContext(function($ctx1) { var $1;
  1014. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  1015. return $1;
  1016. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.VariableNode)})},
  1017. args: ["anInterpreter", "aBlock"],
  1018. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  1019. messageSends: ["interpretVariableNode:continue:"],
  1020. referencedClasses: []
  1021. }),
  1022. smalltalk.VariableNode);
  1023. smalltalk.addMethod(
  1024. "_interpreter_continue_",
  1025. smalltalk.method({
  1026. selector: "interpreter:continue:",
  1027. category: '*Compiler-Interpreter',
  1028. fn: function (anInterpreter,aBlock){
  1029. var self=this;
  1030. return smalltalk.withContext(function($ctx1) { var $1;
  1031. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  1032. return $1;
  1033. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock}, smalltalk.ClassReferenceNode)})},
  1034. args: ["anInterpreter", "aBlock"],
  1035. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  1036. messageSends: ["interpretClassReferenceNode:continue:"],
  1037. referencedClasses: []
  1038. }),
  1039. smalltalk.ClassReferenceNode);