Compiler-Interpreter.js 66 KB

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