Compiler-Interpreter.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. smalltalk.addPackage('Compiler-Interpreter', {});
  2. smalltalk.addClass('AIContext', smalltalk.NodeVisitor, ['outerContext', 'pc', 'locals', 'receiver', 'selector'], 'Compiler-Interpreter');
  3. smalltalk.addMethod(
  4. "_initializeFromMethodContext_",
  5. smalltalk.method({
  6. selector: "initializeFromMethodContext:",
  7. category: 'accessing',
  8. fn: function (aMethodContext){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) { var $1;
  11. _st(self)._pc_(_st(aMethodContext)._pc());
  12. _st(self)._receiver_(_st(aMethodContext)._receiver());
  13. _st(self)._selector_(_st(aMethodContext)._selector());
  14. $1=_st(aMethodContext)._outerContext();
  15. if(($receiver = $1) == nil || $receiver == undefined){
  16. $1;
  17. } else {
  18. _st(self)._outerContext_(_st(_st(self)._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
  19. };
  20. _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
  21. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._locals())._at_put_(key,value);
  22. }, function($ctx2) {$ctx2.fillBlock([key,value], {})})}));
  23. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:", [aMethodContext], {}, smalltalk.AIContext)})},
  24. args: ["aMethodContext"],
  25. 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 ",
  26. messageSends: ["pc:", "pc", "receiver:", "receiver", "selector:", "selector", "ifNotNil:", "outerContext:", "fromMethodContext:", "outerContext", "class", "keysAndValuesDo:", "at:put:", "locals"],
  27. referencedClasses: []
  28. }),
  29. smalltalk.AIContext);
  30. smalltalk.addMethod(
  31. "_localAt_put_",
  32. smalltalk.method({
  33. selector: "localAt:put:",
  34. category: 'accessing',
  35. fn: function (aString,anObject){
  36. var self=this;
  37. return smalltalk.withContext(function($ctx1) { _st(_st(self)._locals())._at_put_(aString,anObject);
  38. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:", [aString,anObject], {}, smalltalk.AIContext)})},
  39. args: ["aString", "anObject"],
  40. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  41. messageSends: ["at:put:", "locals"],
  42. referencedClasses: []
  43. }),
  44. smalltalk.AIContext);
  45. smalltalk.addMethod(
  46. "_locals",
  47. smalltalk.method({
  48. selector: "locals",
  49. category: 'accessing',
  50. fn: function (){
  51. var self=this;
  52. return smalltalk.withContext(function($ctx1) { var $2,$1;
  53. $2=self["@locals"];
  54. if(($receiver = $2) == nil || $receiver == undefined){
  55. self["@locals"]=_st((smalltalk.Dictionary || Dictionary))._new();
  56. $1=self["@locals"];
  57. } else {
  58. $1=$2;
  59. };
  60. return $1;
  61. }, function($ctx1) {$ctx1.fill(self,"locals", [], {}, smalltalk.AIContext)})},
  62. args: [],
  63. source: "locals\x0a\x09^ locals ifNil: [ locals := Dictionary new ]",
  64. messageSends: ["ifNil:", "new"],
  65. referencedClasses: ["Dictionary"]
  66. }),
  67. smalltalk.AIContext);
  68. smalltalk.addMethod(
  69. "_outerContext",
  70. smalltalk.method({
  71. selector: "outerContext",
  72. category: 'accessing',
  73. fn: function (){
  74. var self=this;
  75. return smalltalk.withContext(function($ctx1) { var $1;
  76. $1=self["@outerContext"];
  77. return $1;
  78. }, function($ctx1) {$ctx1.fill(self,"outerContext", [], {}, smalltalk.AIContext)})},
  79. args: [],
  80. source: "outerContext\x0a\x09^ outerContext",
  81. messageSends: [],
  82. referencedClasses: []
  83. }),
  84. smalltalk.AIContext);
  85. smalltalk.addMethod(
  86. "_outerContext_",
  87. smalltalk.method({
  88. selector: "outerContext:",
  89. category: 'accessing',
  90. fn: function (anAIContext){
  91. var self=this;
  92. return smalltalk.withContext(function($ctx1) { self["@outerContext"]=anAIContext;
  93. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:", [anAIContext], {}, smalltalk.AIContext)})},
  94. args: ["anAIContext"],
  95. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext",
  96. messageSends: [],
  97. referencedClasses: []
  98. }),
  99. smalltalk.AIContext);
  100. smalltalk.addMethod(
  101. "_pc",
  102. smalltalk.method({
  103. selector: "pc",
  104. category: 'accessing',
  105. fn: function (){
  106. var self=this;
  107. return smalltalk.withContext(function($ctx1) { var $2,$1;
  108. $2=self["@pc"];
  109. if(($receiver = $2) == nil || $receiver == undefined){
  110. self["@pc"]=(0);
  111. $1=self["@pc"];
  112. } else {
  113. $1=$2;
  114. };
  115. return $1;
  116. }, function($ctx1) {$ctx1.fill(self,"pc", [], {}, smalltalk.AIContext)})},
  117. args: [],
  118. source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
  119. messageSends: ["ifNil:"],
  120. referencedClasses: []
  121. }),
  122. smalltalk.AIContext);
  123. smalltalk.addMethod(
  124. "_pc_",
  125. smalltalk.method({
  126. selector: "pc:",
  127. category: 'accessing',
  128. fn: function (anInteger){
  129. var self=this;
  130. return smalltalk.withContext(function($ctx1) { self["@pc"]=anInteger;
  131. return self}, function($ctx1) {$ctx1.fill(self,"pc:", [anInteger], {}, smalltalk.AIContext)})},
  132. args: ["anInteger"],
  133. source: "pc: anInteger\x0a\x09pc := anInteger",
  134. messageSends: [],
  135. referencedClasses: []
  136. }),
  137. smalltalk.AIContext);
  138. smalltalk.addMethod(
  139. "_receiver",
  140. smalltalk.method({
  141. selector: "receiver",
  142. category: 'accessing',
  143. fn: function (){
  144. var self=this;
  145. return smalltalk.withContext(function($ctx1) { var $1;
  146. $1=self["@receiver"];
  147. return $1;
  148. }, function($ctx1) {$ctx1.fill(self,"receiver", [], {}, smalltalk.AIContext)})},
  149. args: [],
  150. source: "receiver\x0a\x09^ receiver",
  151. messageSends: [],
  152. referencedClasses: []
  153. }),
  154. smalltalk.AIContext);
  155. smalltalk.addMethod(
  156. "_receiver_",
  157. smalltalk.method({
  158. selector: "receiver:",
  159. category: 'accessing',
  160. fn: function (anObject){
  161. var self=this;
  162. return smalltalk.withContext(function($ctx1) { self["@receiver"]=anObject;
  163. return self}, function($ctx1) {$ctx1.fill(self,"receiver:", [anObject], {}, smalltalk.AIContext)})},
  164. args: ["anObject"],
  165. source: "receiver: anObject\x0a\x09receiver := anObject",
  166. messageSends: [],
  167. referencedClasses: []
  168. }),
  169. smalltalk.AIContext);
  170. smalltalk.addMethod(
  171. "_selector",
  172. smalltalk.method({
  173. selector: "selector",
  174. category: 'accessing',
  175. fn: function (){
  176. var self=this;
  177. return smalltalk.withContext(function($ctx1) { var $1;
  178. $1=self["@selector"];
  179. return $1;
  180. }, function($ctx1) {$ctx1.fill(self,"selector", [], {}, smalltalk.AIContext)})},
  181. args: [],
  182. source: "selector\x0a\x09^ selector",
  183. messageSends: [],
  184. referencedClasses: []
  185. }),
  186. smalltalk.AIContext);
  187. smalltalk.addMethod(
  188. "_selector_",
  189. smalltalk.method({
  190. selector: "selector:",
  191. category: 'accessing',
  192. fn: function (aString){
  193. var self=this;
  194. return smalltalk.withContext(function($ctx1) { self["@selector"]=aString;
  195. return self}, function($ctx1) {$ctx1.fill(self,"selector:", [aString], {}, smalltalk.AIContext)})},
  196. args: ["aString"],
  197. source: "selector: aString\x0a\x09selector := aString",
  198. messageSends: [],
  199. referencedClasses: []
  200. }),
  201. smalltalk.AIContext);
  202. smalltalk.addMethod(
  203. "_fromMethodContext_",
  204. smalltalk.method({
  205. selector: "fromMethodContext:",
  206. category: 'instance creation',
  207. fn: function (aMethodContext){
  208. var self=this;
  209. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  210. $2=_st(self)._new();
  211. _st($2)._initializeFromMethodContext_(aMethodContext);
  212. $3=_st($2)._yourself();
  213. $1=$3;
  214. return $1;
  215. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:", [aMethodContext], {}, smalltalk.AIContext.klass)})},
  216. args: ["aMethodContext"],
  217. source: "fromMethodContext: aMethodContext\x0a\x09^ self new \x0a \x09initializeFromMethodContext: aMethodContext;\x0a yourself",
  218. messageSends: ["initializeFromMethodContext:", "new", "yourself"],
  219. referencedClasses: []
  220. }),
  221. smalltalk.AIContext.klass);
  222. smalltalk.addClass('ASTInterpreter', smalltalk.NodeVisitor, ['currentNode', 'context', 'shouldReturn'], 'Compiler-Interpreter');
  223. smalltalk.addMethod(
  224. "_context",
  225. smalltalk.method({
  226. selector: "context",
  227. category: 'accessing',
  228. fn: function (){
  229. var self=this;
  230. return smalltalk.withContext(function($ctx1) { var $2,$1;
  231. $2=self["@context"];
  232. if(($receiver = $2) == nil || $receiver == undefined){
  233. self["@context"]=_st((smalltalk.AIContext || AIContext))._new();
  234. $1=self["@context"];
  235. } else {
  236. $1=$2;
  237. };
  238. return $1;
  239. }, function($ctx1) {$ctx1.fill(self,"context", [], {}, smalltalk.ASTInterpreter)})},
  240. args: [],
  241. source: "context\x0a\x09^ context ifNil: [ context := AIContext new ]",
  242. messageSends: ["ifNil:", "new"],
  243. referencedClasses: ["AIContext"]
  244. }),
  245. smalltalk.ASTInterpreter);
  246. smalltalk.addMethod(
  247. "_context_",
  248. smalltalk.method({
  249. selector: "context:",
  250. category: 'accessing',
  251. fn: function (anAIContext){
  252. var self=this;
  253. return smalltalk.withContext(function($ctx1) { self["@context"]=anAIContext;
  254. return self}, function($ctx1) {$ctx1.fill(self,"context:", [anAIContext], {}, smalltalk.ASTInterpreter)})},
  255. args: ["anAIContext"],
  256. source: "context: anAIContext\x0a\x09context := anAIContext",
  257. messageSends: [],
  258. referencedClasses: []
  259. }),
  260. smalltalk.ASTInterpreter);
  261. smalltalk.addMethod(
  262. "_eval_",
  263. smalltalk.method({
  264. selector: "eval:",
  265. category: 'interpreting',
  266. fn: function (aString){
  267. var self=this;
  268. return smalltalk.withContext(function($ctx1) { var $1;
  269. $1=_st(_st((smalltalk.Compiler || Compiler))._new())._eval_(_st(_st("(function() { ").__comma(aString)).__comma(" })()"));
  270. return $1;
  271. }, function($ctx1) {$ctx1.fill(self,"eval:", [aString], {}, smalltalk.ASTInterpreter)})},
  272. args: ["aString"],
  273. source: "eval: aString\x0a\x09\x22Evaluate aString as JS source inside an immediately evaluated JS function. \x0a aString is not sandboxed.\x22\x0a \x0a ^ Compiler new eval: '(function() { ', aString, ' })()'",
  274. messageSends: ["eval:", ",", "new"],
  275. referencedClasses: ["Compiler"]
  276. }),
  277. smalltalk.ASTInterpreter);
  278. smalltalk.addMethod(
  279. "_initialize",
  280. smalltalk.method({
  281. selector: "initialize",
  282. category: 'initialization',
  283. fn: function (){
  284. var self=this;
  285. return smalltalk.withContext(function($ctx1) { smalltalk.NodeVisitor.fn.prototype._initialize.apply(_st(self), []);
  286. self["@shouldReturn"]=false;
  287. return self}, function($ctx1) {$ctx1.fill(self,"initialize", [], {}, smalltalk.ASTInterpreter)})},
  288. args: [],
  289. source: "initialize\x0a\x09super initialize.\x0a shouldReturn := false",
  290. messageSends: ["initialize"],
  291. referencedClasses: []
  292. }),
  293. smalltalk.ASTInterpreter);
  294. smalltalk.addMethod(
  295. "_interpret_",
  296. smalltalk.method({
  297. selector: "interpret:",
  298. category: 'interpreting',
  299. fn: function (aNode){
  300. var self=this;
  301. return smalltalk.withContext(function($ctx1) { var $1;
  302. self["@shouldReturn"]=false;
  303. $1=_st(self)._interpretNode_(aNode);
  304. return $1;
  305. }, function($ctx1) {$ctx1.fill(self,"interpret:", [aNode], {}, smalltalk.ASTInterpreter)})},
  306. args: ["aNode"],
  307. source: "interpret: aNode\x0a\x09shouldReturn := false.\x0a ^ self interpretNode: aNode",
  308. messageSends: ["interpretNode:"],
  309. referencedClasses: []
  310. }),
  311. smalltalk.ASTInterpreter);
  312. smalltalk.addMethod(
  313. "_interpretNode_",
  314. smalltalk.method({
  315. selector: "interpretNode:",
  316. category: 'interpreting',
  317. fn: function (aNode){
  318. var self=this;
  319. return smalltalk.withContext(function($ctx1) { var $1;
  320. self["@currentNode"]=aNode;
  321. $1=_st(self)._visit_(aNode);
  322. return $1;
  323. }, function($ctx1) {$ctx1.fill(self,"interpretNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  324. args: ["aNode"],
  325. source: "interpretNode: aNode\x0a\x09currentNode := aNode.\x0a ^ self visit: aNode",
  326. messageSends: ["visit:"],
  327. referencedClasses: []
  328. }),
  329. smalltalk.ASTInterpreter);
  330. smalltalk.addMethod(
  331. "_messageFromSendNode_",
  332. smalltalk.method({
  333. selector: "messageFromSendNode:",
  334. category: 'interpreting',
  335. fn: function (aSendNode){
  336. var self=this;
  337. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  338. $2=_st((smalltalk.Message || Message))._new();
  339. _st($2)._selector_(_st(aSendNode)._selector());
  340. _st($2)._arguments_(_st(_st(aSendNode)._arguments())._collect_((function(each){
  341. return smalltalk.withContext(function($ctx2) { return _st(self)._interpretNode_(each);
  342. }, function($ctx2) {$ctx2.fillBlock([each], {})})})));
  343. $3=_st($2)._yourself();
  344. $1=$3;
  345. return $1;
  346. }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:", [aSendNode], {}, smalltalk.ASTInterpreter)})},
  347. args: ["aSendNode"],
  348. source: "messageFromSendNode: aSendNode\x0a\x09^ Message new\x0a \x09selector: aSendNode selector;\x0a arguments: (aSendNode arguments collect: [ :each |\x0a \x09self interpretNode: each ]);\x0a yourself",
  349. messageSends: ["selector:", "selector", "new", "arguments:", "collect:", "interpretNode:", "arguments", "yourself"],
  350. referencedClasses: ["Message"]
  351. }),
  352. smalltalk.ASTInterpreter);
  353. smalltalk.addMethod(
  354. "_visitBlockNode_",
  355. smalltalk.method({
  356. selector: "visitBlockNode:",
  357. category: 'visiting',
  358. fn: function (aNode){
  359. var self=this;
  360. return smalltalk.withContext(function($ctx1) { var $1;
  361. $1=(function(){
  362. return smalltalk.withContext(function($ctx2) { return _st(self)._interpretNode_(_st(_st(aNode)._nodes())._first());
  363. }, function($ctx2) {$ctx2.fillBlock([], {})})});
  364. return $1;
  365. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  366. args: ["aNode"],
  367. source: "visitBlockNode: aNode\x0a ^ [ self interpretNode: aNode nodes first ]",
  368. messageSends: ["interpretNode:", "first", "nodes"],
  369. referencedClasses: []
  370. }),
  371. smalltalk.ASTInterpreter);
  372. smalltalk.addMethod(
  373. "_visitCascadeNode_",
  374. smalltalk.method({
  375. selector: "visitCascadeNode:",
  376. category: 'visiting',
  377. fn: function (aNode){
  378. var self=this;
  379. var receiver;
  380. return smalltalk.withContext(function($ctx1) { var $1;
  381. receiver=_st(self)._interpretNode_(_st(aNode)._receiver());
  382. _st(_st(_st(aNode)._nodes())._allButLast())._do_((function(each){
  383. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._messageFromSendNode_(each))._sendTo_(receiver);
  384. }, function($ctx2) {$ctx2.fillBlock([each], {})})}));
  385. $1=_st(_st(self)._messageFromSendNode_(_st(_st(aNode)._nodes())._last()))._sendTo_(receiver);
  386. return $1;
  387. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:", [aNode], {receiver:receiver}, smalltalk.ASTInterpreter)})},
  388. args: ["aNode"],
  389. source: "visitCascadeNode: aNode\x0a\x09\x22TODO: Handle super sends\x22\x0a\x09| receiver |\x0a \x0a receiver := self interpretNode: aNode receiver.\x0a\x0a aNode nodes allButLast\x0a \x09do: [ :each | \x0a \x09(self messageFromSendNode: each)\x0a \x09sendTo: receiver ].\x0a\x0a ^ (self messageFromSendNode: aNode nodes last)\x0a \x09sendTo: receiver",
  390. messageSends: ["interpretNode:", "receiver", "do:", "sendTo:", "messageFromSendNode:", "allButLast", "nodes", "last"],
  391. referencedClasses: []
  392. }),
  393. smalltalk.ASTInterpreter);
  394. smalltalk.addMethod(
  395. "_visitClassReferenceNode_",
  396. smalltalk.method({
  397. selector: "visitClassReferenceNode:",
  398. category: 'visiting',
  399. fn: function (aNode){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) { var $1;
  402. $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(_st(aNode)._value());
  403. return $1;
  404. }, function($ctx1) {$ctx1.fill(self,"visitClassReferenceNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  405. args: ["aNode"],
  406. source: "visitClassReferenceNode: aNode\x0a\x09^ Smalltalk current at: aNode value",
  407. messageSends: ["at:", "value", "current"],
  408. referencedClasses: ["Smalltalk"]
  409. }),
  410. smalltalk.ASTInterpreter);
  411. smalltalk.addMethod(
  412. "_visitJSStatementNode_",
  413. smalltalk.method({
  414. selector: "visitJSStatementNode:",
  415. category: 'visiting',
  416. fn: function (aNode){
  417. var self=this;
  418. return smalltalk.withContext(function($ctx1) { var $1;
  419. self["@shouldReturn"]=true;
  420. $1=_st(self)._eval_(_st(aNode)._source());
  421. return $1;
  422. }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  423. args: ["aNode"],
  424. source: "visitJSStatementNode: aNode\x0a\x09shouldReturn := true.\x0a\x09^ self eval: aNode source",
  425. messageSends: ["eval:", "source"],
  426. referencedClasses: []
  427. }),
  428. smalltalk.ASTInterpreter);
  429. smalltalk.addMethod(
  430. "_visitReturnNode_",
  431. smalltalk.method({
  432. selector: "visitReturnNode:",
  433. category: 'visiting',
  434. fn: function (aNode){
  435. var self=this;
  436. return smalltalk.withContext(function($ctx1) { var $1;
  437. self["@shouldReturn"]=true;
  438. $1=_st(self)._interpretNode_(_st(_st(aNode)._nodes())._first());
  439. return $1;
  440. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  441. args: ["aNode"],
  442. source: "visitReturnNode: aNode\x0a\x09shouldReturn := true.\x0a ^ self interpretNode: aNode nodes first",
  443. messageSends: ["interpretNode:", "first", "nodes"],
  444. referencedClasses: []
  445. }),
  446. smalltalk.ASTInterpreter);
  447. smalltalk.addMethod(
  448. "_visitSendNode_",
  449. smalltalk.method({
  450. selector: "visitSendNode:",
  451. category: 'visiting',
  452. fn: function (aNode){
  453. var self=this;
  454. return smalltalk.withContext(function($ctx1) { var $1;
  455. $1=_st(_st(self)._messageFromSendNode_(aNode))._sendTo_(_st(self)._interpretNode_(_st(aNode)._receiver()));
  456. return $1;
  457. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  458. args: ["aNode"],
  459. source: "visitSendNode: aNode\x0a\x09\x22TODO: Handle super sends\x22\x0a \x0a ^ (self messageFromSendNode: aNode)\x0a \x09sendTo: (self interpretNode: aNode receiver)",
  460. messageSends: ["sendTo:", "interpretNode:", "receiver", "messageFromSendNode:"],
  461. referencedClasses: []
  462. }),
  463. smalltalk.ASTInterpreter);
  464. smalltalk.addMethod(
  465. "_visitSequenceNode_",
  466. smalltalk.method({
  467. selector: "visitSequenceNode:",
  468. category: 'visiting',
  469. fn: function (aNode){
  470. var self=this;
  471. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$2,$5;
  472. var $early={};
  473. try {
  474. $1=_st(_st(aNode)._nodes())._allButLast();
  475. $2=(function(each){
  476. var value;
  477. return smalltalk.withContext(function($ctx2) { value=_st(self)._interpretNode_(each);
  478. value;
  479. $3=self["@shouldReturn"];
  480. if(smalltalk.assert($3)){
  481. $4=value;
  482. throw $early=[$4];
  483. };
  484. }, function($ctx2) {$ctx2.fillBlock([each], {value:value})})});
  485. _st($1)._do_($2);
  486. $5=_st(self)._interpretNode_(_st(_st(aNode)._nodes())._last());
  487. return $5;
  488. }
  489. catch(e) {if(e===$early)return e[0]; throw e}
  490. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  491. args: ["aNode"],
  492. source: "visitSequenceNode: aNode\x0a\x0a\x09aNode nodes allButLast do: [ :each | | value |\x0a value := self interpretNode: each.\x0a\x09\x09shouldReturn ifTrue: [ ^ value ] ].\x0a \x0a ^ self interpretNode: aNode nodes last",
  493. messageSends: ["do:", "interpretNode:", "ifTrue:", "allButLast", "nodes", "last"],
  494. referencedClasses: []
  495. }),
  496. smalltalk.ASTInterpreter);
  497. smalltalk.addMethod(
  498. "_visitValueNode_",
  499. smalltalk.method({
  500. selector: "visitValueNode:",
  501. category: 'visiting',
  502. fn: function (aNode){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx1) { var $1;
  505. $1=_st(aNode)._value();
  506. return $1;
  507. }, function($ctx1) {$ctx1.fill(self,"visitValueNode:", [aNode], {}, smalltalk.ASTInterpreter)})},
  508. args: ["aNode"],
  509. source: "visitValueNode: aNode\x0a\x09^ aNode value",
  510. messageSends: ["value"],
  511. referencedClasses: []
  512. }),
  513. smalltalk.ASTInterpreter);