Compiler-Interpreter.js 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078
  1. smalltalk.addPackage('Compiler-Interpreter');
  2. smalltalk.addClass('AIContext', smalltalk.NodeVisitor, ['outerContext', 'innerContext', 'pc', 'locals', 'method', 'ast', 'interpreter', 'methodContext'], 'Compiler-Interpreter');
  3. smalltalk.AIContext.comment="I am like a `MethodContext`, used by the `ASTInterpreter`.\x0aUnlike a `MethodContext`, my instances are not read-only.\x0a\x0aWhen debugging, my instances are created by copying the current `MethodContext` (thisContext)";
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "arguments",
  7. category: 'interpreting',
  8. fn: function (){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) {
  11. var $1;
  12. $1=_st(_st(self._ast())._arguments())._collect_((function(each){
  13. return smalltalk.withContext(function($ctx2) {
  14. return self._localAt_(each);
  15. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  16. return $1;
  17. }, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.AIContext)})},
  18. args: [],
  19. source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ]",
  20. messageSends: ["collect:", "arguments", "ast", "localAt:"],
  21. referencedClasses: []
  22. }),
  23. smalltalk.AIContext);
  24. smalltalk.addMethod(
  25. smalltalk.method({
  26. selector: "asString",
  27. category: 'converting',
  28. fn: function (){
  29. var self=this;
  30. return smalltalk.withContext(function($ctx1) {
  31. var $1;
  32. $1=_st(self["@methodContext"])._asString();
  33. return $1;
  34. }, function($ctx1) {$ctx1.fill(self,"asString",{},smalltalk.AIContext)})},
  35. args: [],
  36. source: "asString\x0a\x09^ methodContext asString",
  37. messageSends: ["asString"],
  38. referencedClasses: []
  39. }),
  40. smalltalk.AIContext);
  41. smalltalk.addMethod(
  42. smalltalk.method({
  43. selector: "ast",
  44. category: 'interpreting',
  45. fn: function (){
  46. var self=this;
  47. return smalltalk.withContext(function($ctx1) {
  48. var $1,$2;
  49. $1=self["@ast"];
  50. if(($receiver = $1) == nil || $receiver == undefined){
  51. self._initializeAST();
  52. } else {
  53. $1;
  54. };
  55. $2=self["@ast"];
  56. return $2;
  57. }, function($ctx1) {$ctx1.fill(self,"ast",{},smalltalk.AIContext)})},
  58. args: [],
  59. source: "ast\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
  60. messageSends: ["ifNil:", "initializeAST"],
  61. referencedClasses: []
  62. }),
  63. smalltalk.AIContext);
  64. smalltalk.addMethod(
  65. smalltalk.method({
  66. selector: "home",
  67. category: 'accessing',
  68. fn: function (){
  69. var self=this;
  70. return smalltalk.withContext(function($ctx1) {
  71. var $2,$1;
  72. $2=self._isBlockContext();
  73. if(smalltalk.assert($2)){
  74. $1=_st(self._outerContext())._methodContext();
  75. } else {
  76. $1=self;
  77. };
  78. return $1;
  79. }, function($ctx1) {$ctx1.fill(self,"home",{},smalltalk.AIContext)})},
  80. args: [],
  81. source: "home\x0a\x09^ self isBlockContext \x0a\x09\x09ifTrue: [ self outerContext methodContext ]\x0a\x09\x09ifFalse: [ self ]",
  82. messageSends: ["ifTrue:ifFalse:", "methodContext", "outerContext", "isBlockContext"],
  83. referencedClasses: []
  84. }),
  85. smalltalk.AIContext);
  86. smalltalk.addMethod(
  87. smalltalk.method({
  88. selector: "initializeAST",
  89. category: 'initialization',
  90. fn: function (){
  91. var self=this;
  92. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  93. return smalltalk.withContext(function($ctx1) {
  94. self["@ast"]=_st(self._method())._ast();
  95. _st(_st($SemanticAnalyzer())._on_(_st(self._method())._methodClass()))._visit_(self["@ast"]);
  96. return self}, function($ctx1) {$ctx1.fill(self,"initializeAST",{},smalltalk.AIContext)})},
  97. args: [],
  98. source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
  99. messageSends: ["ast", "method", "visit:", "on:", "methodClass"],
  100. referencedClasses: ["SemanticAnalyzer"]
  101. }),
  102. smalltalk.AIContext);
  103. smalltalk.addMethod(
  104. smalltalk.method({
  105. selector: "initializeFromMethodContext:",
  106. category: 'initialization',
  107. fn: function (aMethodContext){
  108. var self=this;
  109. return smalltalk.withContext(function($ctx1) {
  110. var $1,$2;
  111. self["@methodContext"]=aMethodContext;
  112. self._pc_(_st(aMethodContext)._pc());
  113. self._receiver_(_st(aMethodContext)._receiver());
  114. self._method_(_st(aMethodContext)._method());
  115. $1=_st(aMethodContext)._outerContext();
  116. if(($receiver = $1) == nil || $receiver == undefined){
  117. $1;
  118. } else {
  119. var outer;
  120. outer=$receiver;
  121. $2=_st(outer)._methodContext();
  122. if(($receiver = $2) == nil || $receiver == undefined){
  123. $2;
  124. } else {
  125. self._outerContext_(_st(self._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
  126. };
  127. _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
  128. return smalltalk.withContext(function($ctx2) {
  129. return _st(self._locals())._at_put_(key,value);
  130. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  131. };
  132. return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext)})},
  133. args: ["aMethodContext"],
  134. source: "initializeFromMethodContext: aMethodContext\x0a\x09methodContext := aMethodContext.\x0a\x09\x0a\x09self pc: aMethodContext pc.\x0a\x09self receiver: aMethodContext receiver.\x0a\x09self method: aMethodContext method.\x0a\x09aMethodContext outerContext ifNotNil: [ :outer |\x0a\x09\x09\x22If the method context is nil, the block was defined in JS, so ignore it\x22\x0a\x09\x09outer methodContext ifNotNil: [\x0a\x09\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a\x09\x09\x09aMethodContext locals keysAndValuesDo: [ :key :value |\x0a\x09\x09\x09\x09self locals at: key put: value ] ]",
  135. messageSends: ["pc:", "pc", "receiver:", "receiver", "method:", "method", "ifNotNil:", "outerContext:", "fromMethodContext:", "outerContext", "class", "methodContext", "keysAndValuesDo:", "at:put:", "locals"],
  136. referencedClasses: []
  137. }),
  138. smalltalk.AIContext);
  139. smalltalk.addMethod(
  140. smalltalk.method({
  141. selector: "initializeInterpreter",
  142. category: 'initialization',
  143. fn: function (){
  144. var self=this;
  145. function $Interpreter(){return smalltalk.Interpreter||(typeof Interpreter=="undefined"?nil:Interpreter)}
  146. return smalltalk.withContext(function($ctx1) {
  147. var $1,$2,$3;
  148. $1=_st($Interpreter())._new();
  149. _st($1)._context_(self);
  150. _st($1)._node_(self._retrieveNode());
  151. $2=_st($1)._yourself();
  152. self["@interpreter"]=$2;
  153. $3=_st(self._innerContext())._isBlockContext();
  154. if(! smalltalk.assert($3)){
  155. self._setupInterpreter_(self["@interpreter"]);
  156. };
  157. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},smalltalk.AIContext)})},
  158. args: [],
  159. source: "initializeInterpreter\x0a\x09interpreter := Interpreter new\x0a\x09\x09context: self;\x0a\x09\x09node: self retrieveNode;\x0a\x09\x09yourself.\x0a\x09self innerContext isBlockContext ifFalse: [\x0a\x09\x09self setupInterpreter: interpreter ]",
  160. messageSends: ["context:", "new", "node:", "retrieveNode", "yourself", "ifFalse:", "setupInterpreter:", "isBlockContext", "innerContext"],
  161. referencedClasses: ["Interpreter"]
  162. }),
  163. smalltalk.AIContext);
  164. smalltalk.addMethod(
  165. smalltalk.method({
  166. selector: "initializeLocals",
  167. category: 'initialization',
  168. fn: function (){
  169. var self=this;
  170. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  171. return smalltalk.withContext(function($ctx1) {
  172. self["@locals"]=_st($Dictionary())._new();
  173. _st(self["@locals"])._at_put_("thisContext",self);
  174. return self}, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},smalltalk.AIContext)})},
  175. args: [],
  176. source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
  177. messageSends: ["new", "at:put:"],
  178. referencedClasses: ["Dictionary"]
  179. }),
  180. smalltalk.AIContext);
  181. smalltalk.addMethod(
  182. smalltalk.method({
  183. selector: "innerContext",
  184. category: 'accessing',
  185. fn: function (){
  186. var self=this;
  187. return smalltalk.withContext(function($ctx1) {
  188. var $1;
  189. $1=self["@innerContext"];
  190. return $1;
  191. }, function($ctx1) {$ctx1.fill(self,"innerContext",{},smalltalk.AIContext)})},
  192. args: [],
  193. source: "innerContext\x0a\x09^ innerContext",
  194. messageSends: [],
  195. referencedClasses: []
  196. }),
  197. smalltalk.AIContext);
  198. smalltalk.addMethod(
  199. smalltalk.method({
  200. selector: "innerContext:",
  201. category: 'accessing',
  202. fn: function (anAIContext){
  203. var self=this;
  204. return smalltalk.withContext(function($ctx1) {
  205. self["@innerContext"]=anAIContext;
  206. return self}, function($ctx1) {$ctx1.fill(self,"innerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  207. args: ["anAIContext"],
  208. source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
  209. messageSends: [],
  210. referencedClasses: []
  211. }),
  212. smalltalk.AIContext);
  213. smalltalk.addMethod(
  214. smalltalk.method({
  215. selector: "interpreter",
  216. category: 'interpreting',
  217. fn: function (){
  218. var self=this;
  219. return smalltalk.withContext(function($ctx1) {
  220. var $1,$2;
  221. $1=self["@interpreter"];
  222. if(($receiver = $1) == nil || $receiver == undefined){
  223. self._initializeInterpreter();
  224. } else {
  225. $1;
  226. };
  227. $2=self["@interpreter"];
  228. return $2;
  229. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AIContext)})},
  230. args: [],
  231. source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
  232. messageSends: ["ifNil:", "initializeInterpreter"],
  233. referencedClasses: []
  234. }),
  235. smalltalk.AIContext);
  236. smalltalk.addMethod(
  237. smalltalk.method({
  238. selector: "isBlockContext",
  239. category: 'testing',
  240. fn: function (){
  241. var self=this;
  242. return smalltalk.withContext(function($ctx1) {
  243. var $1;
  244. $1=_st(self["@methodContext"])._isBlockContext();
  245. return $1;
  246. }, function($ctx1) {$ctx1.fill(self,"isBlockContext",{},smalltalk.AIContext)})},
  247. args: [],
  248. source: "isBlockContext\x0a\x09^ methodContext isBlockContext",
  249. messageSends: ["isBlockContext"],
  250. referencedClasses: []
  251. }),
  252. smalltalk.AIContext);
  253. smalltalk.addMethod(
  254. smalltalk.method({
  255. selector: "localAt:",
  256. category: 'accessing',
  257. fn: function (aString){
  258. var self=this;
  259. return smalltalk.withContext(function($ctx1) {
  260. var $1;
  261. $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
  262. return smalltalk.withContext(function($ctx2) {
  263. return nil;
  264. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  265. return $1;
  266. }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},smalltalk.AIContext)})},
  267. args: ["aString"],
  268. source: "localAt: aString\x0a\x09^ self locals at: aString ifAbsent: [ nil ]",
  269. messageSends: ["at:ifAbsent:", "locals"],
  270. referencedClasses: []
  271. }),
  272. smalltalk.AIContext);
  273. smalltalk.addMethod(
  274. smalltalk.method({
  275. selector: "localAt:put:",
  276. category: 'accessing',
  277. fn: function (aString,anObject){
  278. var self=this;
  279. return smalltalk.withContext(function($ctx1) {
  280. _st(self._locals())._at_put_(aString,anObject);
  281. return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},smalltalk.AIContext)})},
  282. args: ["aString", "anObject"],
  283. source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
  284. messageSends: ["at:put:", "locals"],
  285. referencedClasses: []
  286. }),
  287. smalltalk.AIContext);
  288. smalltalk.addMethod(
  289. smalltalk.method({
  290. selector: "locals",
  291. category: 'accessing',
  292. fn: function (){
  293. var self=this;
  294. return smalltalk.withContext(function($ctx1) {
  295. var $1,$2;
  296. $1=self["@locals"];
  297. if(($receiver = $1) == nil || $receiver == undefined){
  298. self._initializeLocals();
  299. } else {
  300. $1;
  301. };
  302. $2=self["@locals"];
  303. return $2;
  304. }, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.AIContext)})},
  305. args: [],
  306. source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
  307. messageSends: ["ifNil:", "initializeLocals"],
  308. referencedClasses: []
  309. }),
  310. smalltalk.AIContext);
  311. smalltalk.addMethod(
  312. smalltalk.method({
  313. selector: "method",
  314. category: 'accessing',
  315. fn: function (){
  316. var self=this;
  317. return smalltalk.withContext(function($ctx1) {
  318. var $1;
  319. $1=self["@method"];
  320. return $1;
  321. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.AIContext)})},
  322. args: [],
  323. source: "method\x0a\x09^ method",
  324. messageSends: [],
  325. referencedClasses: []
  326. }),
  327. smalltalk.AIContext);
  328. smalltalk.addMethod(
  329. smalltalk.method({
  330. selector: "method:",
  331. category: 'accessing',
  332. fn: function (aCompiledMethod){
  333. var self=this;
  334. return smalltalk.withContext(function($ctx1) {
  335. self["@method"]=aCompiledMethod;
  336. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod},smalltalk.AIContext)})},
  337. args: ["aCompiledMethod"],
  338. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  339. messageSends: [],
  340. referencedClasses: []
  341. }),
  342. smalltalk.AIContext);
  343. smalltalk.addMethod(
  344. smalltalk.method({
  345. selector: "outerContext",
  346. category: 'accessing',
  347. fn: function (){
  348. var self=this;
  349. return smalltalk.withContext(function($ctx1) {
  350. var $1;
  351. $1=self["@outerContext"];
  352. return $1;
  353. }, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.AIContext)})},
  354. args: [],
  355. source: "outerContext\x0a\x09^ outerContext",
  356. messageSends: [],
  357. referencedClasses: []
  358. }),
  359. smalltalk.AIContext);
  360. smalltalk.addMethod(
  361. smalltalk.method({
  362. selector: "outerContext:",
  363. category: 'accessing',
  364. fn: function (anAIContext){
  365. var self=this;
  366. return smalltalk.withContext(function($ctx1) {
  367. self["@outerContext"]=anAIContext;
  368. _st(self["@outerContext"])._innerContext_(self);
  369. return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
  370. args: ["anAIContext"],
  371. source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext innerContext: self",
  372. messageSends: ["innerContext:"],
  373. referencedClasses: []
  374. }),
  375. smalltalk.AIContext);
  376. smalltalk.addMethod(
  377. smalltalk.method({
  378. selector: "pc",
  379. category: 'interpreting',
  380. fn: function (){
  381. var self=this;
  382. return smalltalk.withContext(function($ctx1) {
  383. var $2,$1;
  384. $2=self["@pc"];
  385. if(($receiver = $2) == nil || $receiver == undefined){
  386. self["@pc"]=(0);
  387. $1=self["@pc"];
  388. } else {
  389. $1=$2;
  390. };
  391. return $1;
  392. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.AIContext)})},
  393. args: [],
  394. source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
  395. messageSends: ["ifNil:"],
  396. referencedClasses: []
  397. }),
  398. smalltalk.AIContext);
  399. smalltalk.addMethod(
  400. smalltalk.method({
  401. selector: "pc:",
  402. category: 'interpreting',
  403. fn: function (anInteger){
  404. var self=this;
  405. return smalltalk.withContext(function($ctx1) {
  406. self["@pc"]=anInteger;
  407. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.AIContext)})},
  408. args: ["anInteger"],
  409. source: "pc: anInteger\x0a\x09pc := anInteger",
  410. messageSends: [],
  411. referencedClasses: []
  412. }),
  413. smalltalk.AIContext);
  414. smalltalk.addMethod(
  415. smalltalk.method({
  416. selector: "receiver",
  417. category: 'interpreting',
  418. fn: function (){
  419. var self=this;
  420. return smalltalk.withContext(function($ctx1) {
  421. var $1;
  422. $1=self._localAt_("self");
  423. return $1;
  424. }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AIContext)})},
  425. args: [],
  426. source: "receiver\x0a\x09^ self localAt: 'self'",
  427. messageSends: ["localAt:"],
  428. referencedClasses: []
  429. }),
  430. smalltalk.AIContext);
  431. smalltalk.addMethod(
  432. smalltalk.method({
  433. selector: "receiver:",
  434. category: 'interpreting',
  435. fn: function (anObject){
  436. var self=this;
  437. return smalltalk.withContext(function($ctx1) {
  438. self._localAt_put_("self",anObject);
  439. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},smalltalk.AIContext)})},
  440. args: ["anObject"],
  441. source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
  442. messageSends: ["localAt:put:"],
  443. referencedClasses: []
  444. }),
  445. smalltalk.AIContext);
  446. smalltalk.addMethod(
  447. smalltalk.method({
  448. selector: "retrieveNode",
  449. category: 'interpreting',
  450. fn: function (){
  451. var self=this;
  452. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  453. return smalltalk.withContext(function($ctx1) {
  454. var $2,$3,$1;
  455. $2=_st($ASTPCNodeVisitor())._new();
  456. _st($2)._context_(self);
  457. _st($2)._visit_(self._ast());
  458. $3=_st($2)._currentNode();
  459. $1=$3;
  460. return $1;
  461. }, function($ctx1) {$ctx1.fill(self,"retrieveNode",{},smalltalk.AIContext)})},
  462. args: [],
  463. source: "retrieveNode\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09context: self;\x0a\x09\x09visit: self ast;\x0a\x09\x09currentNode",
  464. messageSends: ["context:", "new", "visit:", "ast", "currentNode"],
  465. referencedClasses: ["ASTPCNodeVisitor"]
  466. }),
  467. smalltalk.AIContext);
  468. smalltalk.addMethod(
  469. smalltalk.method({
  470. selector: "selector",
  471. category: 'accessing',
  472. fn: function (){
  473. var self=this;
  474. return smalltalk.withContext(function($ctx1) {
  475. var $2,$1;
  476. $2=self._method();
  477. if(($receiver = $2) == nil || $receiver == undefined){
  478. $1=$2;
  479. } else {
  480. $1=_st(self._method())._selector();
  481. };
  482. return $1;
  483. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.AIContext)})},
  484. args: [],
  485. source: "selector\x0a\x09^ self method ifNotNil: [ \x0a\x09\x09self method selector ]",
  486. messageSends: ["ifNotNil:", "selector", "method"],
  487. referencedClasses: []
  488. }),
  489. smalltalk.AIContext);
  490. smalltalk.addMethod(
  491. smalltalk.method({
  492. selector: "setupInterpreter:",
  493. category: 'interpreting',
  494. fn: function (anInterpreter){
  495. var self=this;
  496. return smalltalk.withContext(function($ctx1) {
  497. _st(_st(_st(self._innerContext())._arguments())._reversed())._do_((function(each){
  498. return smalltalk.withContext(function($ctx2) {
  499. return _st(anInterpreter)._push_(each);
  500. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  501. _st(anInterpreter)._push_(_st(self._innerContext())._receiver());
  502. return self}, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
  503. args: ["anInterpreter"],
  504. source: "setupInterpreter: anInterpreter\x0a\x09\x22Push the send args and receiver to the interpreter stack\x22\x0a\x09\x0a\x09self innerContext arguments reversed do: [ :each | \x0a\x09\x09anInterpreter push: each ].\x0a\x09\x09\x0a\x09anInterpreter push: (self innerContext receiver)",
  505. messageSends: ["do:", "push:", "reversed", "arguments", "innerContext", "receiver"],
  506. referencedClasses: []
  507. }),
  508. smalltalk.AIContext);
  509. smalltalk.addMethod(
  510. smalltalk.method({
  511. selector: "fromMethodContext:",
  512. category: 'instance creation',
  513. fn: function (aMethodContext){
  514. var self=this;
  515. return smalltalk.withContext(function($ctx1) {
  516. var $2,$3,$1;
  517. $2=self._new();
  518. _st($2)._initializeFromMethodContext_(aMethodContext);
  519. $3=_st($2)._yourself();
  520. $1=$3;
  521. return $1;
  522. }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext.klass)})},
  523. args: ["aMethodContext"],
  524. source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
  525. messageSends: ["initializeFromMethodContext:", "new", "yourself"],
  526. referencedClasses: []
  527. }),
  528. smalltalk.AIContext.klass);
  529. smalltalk.addClass('ASTDebugger', smalltalk.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
  530. smalltalk.ASTDebugger.comment="I am a stepping debugger interface for Amber code.\x0aI internally use an instance of `ASTSteppingInterpreter` to actually step through node and interpret them.\x0a\x0aMy instances are created from a `MethodContext` with `ASTDebugger class >> context:`.\x0aThey hold an `AIContext` instance internally, recursive copy of the `MethodContext`.\x0a\x0a## API\x0a\x0aUse the methods of the `'stepping'` protocol to do stepping.";
  531. smalltalk.addMethod(
  532. smalltalk.method({
  533. selector: "atEnd",
  534. category: 'testing',
  535. fn: function (){
  536. var self=this;
  537. return smalltalk.withContext(function($ctx1) {
  538. var $1;
  539. $1=_st(self._interpreter())._atEnd();
  540. return $1;
  541. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTDebugger)})},
  542. args: [],
  543. source: "atEnd\x0a\x09^ self interpreter atEnd",
  544. messageSends: ["atEnd", "interpreter"],
  545. referencedClasses: []
  546. }),
  547. smalltalk.ASTDebugger);
  548. smalltalk.addMethod(
  549. smalltalk.method({
  550. selector: "buildAST",
  551. category: 'initialization',
  552. fn: function (){
  553. var self=this;
  554. var ast;
  555. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  556. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  557. return smalltalk.withContext(function($ctx1) {
  558. var $1;
  559. ast=_st(_st($Smalltalk())._current())._parse_(_st(self._method())._source());
  560. _st(_st($SemanticAnalyzer())._on_(_st(_st(self._context())._receiver())._class()))._visit_(ast);
  561. $1=ast;
  562. return $1;
  563. }, function($ctx1) {$ctx1.fill(self,"buildAST",{ast:ast},smalltalk.ASTDebugger)})},
  564. args: [],
  565. 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",
  566. messageSends: ["parse:", "current", "source", "method", "visit:", "on:", "class", "receiver", "context"],
  567. referencedClasses: ["Smalltalk", "SemanticAnalyzer"]
  568. }),
  569. smalltalk.ASTDebugger);
  570. smalltalk.addMethod(
  571. smalltalk.method({
  572. selector: "context",
  573. category: 'accessing',
  574. fn: function (){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) {
  577. var $1;
  578. $1=self["@context"];
  579. return $1;
  580. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTDebugger)})},
  581. args: [],
  582. source: "context\x0a\x09^ context",
  583. messageSends: [],
  584. referencedClasses: []
  585. }),
  586. smalltalk.ASTDebugger);
  587. smalltalk.addMethod(
  588. smalltalk.method({
  589. selector: "context:",
  590. category: 'accessing',
  591. fn: function (aContext){
  592. var self=this;
  593. return smalltalk.withContext(function($ctx1) {
  594. self["@context"]=aContext;
  595. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger)})},
  596. args: ["aContext"],
  597. source: "context: aContext\x0a\x09context := aContext",
  598. messageSends: [],
  599. referencedClasses: []
  600. }),
  601. smalltalk.ASTDebugger);
  602. smalltalk.addMethod(
  603. smalltalk.method({
  604. selector: "defaultInterpreterClass",
  605. category: 'defaults',
  606. fn: function (){
  607. var self=this;
  608. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  609. return smalltalk.withContext(function($ctx1) {
  610. var $1;
  611. $1=$ASTSteppingInterpreter();
  612. return $1;
  613. }, function($ctx1) {$ctx1.fill(self,"defaultInterpreterClass",{},smalltalk.ASTDebugger)})},
  614. args: [],
  615. source: "defaultInterpreterClass\x0a\x09^ ASTSteppingInterpreter",
  616. messageSends: [],
  617. referencedClasses: ["ASTSteppingInterpreter"]
  618. }),
  619. smalltalk.ASTDebugger);
  620. smalltalk.addMethod(
  621. smalltalk.method({
  622. selector: "initializeInterpreter",
  623. category: 'initialization',
  624. fn: function (){
  625. var self=this;
  626. var ast,next;
  627. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  628. return smalltalk.withContext(function($ctx1) {
  629. var $1,$2;
  630. ast=self._buildAST();
  631. $1=_st($ASTPCNodeVisitor())._new();
  632. _st($1)._context_(self._context());
  633. _st($1)._visit_(ast);
  634. $2=_st($1)._currentNode();
  635. next=$2;
  636. _st(self._interpreter())._interpret_(next);
  637. return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{ast:ast,next:next},smalltalk.ASTDebugger)})},
  638. args: [],
  639. source: "initializeInterpreter\x0a\x09| ast next |\x0a\x09ast := self buildAST.\x0a\x09next := ASTPCNodeVisitor new\x0a\x09\x09context: self context;\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode.\x0a\x09self interpreter interpret: next",
  640. messageSends: ["buildAST", "context:", "new", "context", "visit:", "currentNode", "interpret:", "interpreter"],
  641. referencedClasses: ["ASTPCNodeVisitor"]
  642. }),
  643. smalltalk.ASTDebugger);
  644. smalltalk.addMethod(
  645. smalltalk.method({
  646. selector: "initializeWithContext:",
  647. category: 'initialization',
  648. fn: function (aContext){
  649. var self=this;
  650. return smalltalk.withContext(function($ctx1) {
  651. self._context_(aContext);
  652. self._initializeInterpreter();
  653. return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:",{aContext:aContext},smalltalk.ASTDebugger)})},
  654. args: ["aContext"],
  655. source: "initializeWithContext: aContext\x0a\x09\x22TODO: do we need to handle block contexts?\x22\x0a\x09\x0a\x09self context: aContext.\x0a\x09self initializeInterpreter",
  656. messageSends: ["context:", "initializeInterpreter"],
  657. referencedClasses: []
  658. }),
  659. smalltalk.ASTDebugger);
  660. smalltalk.addMethod(
  661. smalltalk.method({
  662. selector: "interpreter",
  663. category: 'accessing',
  664. fn: function (){
  665. var self=this;
  666. return smalltalk.withContext(function($ctx1) {
  667. var $2,$1;
  668. $2=self["@interpreter"];
  669. if(($receiver = $2) == nil || $receiver == undefined){
  670. self["@interpreter"]=_st(self._defaultInterpreterClass())._new();
  671. $1=self["@interpreter"];
  672. } else {
  673. $1=$2;
  674. };
  675. return $1;
  676. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTDebugger)})},
  677. args: [],
  678. source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := self defaultInterpreterClass new ]",
  679. messageSends: ["ifNil:", "new", "defaultInterpreterClass"],
  680. referencedClasses: []
  681. }),
  682. smalltalk.ASTDebugger);
  683. smalltalk.addMethod(
  684. smalltalk.method({
  685. selector: "interpreter:",
  686. category: 'accessing',
  687. fn: function (anInterpreter){
  688. var self=this;
  689. return smalltalk.withContext(function($ctx1) {
  690. self["@interpreter"]=anInterpreter;
  691. return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.ASTDebugger)})},
  692. args: ["anInterpreter"],
  693. source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
  694. messageSends: [],
  695. referencedClasses: []
  696. }),
  697. smalltalk.ASTDebugger);
  698. smalltalk.addMethod(
  699. smalltalk.method({
  700. selector: "method",
  701. category: 'accessing',
  702. fn: function (){
  703. var self=this;
  704. return smalltalk.withContext(function($ctx1) {
  705. var $1;
  706. $1=_st(self._context())._method();
  707. return $1;
  708. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.ASTDebugger)})},
  709. args: [],
  710. source: "method\x0a\x09^ self context method",
  711. messageSends: ["method", "context"],
  712. referencedClasses: []
  713. }),
  714. smalltalk.ASTDebugger);
  715. smalltalk.addMethod(
  716. smalltalk.method({
  717. selector: "nextNode",
  718. category: 'accessing',
  719. fn: function (){
  720. var self=this;
  721. return smalltalk.withContext(function($ctx1) {
  722. var $1;
  723. $1=_st(self._interpreter())._nextNode();
  724. return $1;
  725. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTDebugger)})},
  726. args: [],
  727. source: "nextNode\x0a\x09^ self interpreter nextNode",
  728. messageSends: ["nextNode", "interpreter"],
  729. referencedClasses: []
  730. }),
  731. smalltalk.ASTDebugger);
  732. smalltalk.addMethod(
  733. smalltalk.method({
  734. selector: "proceed",
  735. category: 'stepping',
  736. fn: function (){
  737. var self=this;
  738. return smalltalk.withContext(function($ctx1) {
  739. self._shouldBeImplemented();
  740. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTDebugger)})},
  741. args: [],
  742. source: "proceed\x0a\x09self shouldBeImplemented",
  743. messageSends: ["shouldBeImplemented"],
  744. referencedClasses: []
  745. }),
  746. smalltalk.ASTDebugger);
  747. smalltalk.addMethod(
  748. smalltalk.method({
  749. selector: "restart",
  750. category: 'stepping',
  751. fn: function (){
  752. var self=this;
  753. return smalltalk.withContext(function($ctx1) {
  754. self._shouldBeImplemented();
  755. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTDebugger)})},
  756. args: [],
  757. source: "restart\x0a\x09self shouldBeImplemented",
  758. messageSends: ["shouldBeImplemented"],
  759. referencedClasses: []
  760. }),
  761. smalltalk.ASTDebugger);
  762. smalltalk.addMethod(
  763. smalltalk.method({
  764. selector: "step",
  765. category: 'stepping',
  766. fn: function (){
  767. var self=this;
  768. return smalltalk.withContext(function($ctx1) {
  769. _st((function(){
  770. return smalltalk.withContext(function($ctx2) {
  771. return _st(_st(_st(_st(self._interpreter())._nextNode())._notNil())._and_((function(){
  772. return smalltalk.withContext(function($ctx3) {
  773. return _st(_st(self._interpreter())._nextNode())._stopOnStepping();
  774. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})})))._or_((function(){
  775. return smalltalk.withContext(function($ctx3) {
  776. return _st(_st(self._interpreter())._atEnd())._not();
  777. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  778. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  779. return smalltalk.withContext(function($ctx2) {
  780. _st(self._interpreter())._step();
  781. return self._step();
  782. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  783. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTDebugger)})},
  784. args: [],
  785. 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 ]",
  786. messageSends: ["whileFalse:", "or:", "and:", "notNil", "nextNode", "interpreter", "stopOnStepping", "not", "atEnd", "step"],
  787. referencedClasses: []
  788. }),
  789. smalltalk.ASTDebugger);
  790. smalltalk.addMethod(
  791. smalltalk.method({
  792. selector: "stepInto",
  793. category: 'stepping',
  794. fn: function (){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) {
  797. self._shouldBeImplemented();
  798. return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},smalltalk.ASTDebugger)})},
  799. args: [],
  800. source: "stepInto\x0a\x09self shouldBeImplemented",
  801. messageSends: ["shouldBeImplemented"],
  802. referencedClasses: []
  803. }),
  804. smalltalk.ASTDebugger);
  805. smalltalk.addMethod(
  806. smalltalk.method({
  807. selector: "stepOver",
  808. category: 'stepping',
  809. fn: function (){
  810. var self=this;
  811. return smalltalk.withContext(function($ctx1) {
  812. self._step();
  813. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTDebugger)})},
  814. args: [],
  815. source: "stepOver\x0a\x09self step",
  816. messageSends: ["step"],
  817. referencedClasses: []
  818. }),
  819. smalltalk.ASTDebugger);
  820. smalltalk.addMethod(
  821. smalltalk.method({
  822. selector: "context:",
  823. category: 'instance creation',
  824. fn: function (aContext){
  825. var self=this;
  826. return smalltalk.withContext(function($ctx1) {
  827. var $2,$3,$1;
  828. $2=self._new();
  829. _st($2)._initializeWithContext_(aContext);
  830. $3=_st($2)._yourself();
  831. $1=$3;
  832. return $1;
  833. }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger.klass)})},
  834. args: ["aContext"],
  835. source: "context: aContext\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext;\x0a\x09\x09yourself",
  836. messageSends: ["initializeWithContext:", "new", "yourself"],
  837. referencedClasses: []
  838. }),
  839. smalltalk.ASTDebugger.klass);
  840. smalltalk.addClass('ASTInterpreter', smalltalk.Object, ['currentNode', 'nextNode', 'context', 'shouldReturn', 'result'], 'Compiler-Interpreter');
  841. smalltalk.ASTInterpreter.comment="I am like a `NodeVisitor`, interpreting nodes one after each other.\x0aI am built using Continuation Passing Style for stepping purposes.\x0a\x0a## Usage 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";
  842. smalltalk.addMethod(
  843. smalltalk.method({
  844. selector: "assign:to:",
  845. category: 'private',
  846. fn: function (aNode,anObject){
  847. var self=this;
  848. return smalltalk.withContext(function($ctx1) {
  849. var $2,$1;
  850. $2=_st(_st(aNode)._binding())._isInstanceVar();
  851. if(smalltalk.assert($2)){
  852. $1=_st(_st(self._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  853. } else {
  854. $1=_st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
  855. };
  856. return $1;
  857. }, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.ASTInterpreter)})},
  858. args: ["aNode", "anObject"],
  859. 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 ]",
  860. messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
  861. referencedClasses: []
  862. }),
  863. smalltalk.ASTInterpreter);
  864. smalltalk.addMethod(
  865. smalltalk.method({
  866. selector: "context",
  867. category: 'accessing',
  868. fn: function (){
  869. var self=this;
  870. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  871. return smalltalk.withContext(function($ctx1) {
  872. var $2,$1;
  873. $2=self["@context"];
  874. if(($receiver = $2) == nil || $receiver == undefined){
  875. self["@context"]=_st($AIContext())._new();
  876. $1=self["@context"];
  877. } else {
  878. $1=$2;
  879. };
  880. return $1;
  881. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTInterpreter)})},
  882. args: [],
  883. source: "context\x0a\x09^ context ifNil: [ context := AIContext new ]",
  884. messageSends: ["ifNil:", "new"],
  885. referencedClasses: ["AIContext"]
  886. }),
  887. smalltalk.ASTInterpreter);
  888. smalltalk.addMethod(
  889. smalltalk.method({
  890. selector: "context:",
  891. category: 'accessing',
  892. fn: function (anAIContext){
  893. var self=this;
  894. return smalltalk.withContext(function($ctx1) {
  895. self["@context"]=anAIContext;
  896. return self}, function($ctx1) {$ctx1.fill(self,"context:",{anAIContext:anAIContext},smalltalk.ASTInterpreter)})},
  897. args: ["anAIContext"],
  898. source: "context: anAIContext\x0a\x09context := anAIContext",
  899. messageSends: [],
  900. referencedClasses: []
  901. }),
  902. smalltalk.ASTInterpreter);
  903. smalltalk.addMethod(
  904. smalltalk.method({
  905. selector: "continue:value:",
  906. category: 'private',
  907. fn: function (aBlock,anObject){
  908. var self=this;
  909. return smalltalk.withContext(function($ctx1) {
  910. self["@result"]=anObject;
  911. _st(aBlock)._value_(anObject);
  912. return self}, function($ctx1) {$ctx1.fill(self,"continue:value:",{aBlock:aBlock,anObject:anObject},smalltalk.ASTInterpreter)})},
  913. args: ["aBlock", "anObject"],
  914. source: "continue: aBlock value: anObject\x0a\x09result := anObject.\x0a\x09aBlock value: anObject",
  915. messageSends: ["value:"],
  916. referencedClasses: []
  917. }),
  918. smalltalk.ASTInterpreter);
  919. smalltalk.addMethod(
  920. smalltalk.method({
  921. selector: "currentNode",
  922. category: 'accessing',
  923. fn: function (){
  924. var self=this;
  925. return smalltalk.withContext(function($ctx1) {
  926. var $1;
  927. $1=self["@currentNode"];
  928. return $1;
  929. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTInterpreter)})},
  930. args: [],
  931. source: "currentNode\x0a\x09^ currentNode",
  932. messageSends: [],
  933. referencedClasses: []
  934. }),
  935. smalltalk.ASTInterpreter);
  936. smalltalk.addMethod(
  937. smalltalk.method({
  938. selector: "eval:",
  939. category: 'private',
  940. fn: function (aString){
  941. var self=this;
  942. var source,function_;
  943. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  944. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  945. return smalltalk.withContext(function($ctx1) {
  946. var $1,$2,$3;
  947. source=_st($String())._streamContents_((function(str){
  948. return smalltalk.withContext(function($ctx2) {
  949. _st(str)._nextPutAll_("(function(");
  950. _st(_st(_st(self._context())._locals())._keys())._do_separatedBy_((function(each){
  951. return smalltalk.withContext(function($ctx3) {
  952. return _st(str)._nextPutAll_(each);
  953. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2)})}),(function(){
  954. return smalltalk.withContext(function($ctx3) {
  955. return _st(str)._nextPutAll_(",");
  956. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  957. $1=str;
  958. _st($1)._nextPutAll_("){ return (function() {");
  959. _st($1)._nextPutAll_(aString);
  960. $2=_st($1)._nextPutAll_("})() })");
  961. return $2;
  962. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
  963. function_=_st(_st($Compiler())._new())._eval_(source);
  964. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
  965. return $3;
  966. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.ASTInterpreter)})},
  967. args: ["aString"],
  968. 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",
  969. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  970. referencedClasses: ["String", "Compiler"]
  971. }),
  972. smalltalk.ASTInterpreter);
  973. smalltalk.addMethod(
  974. smalltalk.method({
  975. selector: "initialize",
  976. category: 'initialization',
  977. fn: function (){
  978. var self=this;
  979. return smalltalk.withContext(function($ctx1) {
  980. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  981. self["@shouldReturn"]=false;
  982. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ASTInterpreter)})},
  983. args: [],
  984. source: "initialize\x0a\x09super initialize.\x0a\x09shouldReturn := false",
  985. messageSends: ["initialize"],
  986. referencedClasses: []
  987. }),
  988. smalltalk.ASTInterpreter);
  989. smalltalk.addMethod(
  990. smalltalk.method({
  991. selector: "interpret:",
  992. category: 'interpreting',
  993. fn: function (aNode){
  994. var self=this;
  995. return smalltalk.withContext(function($ctx1) {
  996. self["@shouldReturn"]=false;
  997. self._interpret_continue_(aNode,(function(value){
  998. return smalltalk.withContext(function($ctx2) {
  999. self["@result"]=value;
  1000. return self["@result"];
  1001. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1002. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1003. args: ["aNode"],
  1004. source: "interpret: aNode\x0a\x09shouldReturn := false.\x0a\x09self interpret: aNode continue: [ :value |\x0a\x09\x09result := value ]",
  1005. messageSends: ["interpret:continue:"],
  1006. referencedClasses: []
  1007. }),
  1008. smalltalk.ASTInterpreter);
  1009. smalltalk.addMethod(
  1010. smalltalk.method({
  1011. selector: "interpret:continue:",
  1012. category: 'interpreting',
  1013. fn: function (aNode,aBlock){
  1014. var self=this;
  1015. return smalltalk.withContext(function($ctx1) {
  1016. var $1,$2,$3;
  1017. $1=self["@shouldReturn"];
  1018. if(smalltalk.assert($1)){
  1019. $2=self;
  1020. return $2;
  1021. };
  1022. $3=_st(aNode)._isNode();
  1023. if(smalltalk.assert($3)){
  1024. self["@currentNode"]=aNode;
  1025. self["@currentNode"];
  1026. self._interpretNode_continue_(aNode,(function(value){
  1027. return smalltalk.withContext(function($ctx2) {
  1028. return self._continue_value_(aBlock,value);
  1029. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1030. } else {
  1031. self._continue_value_(aBlock,aNode);
  1032. };
  1033. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1034. args: ["aNode", "aBlock"],
  1035. 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 ]",
  1036. messageSends: ["ifTrue:", "ifTrue:ifFalse:", "isNode", "interpretNode:continue:", "continue:value:"],
  1037. referencedClasses: []
  1038. }),
  1039. smalltalk.ASTInterpreter);
  1040. smalltalk.addMethod(
  1041. smalltalk.method({
  1042. selector: "interpretAll:continue:",
  1043. category: 'private',
  1044. fn: function (aCollection,aBlock){
  1045. var self=this;
  1046. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1047. return smalltalk.withContext(function($ctx1) {
  1048. self._interpretAll_continue_result_(aCollection,aBlock,_st($OrderedCollection())._new());
  1049. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:",{aCollection:aCollection,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1050. args: ["aCollection", "aBlock"],
  1051. source: "interpretAll: aCollection continue: aBlock\x0a\x09self\x0a\x09\x09interpretAll: aCollection\x0a\x09\x09continue: aBlock\x0a\x09\x09result: OrderedCollection new",
  1052. messageSends: ["interpretAll:continue:result:", "new"],
  1053. referencedClasses: ["OrderedCollection"]
  1054. }),
  1055. smalltalk.ASTInterpreter);
  1056. smalltalk.addMethod(
  1057. smalltalk.method({
  1058. selector: "interpretAll:continue:result:",
  1059. category: 'private',
  1060. fn: function (nodes,aBlock,aCollection){
  1061. var self=this;
  1062. return smalltalk.withContext(function($ctx1) {
  1063. var $1;
  1064. $1=_st(nodes)._isEmpty();
  1065. if(smalltalk.assert($1)){
  1066. self._continue_value_(aBlock,aCollection);
  1067. } else {
  1068. self._interpret_continue_(_st(nodes)._first(),(function(value){
  1069. return smalltalk.withContext(function($ctx2) {
  1070. return self._interpretAll_continue_result_(_st(nodes)._allButFirst(),aBlock,_st(aCollection).__comma([value]));
  1071. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1072. };
  1073. return self}, function($ctx1) {$ctx1.fill(self,"interpretAll:continue:result:",{nodes:nodes,aBlock:aBlock,aCollection:aCollection},smalltalk.ASTInterpreter)})},
  1074. args: ["nodes", "aBlock", "aCollection"],
  1075. 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 } ] ]",
  1076. messageSends: ["ifTrue:ifFalse:", "isEmpty", "continue:value:", "interpret:continue:", "first", "interpretAll:continue:result:", "allButFirst", ","],
  1077. referencedClasses: []
  1078. }),
  1079. smalltalk.ASTInterpreter);
  1080. smalltalk.addMethod(
  1081. smalltalk.method({
  1082. selector: "interpretAssignmentNode:continue:",
  1083. category: 'interpreting',
  1084. fn: function (aNode,aBlock){
  1085. var self=this;
  1086. return smalltalk.withContext(function($ctx1) {
  1087. self._interpret_continue_(_st(aNode)._right(),(function(value){
  1088. return smalltalk.withContext(function($ctx2) {
  1089. return self._continue_value_(aBlock,self._assign_to_(_st(aNode)._left(),value));
  1090. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1091. return self}, function($ctx1) {$ctx1.fill(self,"interpretAssignmentNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1092. args: ["aNode", "aBlock"],
  1093. 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) ]",
  1094. messageSends: ["interpret:continue:", "right", "continue:value:", "assign:to:", "left"],
  1095. referencedClasses: []
  1096. }),
  1097. smalltalk.ASTInterpreter);
  1098. smalltalk.addMethod(
  1099. smalltalk.method({
  1100. selector: "interpretBlockNode:continue:",
  1101. category: 'interpreting',
  1102. fn: function (aNode,aBlock){
  1103. var self=this;
  1104. return smalltalk.withContext(function($ctx1) {
  1105. var $1,$2;
  1106. self._continue_value_(aBlock,(function(){
  1107. return smalltalk.withContext(function($ctx2) {
  1108. return self._withBlockContext_((function(){
  1109. return smalltalk.withContext(function($ctx3) {
  1110. $1=self;
  1111. _st($1)._interpret_(_st(_st(aNode)._nodes())._first());
  1112. $2=_st($1)._result();
  1113. return $2;
  1114. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  1115. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1116. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1117. args: ["aNode", "aBlock"],
  1118. source: "interpretBlockNode: aNode continue: aBlock\x0a\x09self\x0a\x09\x09continue: aBlock\x0a\x09\x09value: [ \x0a\x09\x09\x09self withBlockContext: [ \x0a\x09\x09\x09\x09self interpret: aNode nodes first; result ] ]",
  1119. messageSends: ["continue:value:", "withBlockContext:", "interpret:", "first", "nodes", "result"],
  1120. referencedClasses: []
  1121. }),
  1122. smalltalk.ASTInterpreter);
  1123. smalltalk.addMethod(
  1124. smalltalk.method({
  1125. selector: "interpretBlockSequenceNode:continue:",
  1126. category: 'interpreting',
  1127. fn: function (aNode,aBlock){
  1128. var self=this;
  1129. return smalltalk.withContext(function($ctx1) {
  1130. self._interpretSequenceNode_continue_(aNode,aBlock);
  1131. return self}, function($ctx1) {$ctx1.fill(self,"interpretBlockSequenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1132. args: ["aNode", "aBlock"],
  1133. source: "interpretBlockSequenceNode: aNode continue: aBlock\x0a\x09self interpretSequenceNode: aNode continue: aBlock",
  1134. messageSends: ["interpretSequenceNode:continue:"],
  1135. referencedClasses: []
  1136. }),
  1137. smalltalk.ASTInterpreter);
  1138. smalltalk.addMethod(
  1139. smalltalk.method({
  1140. selector: "interpretCascadeNode:continue:",
  1141. category: 'interpreting',
  1142. fn: function (aNode,aBlock){
  1143. var self=this;
  1144. return smalltalk.withContext(function($ctx1) {
  1145. self._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  1146. return smalltalk.withContext(function($ctx2) {
  1147. _st(_st(aNode)._nodes())._do_((function(each){
  1148. return smalltalk.withContext(function($ctx3) {
  1149. return _st(each)._receiver_(receiver);
  1150. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2)})}));
  1151. return self._interpretAll_continue_(_st(_st(aNode)._nodes())._allButLast(),(function(){
  1152. return smalltalk.withContext(function($ctx3) {
  1153. return self._interpret_continue_(_st(_st(aNode)._nodes())._last(),(function(val){
  1154. return smalltalk.withContext(function($ctx4) {
  1155. return self._continue_value_(aBlock,val);
  1156. }, function($ctx4) {$ctx4.fillBlock({val:val},$ctx3)})}));
  1157. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  1158. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  1159. return self}, function($ctx1) {$ctx1.fill(self,"interpretCascadeNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1160. args: ["aNode", "aBlock"],
  1161. 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 ] ] ]",
  1162. messageSends: ["interpret:continue:", "receiver", "do:", "nodes", "receiver:", "interpretAll:continue:", "allButLast", "last", "continue:value:"],
  1163. referencedClasses: []
  1164. }),
  1165. smalltalk.ASTInterpreter);
  1166. smalltalk.addMethod(
  1167. smalltalk.method({
  1168. selector: "interpretClassReferenceNode:continue:",
  1169. category: 'interpreting',
  1170. fn: function (aNode,aBlock){
  1171. var self=this;
  1172. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1173. return smalltalk.withContext(function($ctx1) {
  1174. self._continue_value_(aBlock,_st(_st($Smalltalk())._current())._at_(_st(aNode)._value()));
  1175. return self}, function($ctx1) {$ctx1.fill(self,"interpretClassReferenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1176. args: ["aNode", "aBlock"],
  1177. source: "interpretClassReferenceNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: (Smalltalk current at: aNode value)",
  1178. messageSends: ["continue:value:", "at:", "current", "value"],
  1179. referencedClasses: ["Smalltalk"]
  1180. }),
  1181. smalltalk.ASTInterpreter);
  1182. smalltalk.addMethod(
  1183. smalltalk.method({
  1184. selector: "interpretDynamicArrayNode:continue:",
  1185. category: 'interpreting',
  1186. fn: function (aNode,aBlock){
  1187. var self=this;
  1188. return smalltalk.withContext(function($ctx1) {
  1189. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1190. return smalltalk.withContext(function($ctx2) {
  1191. return self._continue_value_(aBlock,array);
  1192. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  1193. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicArrayNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1194. args: ["aNode", "aBlock"],
  1195. 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 ]",
  1196. messageSends: ["interpretAll:continue:", "nodes", "continue:value:"],
  1197. referencedClasses: []
  1198. }),
  1199. smalltalk.ASTInterpreter);
  1200. smalltalk.addMethod(
  1201. smalltalk.method({
  1202. selector: "interpretDynamicDictionaryNode:continue:",
  1203. category: 'interpreting',
  1204. fn: function (aNode,aBlock){
  1205. var self=this;
  1206. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1207. return smalltalk.withContext(function($ctx1) {
  1208. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1209. var hashedCollection;
  1210. return smalltalk.withContext(function($ctx2) {
  1211. hashedCollection=_st($HashedCollection())._new();
  1212. hashedCollection;
  1213. _st(array)._do_((function(each){
  1214. return smalltalk.withContext(function($ctx3) {
  1215. return _st(hashedCollection)._add_(each);
  1216. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2)})}));
  1217. return self._continue_value_(aBlock,hashedCollection);
  1218. }, function($ctx2) {$ctx2.fillBlock({array:array,hashedCollection:hashedCollection},$ctx1)})}));
  1219. return self}, function($ctx1) {$ctx1.fill(self,"interpretDynamicDictionaryNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1220. args: ["aNode", "aBlock"],
  1221. 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 ]",
  1222. messageSends: ["interpretAll:continue:", "nodes", "new", "do:", "add:", "continue:value:"],
  1223. referencedClasses: ["HashedCollection"]
  1224. }),
  1225. smalltalk.ASTInterpreter);
  1226. smalltalk.addMethod(
  1227. smalltalk.method({
  1228. selector: "interpretJSStatementNode:continue:",
  1229. category: 'interpreting',
  1230. fn: function (aNode,aBlock){
  1231. var self=this;
  1232. return smalltalk.withContext(function($ctx1) {
  1233. self["@shouldReturn"]=true;
  1234. self._continue_value_(aBlock,self._eval_(_st(aNode)._source()));
  1235. return self}, function($ctx1) {$ctx1.fill(self,"interpretJSStatementNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1236. args: ["aNode", "aBlock"],
  1237. source: "interpretJSStatementNode: aNode continue: aBlock\x0a\x09shouldReturn := true.\x0a\x09self continue: aBlock value: (self eval: aNode source)",
  1238. messageSends: ["continue:value:", "eval:", "source"],
  1239. referencedClasses: []
  1240. }),
  1241. smalltalk.ASTInterpreter);
  1242. smalltalk.addMethod(
  1243. smalltalk.method({
  1244. selector: "interpretMethodNode:continue:",
  1245. category: 'interpreting',
  1246. fn: function (aNode,aBlock){
  1247. var self=this;
  1248. return smalltalk.withContext(function($ctx1) {
  1249. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1250. return smalltalk.withContext(function($ctx2) {
  1251. return self._continue_value_(aBlock,_st(array)._first());
  1252. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  1253. return self}, function($ctx1) {$ctx1.fill(self,"interpretMethodNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1254. args: ["aNode", "aBlock"],
  1255. source: "interpretMethodNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self continue: aBlock value: array first ]",
  1256. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "first"],
  1257. referencedClasses: []
  1258. }),
  1259. smalltalk.ASTInterpreter);
  1260. smalltalk.addMethod(
  1261. smalltalk.method({
  1262. selector: "interpretNode:continue:",
  1263. category: 'interpreting',
  1264. fn: function (aNode,aBlock){
  1265. var self=this;
  1266. return smalltalk.withContext(function($ctx1) {
  1267. _st(aNode)._interpreter_continue_(self,aBlock);
  1268. return self}, function($ctx1) {$ctx1.fill(self,"interpretNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1269. args: ["aNode", "aBlock"],
  1270. source: "interpretNode: aNode continue: aBlock\x0a\x09aNode interpreter: self continue: aBlock",
  1271. messageSends: ["interpreter:continue:"],
  1272. referencedClasses: []
  1273. }),
  1274. smalltalk.ASTInterpreter);
  1275. smalltalk.addMethod(
  1276. smalltalk.method({
  1277. selector: "interpretReturnNode:continue:",
  1278. category: 'interpreting',
  1279. fn: function (aNode,aBlock){
  1280. var self=this;
  1281. return smalltalk.withContext(function($ctx1) {
  1282. self._interpret_continue_(_st(_st(aNode)._nodes())._first(),(function(value){
  1283. return smalltalk.withContext(function($ctx2) {
  1284. self["@shouldReturn"]=true;
  1285. self["@shouldReturn"];
  1286. return self._continue_value_(aBlock,value);
  1287. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1288. return self}, function($ctx1) {$ctx1.fill(self,"interpretReturnNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1289. args: ["aNode", "aBlock"],
  1290. source: "interpretReturnNode: aNode continue: aBlock\x0a\x09self interpret: aNode nodes first continue: [ :value |\x0a\x09\x09shouldReturn := true.\x0a\x09\x09self continue: aBlock value: value ]",
  1291. messageSends: ["interpret:continue:", "first", "nodes", "continue:value:"],
  1292. referencedClasses: []
  1293. }),
  1294. smalltalk.ASTInterpreter);
  1295. smalltalk.addMethod(
  1296. smalltalk.method({
  1297. selector: "interpretSendNode:continue:",
  1298. category: 'interpreting',
  1299. fn: function (aNode,aBlock){
  1300. var self=this;
  1301. return smalltalk.withContext(function($ctx1) {
  1302. self._interpret_continue_(_st(aNode)._receiver(),(function(receiver){
  1303. return smalltalk.withContext(function($ctx2) {
  1304. return self._interpretAll_continue_(_st(aNode)._arguments(),(function(args){
  1305. return smalltalk.withContext(function($ctx3) {
  1306. return self._messageFromSendNode_arguments_do_(aNode,args,(function(message){
  1307. return smalltalk.withContext(function($ctx4) {
  1308. _st(self._context())._pc_(_st(_st(self._context())._pc()).__plus((1)));
  1309. return self._continue_value_(aBlock,self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend()));
  1310. }, function($ctx4) {$ctx4.fillBlock({message:message},$ctx3)})}));
  1311. }, function($ctx3) {$ctx3.fillBlock({args:args},$ctx2)})}));
  1312. }, function($ctx2) {$ctx2.fillBlock({receiver:receiver},$ctx1)})}));
  1313. return self}, function($ctx1) {$ctx1.fill(self,"interpretSendNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1314. args: ["aNode", "aBlock"],
  1315. source: "interpretSendNode: aNode continue: aBlock\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: (self sendMessage: message to: receiver superSend: aNode superSend) ] ] ]",
  1316. messageSends: ["interpret:continue:", "receiver", "interpretAll:continue:", "arguments", "messageFromSendNode:arguments:do:", "pc:", "context", "+", "pc", "continue:value:", "sendMessage:to:superSend:", "superSend"],
  1317. referencedClasses: []
  1318. }),
  1319. smalltalk.ASTInterpreter);
  1320. smalltalk.addMethod(
  1321. smalltalk.method({
  1322. selector: "interpretSequenceNode:continue:",
  1323. category: 'interpreting',
  1324. fn: function (aNode,aBlock){
  1325. var self=this;
  1326. return smalltalk.withContext(function($ctx1) {
  1327. self._interpretAll_continue_(_st(aNode)._nodes(),(function(array){
  1328. return smalltalk.withContext(function($ctx2) {
  1329. return self._continue_value_(aBlock,_st(array)._last());
  1330. }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
  1331. return self}, function($ctx1) {$ctx1.fill(self,"interpretSequenceNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1332. args: ["aNode", "aBlock"],
  1333. source: "interpretSequenceNode: aNode continue: aBlock\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a\x09\x09self continue: aBlock value: array last ]",
  1334. messageSends: ["interpretAll:continue:", "nodes", "continue:value:", "last"],
  1335. referencedClasses: []
  1336. }),
  1337. smalltalk.ASTInterpreter);
  1338. smalltalk.addMethod(
  1339. smalltalk.method({
  1340. selector: "interpretValueNode:continue:",
  1341. category: 'interpreting',
  1342. fn: function (aNode,aBlock){
  1343. var self=this;
  1344. return smalltalk.withContext(function($ctx1) {
  1345. self._continue_value_(aBlock,_st(aNode)._value());
  1346. return self}, function($ctx1) {$ctx1.fill(self,"interpretValueNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1347. args: ["aNode", "aBlock"],
  1348. source: "interpretValueNode: aNode continue: aBlock\x0a\x09self continue: aBlock value: aNode value",
  1349. messageSends: ["continue:value:", "value"],
  1350. referencedClasses: []
  1351. }),
  1352. smalltalk.ASTInterpreter);
  1353. smalltalk.addMethod(
  1354. smalltalk.method({
  1355. selector: "interpretVariableNode:continue:",
  1356. category: 'interpreting',
  1357. fn: function (aNode,aBlock){
  1358. var self=this;
  1359. return smalltalk.withContext(function($ctx1) {
  1360. var $1,$2,$4,$3;
  1361. $1=self;
  1362. $2=aBlock;
  1363. $4=_st(_st(aNode)._binding())._isInstanceVar();
  1364. if(smalltalk.assert($4)){
  1365. $3=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
  1366. } else {
  1367. $3=_st(self._context())._localAt_(_st(aNode)._value());
  1368. };
  1369. _st($1)._continue_value_($2,$3);
  1370. return self}, function($ctx1) {$ctx1.fill(self,"interpretVariableNode:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1371. args: ["aNode", "aBlock"],
  1372. 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 ])",
  1373. messageSends: ["continue:value:", "ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:", "receiver", "context", "value", "localAt:"],
  1374. referencedClasses: []
  1375. }),
  1376. smalltalk.ASTInterpreter);
  1377. smalltalk.addMethod(
  1378. smalltalk.method({
  1379. selector: "messageFromSendNode:arguments:do:",
  1380. category: 'private',
  1381. fn: function (aSendNode,aCollection,aBlock){
  1382. var self=this;
  1383. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  1384. return smalltalk.withContext(function($ctx1) {
  1385. var $1,$2;
  1386. $1=_st($Message())._new();
  1387. _st($1)._selector_(_st(aSendNode)._selector());
  1388. _st($1)._arguments_(aCollection);
  1389. $2=_st($1)._yourself();
  1390. self._continue_value_(aBlock,$2);
  1391. return self}, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:do:",{aSendNode:aSendNode,aCollection:aCollection,aBlock:aBlock},smalltalk.ASTInterpreter)})},
  1392. args: ["aSendNode", "aCollection", "aBlock"],
  1393. 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)",
  1394. messageSends: ["continue:value:", "selector:", "new", "selector", "arguments:", "yourself"],
  1395. referencedClasses: ["Message"]
  1396. }),
  1397. smalltalk.ASTInterpreter);
  1398. smalltalk.addMethod(
  1399. smalltalk.method({
  1400. selector: "nextNode",
  1401. category: 'accessing',
  1402. fn: function (){
  1403. var self=this;
  1404. return smalltalk.withContext(function($ctx1) {
  1405. var $2,$1;
  1406. $2=self["@nextNode"];
  1407. if(($receiver = $2) == nil || $receiver == undefined){
  1408. $1=self._currentNode();
  1409. } else {
  1410. $1=$2;
  1411. };
  1412. return $1;
  1413. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTInterpreter)})},
  1414. args: [],
  1415. source: "nextNode\x0a\x09^ nextNode ifNil: [ self currentNode ]",
  1416. messageSends: ["ifNil:", "currentNode"],
  1417. referencedClasses: []
  1418. }),
  1419. smalltalk.ASTInterpreter);
  1420. smalltalk.addMethod(
  1421. smalltalk.method({
  1422. selector: "nextNode:",
  1423. category: 'accessing',
  1424. fn: function (aNode){
  1425. var self=this;
  1426. return smalltalk.withContext(function($ctx1) {
  1427. self["@nextNode"]=aNode;
  1428. return self}, function($ctx1) {$ctx1.fill(self,"nextNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
  1429. args: ["aNode"],
  1430. source: "nextNode: aNode\x0a\x09nextNode := aNode",
  1431. messageSends: [],
  1432. referencedClasses: []
  1433. }),
  1434. smalltalk.ASTInterpreter);
  1435. smalltalk.addMethod(
  1436. smalltalk.method({
  1437. selector: "result",
  1438. category: 'accessing',
  1439. fn: function (){
  1440. var self=this;
  1441. return smalltalk.withContext(function($ctx1) {
  1442. var $1;
  1443. $1=self["@result"];
  1444. return $1;
  1445. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ASTInterpreter)})},
  1446. args: [],
  1447. source: "result\x0a\x09^ result",
  1448. messageSends: [],
  1449. referencedClasses: []
  1450. }),
  1451. smalltalk.ASTInterpreter);
  1452. smalltalk.addMethod(
  1453. smalltalk.method({
  1454. selector: "sendMessage:to:superSend:",
  1455. category: 'private',
  1456. fn: function (aMessage,anObject,aBoolean){
  1457. var self=this;
  1458. var method;
  1459. return smalltalk.withContext(function($ctx1) {
  1460. var $1,$2,$3,$4,$5,$6;
  1461. var $early={};
  1462. try {
  1463. $1=aBoolean;
  1464. if(! smalltalk.assert($1)){
  1465. $2=_st(aMessage)._sendTo_(anObject);
  1466. return $2;
  1467. };
  1468. $3=_st(_st(anObject)._class())._superclass();
  1469. if(($receiver = $3) == nil || $receiver == undefined){
  1470. $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1471. return $4;
  1472. } else {
  1473. $3;
  1474. };
  1475. method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
  1476. return smalltalk.withContext(function($ctx2) {
  1477. $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
  1478. throw $early=[$5];
  1479. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1480. $6=_st(_st(method)._fn())._applyTo_arguments_(anObject,_st(aMessage)._arguments());
  1481. return $6;
  1482. }
  1483. catch(e) {if(e===$early)return e[0]; throw e}
  1484. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.ASTInterpreter)})},
  1485. args: ["aMessage", "anObject", "aBoolean"],
  1486. source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method fn applyTo: anObject arguments: aMessage arguments\x0a\x09\x09\x0a\x09\x0a\x09",
  1487. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "applyTo:arguments:", "fn", "arguments"],
  1488. referencedClasses: []
  1489. }),
  1490. smalltalk.ASTInterpreter);
  1491. smalltalk.addMethod(
  1492. smalltalk.method({
  1493. selector: "shouldReturn",
  1494. category: 'testing',
  1495. fn: function (){
  1496. var self=this;
  1497. return smalltalk.withContext(function($ctx1) {
  1498. var $2,$1;
  1499. $2=self["@shouldReturn"];
  1500. if(($receiver = $2) == nil || $receiver == undefined){
  1501. $1=false;
  1502. } else {
  1503. $1=$2;
  1504. };
  1505. return $1;
  1506. }, function($ctx1) {$ctx1.fill(self,"shouldReturn",{},smalltalk.ASTInterpreter)})},
  1507. args: [],
  1508. source: "shouldReturn\x0a\x09^ shouldReturn ifNil: [ false ]",
  1509. messageSends: ["ifNil:"],
  1510. referencedClasses: []
  1511. }),
  1512. smalltalk.ASTInterpreter);
  1513. smalltalk.addMethod(
  1514. smalltalk.method({
  1515. selector: "withBlockContext:",
  1516. category: 'private',
  1517. fn: function (aBlock){
  1518. var self=this;
  1519. var blockResult;
  1520. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  1521. return smalltalk.withContext(function($ctx1) {
  1522. var $1,$2,$3;
  1523. $1=_st($AIContext())._new();
  1524. _st($1)._outerContext_(self._context());
  1525. $2=_st($1)._yourself();
  1526. self._context_($2);
  1527. blockResult=_st(aBlock)._value();
  1528. self._context_(_st(self._context())._outerContext());
  1529. $3=blockResult;
  1530. return $3;
  1531. }, function($ctx1) {$ctx1.fill(self,"withBlockContext:",{aBlock:aBlock,blockResult:blockResult},smalltalk.ASTInterpreter)})},
  1532. args: ["aBlock"],
  1533. source: "withBlockContext: aBlock\x0a\x09\x22Evaluate aBlock with a BlockContext:\x0a\x09- a context is pushed before aBlock evaluation.\x0a\x09- the context is poped after aBlock evaluation\x0a\x09- the result of aBlock evaluation is answered\x22\x0a\x09\x0a\x09| blockResult |\x0a\x09\x09\x09\x0a\x09self context: (AIContext new\x0a\x09\x09outerContext: self context;\x0a\x09\x09yourself).\x0a\x09\x0a\x09blockResult := aBlock value.\x0a\x09\x0a\x09self context: self context outerContext.\x0a\x09^ blockResult",
  1534. messageSends: ["context:", "outerContext:", "new", "context", "yourself", "value", "outerContext"],
  1535. referencedClasses: ["AIContext"]
  1536. }),
  1537. smalltalk.ASTInterpreter);
  1538. smalltalk.addClass('ASTSteppingInterpreter', smalltalk.ASTInterpreter, ['continuation', 'nextNode'], 'Compiler-Interpreter');
  1539. smalltalk.ASTSteppingInterpreter.comment="I am an interpreter with stepping capabilities. The higher level `ASTDebugger` class should be used as a debugger model, as it provides convenience methods for debugging.\x0a\x0a## API\x0a\x0aUse `#step` to actually interpret the next node. Interpretation stops at each node evaluation, weither it's a message node or not.\x0a\x0a\x0a## Usage 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\x09interpreter step; step.\x0a\x09interpreter step; step.\x0a\x09interpreter result.\x22Answers 1\x22\x0a\x09interpreter step.\x0a\x09interpreter result. \x22Answers 3\x22\x0a\x09interpreter step.\x0a\x09interpreter result. \x22Answers 7\x22";
  1540. smalltalk.addMethod(
  1541. smalltalk.method({
  1542. selector: "atEnd",
  1543. category: 'testing',
  1544. fn: function (){
  1545. var self=this;
  1546. return smalltalk.withContext(function($ctx1) {
  1547. var $1;
  1548. $1=_st(self._shouldReturn())._or_((function(){
  1549. return smalltalk.withContext(function($ctx2) {
  1550. return _st(self._nextNode()).__eq_eq(self._currentNode());
  1551. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1552. return $1;
  1553. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTSteppingInterpreter)})},
  1554. args: [],
  1555. source: "atEnd\x0a\x09^ self shouldReturn or: [ self nextNode == self currentNode ]",
  1556. messageSends: ["or:", "shouldReturn", "==", "nextNode", "currentNode"],
  1557. referencedClasses: []
  1558. }),
  1559. smalltalk.ASTSteppingInterpreter);
  1560. smalltalk.addMethod(
  1561. smalltalk.method({
  1562. selector: "initialize",
  1563. category: 'initialization',
  1564. fn: function (){
  1565. var self=this;
  1566. return smalltalk.withContext(function($ctx1) {
  1567. smalltalk.ASTInterpreter.fn.prototype._initialize.apply(_st(self), []);
  1568. self["@continuation"]=(function(){
  1569. return smalltalk.withContext(function($ctx2) {
  1570. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  1571. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ASTSteppingInterpreter)})},
  1572. args: [],
  1573. source: "initialize\x0a\x09super initialize.\x0a\x09continuation := []",
  1574. messageSends: ["initialize"],
  1575. referencedClasses: []
  1576. }),
  1577. smalltalk.ASTSteppingInterpreter);
  1578. smalltalk.addMethod(
  1579. smalltalk.method({
  1580. selector: "interpret:continue:",
  1581. category: 'interpreting',
  1582. fn: function (aNode,aBlock){
  1583. var self=this;
  1584. return smalltalk.withContext(function($ctx1) {
  1585. self["@nextNode"]=aNode;
  1586. self["@continuation"]=(function(){
  1587. return smalltalk.withContext(function($ctx2) {
  1588. return smalltalk.ASTInterpreter.fn.prototype._interpret_continue_.apply(_st(self), [aNode,aBlock]);
  1589. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  1590. return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock},smalltalk.ASTSteppingInterpreter)})},
  1591. args: ["aNode", "aBlock"],
  1592. source: "interpret: aNode continue: aBlock\x0a\x09nextNode := aNode.\x0a\x09continuation := [\x0a\x09\x09super interpret: aNode continue: aBlock ]",
  1593. messageSends: ["interpret:continue:"],
  1594. referencedClasses: []
  1595. }),
  1596. smalltalk.ASTSteppingInterpreter);
  1597. smalltalk.addMethod(
  1598. smalltalk.method({
  1599. selector: "nextNode",
  1600. category: 'accessing',
  1601. fn: function (){
  1602. var self=this;
  1603. return smalltalk.withContext(function($ctx1) {
  1604. var $1;
  1605. $1=self["@nextNode"];
  1606. return $1;
  1607. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTSteppingInterpreter)})},
  1608. args: [],
  1609. source: "nextNode\x0a\x09^ nextNode",
  1610. messageSends: [],
  1611. referencedClasses: []
  1612. }),
  1613. smalltalk.ASTSteppingInterpreter);
  1614. smalltalk.addMethod(
  1615. smalltalk.method({
  1616. selector: "step",
  1617. category: 'stepping',
  1618. fn: function (){
  1619. var self=this;
  1620. return smalltalk.withContext(function($ctx1) {
  1621. _st(self["@continuation"])._value();
  1622. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTSteppingInterpreter)})},
  1623. args: [],
  1624. source: "step\x0a\x09continuation value",
  1625. messageSends: ["value"],
  1626. referencedClasses: []
  1627. }),
  1628. smalltalk.ASTSteppingInterpreter);
  1629. smalltalk.addClass('ASTPCNodeVisitor', smalltalk.NodeVisitor, ['useInlinings', 'pc', 'context', 'currentNode'], 'Compiler-Interpreter');
  1630. smalltalk.ASTPCNodeVisitor.comment="I visit an AST until I get to the current pc node and answer it.\x0a\x0a## API\x0a\x0aMy instances must be filled with a context object using `#context:`.\x0a\x0aAfter visiting the AST the current node corresponding to the `pc` is answered by `#currentNode`";
  1631. smalltalk.addMethod(
  1632. smalltalk.method({
  1633. selector: "context",
  1634. category: 'accessing',
  1635. fn: function (){
  1636. var self=this;
  1637. return smalltalk.withContext(function($ctx1) {
  1638. var $1;
  1639. $1=self["@context"];
  1640. return $1;
  1641. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTPCNodeVisitor)})},
  1642. args: [],
  1643. source: "context\x0a\x09^ context",
  1644. messageSends: [],
  1645. referencedClasses: []
  1646. }),
  1647. smalltalk.ASTPCNodeVisitor);
  1648. smalltalk.addMethod(
  1649. smalltalk.method({
  1650. selector: "context:",
  1651. category: 'accessing',
  1652. fn: function (aContext){
  1653. var self=this;
  1654. return smalltalk.withContext(function($ctx1) {
  1655. self["@context"]=aContext;
  1656. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTPCNodeVisitor)})},
  1657. args: ["aContext"],
  1658. source: "context: aContext\x0a\x09context := aContext",
  1659. messageSends: [],
  1660. referencedClasses: []
  1661. }),
  1662. smalltalk.ASTPCNodeVisitor);
  1663. smalltalk.addMethod(
  1664. smalltalk.method({
  1665. selector: "currentNode",
  1666. category: 'accessing',
  1667. fn: function (){
  1668. var self=this;
  1669. return smalltalk.withContext(function($ctx1) {
  1670. var $1;
  1671. $1=self["@currentNode"];
  1672. return $1;
  1673. }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTPCNodeVisitor)})},
  1674. args: [],
  1675. source: "currentNode\x0a\x09^ currentNode",
  1676. messageSends: [],
  1677. referencedClasses: []
  1678. }),
  1679. smalltalk.ASTPCNodeVisitor);
  1680. smalltalk.addMethod(
  1681. smalltalk.method({
  1682. selector: "pc",
  1683. category: 'accessing',
  1684. fn: function (){
  1685. var self=this;
  1686. return smalltalk.withContext(function($ctx1) {
  1687. var $2,$1;
  1688. $2=self["@pc"];
  1689. if(($receiver = $2) == nil || $receiver == undefined){
  1690. $1=(0);
  1691. } else {
  1692. $1=$2;
  1693. };
  1694. return $1;
  1695. }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.ASTPCNodeVisitor)})},
  1696. args: [],
  1697. source: "pc\x0a\x09^ pc ifNil: [ 0 ]",
  1698. messageSends: ["ifNil:"],
  1699. referencedClasses: []
  1700. }),
  1701. smalltalk.ASTPCNodeVisitor);
  1702. smalltalk.addMethod(
  1703. smalltalk.method({
  1704. selector: "pc:",
  1705. category: 'accessing',
  1706. fn: function (anInteger){
  1707. var self=this;
  1708. return smalltalk.withContext(function($ctx1) {
  1709. self["@pc"]=anInteger;
  1710. return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitor)})},
  1711. args: ["anInteger"],
  1712. source: "pc: anInteger\x0a\x09pc := anInteger",
  1713. messageSends: [],
  1714. referencedClasses: []
  1715. }),
  1716. smalltalk.ASTPCNodeVisitor);
  1717. smalltalk.addMethod(
  1718. smalltalk.method({
  1719. selector: "useInlinings",
  1720. category: 'accessing',
  1721. fn: function (){
  1722. var self=this;
  1723. return smalltalk.withContext(function($ctx1) {
  1724. var $2,$1;
  1725. $2=self["@useInlinings"];
  1726. if(($receiver = $2) == nil || $receiver == undefined){
  1727. $1=true;
  1728. } else {
  1729. $1=$2;
  1730. };
  1731. return $1;
  1732. }, function($ctx1) {$ctx1.fill(self,"useInlinings",{},smalltalk.ASTPCNodeVisitor)})},
  1733. args: [],
  1734. source: "useInlinings\x0a\x09^ useInlinings ifNil: [ true ]",
  1735. messageSends: ["ifNil:"],
  1736. referencedClasses: []
  1737. }),
  1738. smalltalk.ASTPCNodeVisitor);
  1739. smalltalk.addMethod(
  1740. smalltalk.method({
  1741. selector: "useInlinings:",
  1742. category: 'accessing',
  1743. fn: function (aBoolean){
  1744. var self=this;
  1745. return smalltalk.withContext(function($ctx1) {
  1746. self["@useInlinings"]=aBoolean;
  1747. return self}, function($ctx1) {$ctx1.fill(self,"useInlinings:",{aBoolean:aBoolean},smalltalk.ASTPCNodeVisitor)})},
  1748. args: ["aBoolean"],
  1749. source: "useInlinings: aBoolean\x0a\x09useInlinings := aBoolean",
  1750. messageSends: [],
  1751. referencedClasses: []
  1752. }),
  1753. smalltalk.ASTPCNodeVisitor);
  1754. smalltalk.addMethod(
  1755. smalltalk.method({
  1756. selector: "visitJSStatementNode:",
  1757. category: 'visiting',
  1758. fn: function (aNode){
  1759. var self=this;
  1760. return smalltalk.withContext(function($ctx1) {
  1761. self["@currentNode"]=aNode;
  1762. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  1763. args: ["aNode"],
  1764. source: "visitJSStatementNode: aNode\x0a\x09currentNode := aNode",
  1765. messageSends: [],
  1766. referencedClasses: []
  1767. }),
  1768. smalltalk.ASTPCNodeVisitor);
  1769. smalltalk.addMethod(
  1770. smalltalk.method({
  1771. selector: "visitSendNode:",
  1772. category: 'visiting',
  1773. fn: function (aNode){
  1774. var self=this;
  1775. return smalltalk.withContext(function($ctx1) {
  1776. var $1,$2;
  1777. smalltalk.NodeVisitor.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  1778. $1=_st(self._pc()).__eq(_st(self._context())._pc());
  1779. if(! smalltalk.assert($1)){
  1780. $2=_st(aNode)._shouldBeInlined();
  1781. if(! smalltalk.assert($2)){
  1782. self._pc_(_st(self._pc()).__plus((1)));
  1783. self["@currentNode"]=aNode;
  1784. self["@currentNode"];
  1785. };
  1786. };
  1787. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
  1788. args: ["aNode"],
  1789. source: "visitSendNode: aNode\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self pc = self context pc ifFalse: [\x0a\x09\x09aNode shouldBeInlined ifFalse: [ \x0a\x09\x09\x09self pc: self pc + 1.\x0a\x09\x09\x09currentNode := aNode ] ]",
  1790. messageSends: ["visitSendNode:", "ifFalse:", "pc:", "+", "pc", "shouldBeInlined", "=", "context"],
  1791. referencedClasses: []
  1792. }),
  1793. smalltalk.ASTPCNodeVisitor);
  1794. smalltalk.addClass('Interpreter', smalltalk.NodeVisitor, ['node', 'context', 'stack', 'returnValue'], 'Compiler-Interpreter');
  1795. smalltalk.addMethod(
  1796. smalltalk.method({
  1797. selector: "assign:to:",
  1798. category: 'private',
  1799. fn: function (aNode,anObject){
  1800. var self=this;
  1801. return smalltalk.withContext(function($ctx1) {
  1802. var $1;
  1803. $1=_st(_st(aNode)._binding())._isInstanceVar();
  1804. if(smalltalk.assert($1)){
  1805. _st(_st(self._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
  1806. } else {
  1807. _st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
  1808. };
  1809. return self}, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.Interpreter)})},
  1810. args: ["aNode", "anObject"],
  1811. source: "assign: aNode to: anObject\x0a\x09aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value put: anObject ]",
  1812. messageSends: ["ifTrue:ifFalse:", "instVarAt:put:", "value", "receiver", "context", "localAt:put:", "isInstanceVar", "binding"],
  1813. referencedClasses: []
  1814. }),
  1815. smalltalk.Interpreter);
  1816. smalltalk.addMethod(
  1817. smalltalk.method({
  1818. selector: "atEnd",
  1819. category: 'testing',
  1820. fn: function (){
  1821. var self=this;
  1822. return smalltalk.withContext(function($ctx1) {
  1823. var $1;
  1824. $1=_st(self._shouldReturn())._or_((function(){
  1825. return smalltalk.withContext(function($ctx2) {
  1826. return _st(self._node())._isNil();
  1827. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1828. return $1;
  1829. }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.Interpreter)})},
  1830. args: [],
  1831. source: "atEnd\x0a\x09^ self shouldReturn or: [ self node isNil ]",
  1832. messageSends: ["or:", "isNil", "node", "shouldReturn"],
  1833. referencedClasses: []
  1834. }),
  1835. smalltalk.Interpreter);
  1836. smalltalk.addMethod(
  1837. smalltalk.method({
  1838. selector: "context",
  1839. category: 'accessing',
  1840. fn: function (){
  1841. var self=this;
  1842. return smalltalk.withContext(function($ctx1) {
  1843. var $1;
  1844. $1=self["@context"];
  1845. return $1;
  1846. }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.Interpreter)})},
  1847. args: [],
  1848. source: "context\x0a\x09^ context",
  1849. messageSends: [],
  1850. referencedClasses: []
  1851. }),
  1852. smalltalk.Interpreter);
  1853. smalltalk.addMethod(
  1854. smalltalk.method({
  1855. selector: "context:",
  1856. category: 'accessing',
  1857. fn: function (aContext){
  1858. var self=this;
  1859. return smalltalk.withContext(function($ctx1) {
  1860. self["@context"]=aContext;
  1861. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.Interpreter)})},
  1862. args: ["aContext"],
  1863. source: "context: aContext\x0a\x09context := aContext",
  1864. messageSends: [],
  1865. referencedClasses: []
  1866. }),
  1867. smalltalk.Interpreter);
  1868. smalltalk.addMethod(
  1869. smalltalk.method({
  1870. selector: "eval:",
  1871. category: 'private',
  1872. fn: function (aString){
  1873. var self=this;
  1874. var source,function_;
  1875. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  1876. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  1877. return smalltalk.withContext(function($ctx1) {
  1878. var $1,$2,$3;
  1879. source=_st($String())._streamContents_((function(str){
  1880. return smalltalk.withContext(function($ctx2) {
  1881. _st(str)._nextPutAll_("(function(");
  1882. _st(_st(_st(self._context())._locals())._keys())._do_separatedBy_((function(each){
  1883. return smalltalk.withContext(function($ctx3) {
  1884. return _st(str)._nextPutAll_(each);
  1885. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2)})}),(function(){
  1886. return smalltalk.withContext(function($ctx3) {
  1887. return _st(str)._nextPutAll_(",");
  1888. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  1889. $1=str;
  1890. _st($1)._nextPutAll_("){ return (function() {");
  1891. _st($1)._nextPutAll_(aString);
  1892. $2=_st($1)._nextPutAll_("})() })");
  1893. return $2;
  1894. }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
  1895. function_=_st(_st($Compiler())._new())._eval_(source);
  1896. $3=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
  1897. return $3;
  1898. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.Interpreter)})},
  1899. args: ["aString"],
  1900. 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",
  1901. messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
  1902. referencedClasses: ["String", "Compiler"]
  1903. }),
  1904. smalltalk.Interpreter);
  1905. smalltalk.addMethod(
  1906. smalltalk.method({
  1907. selector: "interpret",
  1908. category: 'interpreting',
  1909. fn: function (){
  1910. var self=this;
  1911. return smalltalk.withContext(function($ctx1) {
  1912. self._visit_(self._node());
  1913. return self}, function($ctx1) {$ctx1.fill(self,"interpret",{},smalltalk.Interpreter)})},
  1914. args: [],
  1915. source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
  1916. messageSends: ["visit:", "node"],
  1917. referencedClasses: []
  1918. }),
  1919. smalltalk.Interpreter);
  1920. smalltalk.addMethod(
  1921. smalltalk.method({
  1922. selector: "interpret:",
  1923. category: 'interpreting',
  1924. fn: function (aNode){
  1925. var self=this;
  1926. return smalltalk.withContext(function($ctx1) {
  1927. self._node_(aNode);
  1928. self._interpret();
  1929. return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.Interpreter)})},
  1930. args: ["aNode"],
  1931. source: "interpret: aNode\x0a\x09self node: aNode.\x0a\x09self interpret",
  1932. messageSends: ["node:", "interpret"],
  1933. referencedClasses: []
  1934. }),
  1935. smalltalk.Interpreter);
  1936. smalltalk.addMethod(
  1937. smalltalk.method({
  1938. selector: "messageFromSendNode:arguments:",
  1939. category: 'private',
  1940. fn: function (aSendNode,aCollection){
  1941. var self=this;
  1942. function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
  1943. return smalltalk.withContext(function($ctx1) {
  1944. var $2,$3,$1;
  1945. $2=_st($Message())._new();
  1946. _st($2)._selector_(_st(aSendNode)._selector());
  1947. _st($2)._arguments_(aCollection);
  1948. $3=_st($2)._yourself();
  1949. $1=$3;
  1950. return $1;
  1951. }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},smalltalk.Interpreter)})},
  1952. args: ["aSendNode", "aCollection"],
  1953. source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
  1954. messageSends: ["selector:", "selector", "new", "arguments:", "yourself"],
  1955. referencedClasses: ["Message"]
  1956. }),
  1957. smalltalk.Interpreter);
  1958. smalltalk.addMethod(
  1959. smalltalk.method({
  1960. selector: "messageNotUnderstood:receiver:",
  1961. category: 'private',
  1962. fn: function (aMessage,anObject){
  1963. var self=this;
  1964. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  1965. return smalltalk.withContext(function($ctx1) {
  1966. var $1,$2;
  1967. $1=_st($MessageNotUnderstood())._new();
  1968. _st($1)._meesage_(aMessage);
  1969. _st($1)._receiver_(anObject);
  1970. $2=_st($1)._signal();
  1971. return self}, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},smalltalk.Interpreter)})},
  1972. args: ["aMessage", "anObject"],
  1973. source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09meesage: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
  1974. messageSends: ["meesage:", "new", "receiver:", "signal"],
  1975. referencedClasses: ["MessageNotUnderstood"]
  1976. }),
  1977. smalltalk.Interpreter);
  1978. smalltalk.addMethod(
  1979. smalltalk.method({
  1980. selector: "next",
  1981. category: 'interpreting',
  1982. fn: function (){
  1983. var self=this;
  1984. return smalltalk.withContext(function($ctx1) {
  1985. self._node_(_st(self._node())._nextNode());
  1986. return self}, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.Interpreter)})},
  1987. args: [],
  1988. source: "next\x0a\x09self node: self node nextNode",
  1989. messageSends: ["node:", "nextNode", "node"],
  1990. referencedClasses: []
  1991. }),
  1992. smalltalk.Interpreter);
  1993. smalltalk.addMethod(
  1994. smalltalk.method({
  1995. selector: "node",
  1996. category: 'accessing',
  1997. fn: function (){
  1998. var self=this;
  1999. return smalltalk.withContext(function($ctx1) {
  2000. var $1;
  2001. $1=self["@node"];
  2002. return $1;
  2003. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.Interpreter)})},
  2004. args: [],
  2005. source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
  2006. messageSends: [],
  2007. referencedClasses: []
  2008. }),
  2009. smalltalk.Interpreter);
  2010. smalltalk.addMethod(
  2011. smalltalk.method({
  2012. selector: "node:",
  2013. category: 'accessing',
  2014. fn: function (aNode){
  2015. var self=this;
  2016. return smalltalk.withContext(function($ctx1) {
  2017. self["@node"]=aNode;
  2018. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.Interpreter)})},
  2019. args: ["aNode"],
  2020. source: "node: aNode\x0a\x09node := aNode",
  2021. messageSends: [],
  2022. referencedClasses: []
  2023. }),
  2024. smalltalk.Interpreter);
  2025. smalltalk.addMethod(
  2026. smalltalk.method({
  2027. selector: "peek",
  2028. category: 'stack',
  2029. fn: function (){
  2030. var self=this;
  2031. return smalltalk.withContext(function($ctx1) {
  2032. var $1;
  2033. $1=_st(self._stack())._last();
  2034. return $1;
  2035. }, function($ctx1) {$ctx1.fill(self,"peek",{},smalltalk.Interpreter)})},
  2036. args: [],
  2037. source: "peek\x0a\x09\x22Peek the top object of the context stack\x22\x0a\x09\x0a\x09^ self stack last",
  2038. messageSends: ["last", "stack"],
  2039. referencedClasses: []
  2040. }),
  2041. smalltalk.Interpreter);
  2042. smalltalk.addMethod(
  2043. smalltalk.method({
  2044. selector: "pop",
  2045. category: 'stack',
  2046. fn: function (){
  2047. var self=this;
  2048. var value;
  2049. return smalltalk.withContext(function($ctx1) {
  2050. var $1;
  2051. value=self._peek();
  2052. _st(self._stack())._removeLast();
  2053. $1=value;
  2054. return $1;
  2055. }, function($ctx1) {$ctx1.fill(self,"pop",{value:value},smalltalk.Interpreter)})},
  2056. args: [],
  2057. source: "pop\x0a\x09\x22Pop an object from the context stack\x22\x0a\x09\x0a\x09| value |\x0a\x09\x0a\x09value := self peek.\x0a\x09self stack removeLast.\x0a\x09^ value",
  2058. messageSends: ["peek", "removeLast", "stack"],
  2059. referencedClasses: []
  2060. }),
  2061. smalltalk.Interpreter);
  2062. smalltalk.addMethod(
  2063. smalltalk.method({
  2064. selector: "proceed",
  2065. category: 'interpreting',
  2066. fn: function (){
  2067. var self=this;
  2068. return smalltalk.withContext(function($ctx1) {
  2069. _st((function(){
  2070. return smalltalk.withContext(function($ctx2) {
  2071. return self._atEnd();
  2072. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  2073. return smalltalk.withContext(function($ctx2) {
  2074. return self._step();
  2075. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2076. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.Interpreter)})},
  2077. args: [],
  2078. source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] whileFalse: [ \x0a\x09\x09self step ]",
  2079. messageSends: ["whileFalse:", "atEnd", "step"],
  2080. referencedClasses: []
  2081. }),
  2082. smalltalk.Interpreter);
  2083. smalltalk.addMethod(
  2084. smalltalk.method({
  2085. selector: "push:",
  2086. category: 'stack',
  2087. fn: function (anObject){
  2088. var self=this;
  2089. return smalltalk.withContext(function($ctx1) {
  2090. var $1;
  2091. $1=_st(self._stack())._add_(anObject);
  2092. return $1;
  2093. }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},smalltalk.Interpreter)})},
  2094. args: ["anObject"],
  2095. source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
  2096. messageSends: ["add:", "stack"],
  2097. referencedClasses: []
  2098. }),
  2099. smalltalk.Interpreter);
  2100. smalltalk.addMethod(
  2101. smalltalk.method({
  2102. selector: "restart",
  2103. category: 'interpreting',
  2104. fn: function (){
  2105. var self=this;
  2106. return smalltalk.withContext(function($ctx1) {
  2107. self._node_(_st(_st(self._context())._ast())._nextChild());
  2108. return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.Interpreter)})},
  2109. args: [],
  2110. source: "restart\x0a\x09self node: self context ast nextChild",
  2111. messageSends: ["node:", "nextChild", "ast", "context"],
  2112. referencedClasses: []
  2113. }),
  2114. smalltalk.Interpreter);
  2115. smalltalk.addMethod(
  2116. smalltalk.method({
  2117. selector: "result",
  2118. category: 'accessing',
  2119. fn: function (){
  2120. var self=this;
  2121. return smalltalk.withContext(function($ctx1) {
  2122. var $2,$1;
  2123. $2=self._returnValue();
  2124. if(($receiver = $2) == nil || $receiver == undefined){
  2125. $1=_st(self._context())._receiver();
  2126. } else {
  2127. $1=$2;
  2128. };
  2129. return $1;
  2130. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.Interpreter)})},
  2131. args: [],
  2132. source: "result\x0a\x09^ self returnValue ifNil: [ self context receiver ]",
  2133. messageSends: ["ifNil:", "returnValue", "receiver", "context"],
  2134. referencedClasses: []
  2135. }),
  2136. smalltalk.Interpreter);
  2137. smalltalk.addMethod(
  2138. smalltalk.method({
  2139. selector: "returnValue",
  2140. category: 'accessing',
  2141. fn: function (){
  2142. var self=this;
  2143. return smalltalk.withContext(function($ctx1) {
  2144. var $1;
  2145. $1=self["@returnValue"];
  2146. return $1;
  2147. }, function($ctx1) {$ctx1.fill(self,"returnValue",{},smalltalk.Interpreter)})},
  2148. args: [],
  2149. source: "returnValue\x0a\x09^ returnValue",
  2150. messageSends: [],
  2151. referencedClasses: []
  2152. }),
  2153. smalltalk.Interpreter);
  2154. smalltalk.addMethod(
  2155. smalltalk.method({
  2156. selector: "returnValue:",
  2157. category: 'accessing',
  2158. fn: function (anObject){
  2159. var self=this;
  2160. return smalltalk.withContext(function($ctx1) {
  2161. self["@returnValue"]=anObject;
  2162. return self}, function($ctx1) {$ctx1.fill(self,"returnValue:",{anObject:anObject},smalltalk.Interpreter)})},
  2163. args: ["anObject"],
  2164. source: "returnValue: anObject\x0a\x09returnValue := anObject",
  2165. messageSends: [],
  2166. referencedClasses: []
  2167. }),
  2168. smalltalk.Interpreter);
  2169. smalltalk.addMethod(
  2170. smalltalk.method({
  2171. selector: "sendMessage:to:superSend:",
  2172. category: 'private',
  2173. fn: function (aMessage,anObject,aBoolean){
  2174. var self=this;
  2175. var method;
  2176. return smalltalk.withContext(function($ctx1) {
  2177. var $1,$2,$3,$4,$5,$6;
  2178. var $early={};
  2179. try {
  2180. $1=aBoolean;
  2181. if(! smalltalk.assert($1)){
  2182. $2=_st(aMessage)._sendTo_(anObject);
  2183. return $2;
  2184. };
  2185. $3=_st(_st(anObject)._class())._superclass();
  2186. if(($receiver = $3) == nil || $receiver == undefined){
  2187. $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
  2188. return $4;
  2189. } else {
  2190. $3;
  2191. };
  2192. method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
  2193. return smalltalk.withContext(function($ctx2) {
  2194. $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
  2195. throw $early=[$5];
  2196. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2197. $6=_st(method)._sendTo_arguments_(anObject,_st(aMessage)._arguments());
  2198. return $6;
  2199. }
  2200. catch(e) {if(e===$early)return e[0]; throw e}
  2201. }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.Interpreter)})},
  2202. args: ["aMessage", "anObject", "aBoolean"],
  2203. source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method sendTo: anObject arguments: aMessage arguments",
  2204. messageSends: ["ifFalse:", "sendTo:", "ifNil:", "messageNotUnderstood:receiver:", "superclass", "class", "at:ifAbsent:", "selector", "methodDictionary", "sendTo:arguments:", "arguments"],
  2205. referencedClasses: []
  2206. }),
  2207. smalltalk.Interpreter);
  2208. smalltalk.addMethod(
  2209. smalltalk.method({
  2210. selector: "shouldReturn",
  2211. category: 'testing',
  2212. fn: function (){
  2213. var self=this;
  2214. return smalltalk.withContext(function($ctx1) {
  2215. var $1;
  2216. $1=_st(self._returnValue())._notNil();
  2217. return $1;
  2218. }, function($ctx1) {$ctx1.fill(self,"shouldReturn",{},smalltalk.Interpreter)})},
  2219. args: [],
  2220. source: "shouldReturn\x0a\x09^ self returnValue notNil",
  2221. messageSends: ["notNil", "returnValue"],
  2222. referencedClasses: []
  2223. }),
  2224. smalltalk.Interpreter);
  2225. smalltalk.addMethod(
  2226. smalltalk.method({
  2227. selector: "skip",
  2228. category: 'interpreting',
  2229. fn: function (){
  2230. var self=this;
  2231. return smalltalk.withContext(function($ctx1) {
  2232. self._next();
  2233. return self}, function($ctx1) {$ctx1.fill(self,"skip",{},smalltalk.Interpreter)})},
  2234. args: [],
  2235. source: "skip\x0a\x09self next",
  2236. messageSends: ["next"],
  2237. referencedClasses: []
  2238. }),
  2239. smalltalk.Interpreter);
  2240. smalltalk.addMethod(
  2241. smalltalk.method({
  2242. selector: "stack",
  2243. category: 'accessing',
  2244. fn: function (){
  2245. var self=this;
  2246. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  2247. return smalltalk.withContext(function($ctx1) {
  2248. var $2,$1;
  2249. $2=self["@stack"];
  2250. if(($receiver = $2) == nil || $receiver == undefined){
  2251. self["@stack"]=_st($OrderedCollection())._new();
  2252. $1=self["@stack"];
  2253. } else {
  2254. $1=$2;
  2255. };
  2256. return $1;
  2257. }, function($ctx1) {$ctx1.fill(self,"stack",{},smalltalk.Interpreter)})},
  2258. args: [],
  2259. source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
  2260. messageSends: ["ifNil:", "new"],
  2261. referencedClasses: ["OrderedCollection"]
  2262. }),
  2263. smalltalk.Interpreter);
  2264. smalltalk.addMethod(
  2265. smalltalk.method({
  2266. selector: "step",
  2267. category: 'interpreting',
  2268. fn: function (){
  2269. var self=this;
  2270. return smalltalk.withContext(function($ctx1) {
  2271. var $1,$2;
  2272. $1=self;
  2273. _st($1)._interpret();
  2274. $2=_st($1)._next();
  2275. return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.Interpreter)})},
  2276. args: [],
  2277. source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
  2278. messageSends: ["interpret", "next"],
  2279. referencedClasses: []
  2280. }),
  2281. smalltalk.Interpreter);
  2282. smalltalk.addMethod(
  2283. smalltalk.method({
  2284. selector: "stepOver",
  2285. category: 'interpreting',
  2286. fn: function (){
  2287. var self=this;
  2288. return smalltalk.withContext(function($ctx1) {
  2289. self._step();
  2290. _st((function(){
  2291. return smalltalk.withContext(function($ctx2) {
  2292. return _st(self._node())._isSteppingNode();
  2293. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  2294. return smalltalk.withContext(function($ctx2) {
  2295. return self._step();
  2296. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2297. return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.Interpreter)})},
  2298. args: [],
  2299. source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isSteppingNode ] whileFalse: [ \x0a\x09\x09self step ]",
  2300. messageSends: ["step", "whileFalse:", "isSteppingNode", "node"],
  2301. referencedClasses: []
  2302. }),
  2303. smalltalk.Interpreter);
  2304. smalltalk.addMethod(
  2305. smalltalk.method({
  2306. selector: "visit:",
  2307. category: 'visiting',
  2308. fn: function (aNode){
  2309. var self=this;
  2310. return smalltalk.withContext(function($ctx1) {
  2311. var $1;
  2312. $1=self._shouldReturn();
  2313. if(! smalltalk.assert($1)){
  2314. smalltalk.NodeVisitor.fn.prototype._visit_.apply(_st(self), [aNode]);
  2315. };
  2316. return self}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},smalltalk.Interpreter)})},
  2317. args: ["aNode"],
  2318. source: "visit: aNode\x0a\x09self shouldReturn ifFalse: [ super visit: aNode ]",
  2319. messageSends: ["ifFalse:", "visit:", "shouldReturn"],
  2320. referencedClasses: []
  2321. }),
  2322. smalltalk.Interpreter);
  2323. smalltalk.addMethod(
  2324. smalltalk.method({
  2325. selector: "visitAssignmentNode:",
  2326. category: 'visiting',
  2327. fn: function (aNode){
  2328. var self=this;
  2329. var value;
  2330. return smalltalk.withContext(function($ctx1) {
  2331. value=self._pop();
  2332. self._pop();
  2333. self._push_(value);
  2334. self._assign_to_(_st(aNode)._left(),value);
  2335. return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,value:value},smalltalk.Interpreter)})},
  2336. args: ["aNode"],
  2337. source: "visitAssignmentNode: aNode\x0a\x09| value |\x0a\x09\x0a\x09value := self pop.\x0a\x09\x0a\x09\x22Pop the left side of the assignment.\x0a\x09It already has been visited, and we don't need its value.\x22\x0a\x09self pop.\x0a\x09\x0a\x09self push: value.\x0a\x09self assign: aNode left to: value",
  2338. messageSends: ["pop", "push:", "assign:to:", "left"],
  2339. referencedClasses: []
  2340. }),
  2341. smalltalk.Interpreter);
  2342. smalltalk.addMethod(
  2343. smalltalk.method({
  2344. selector: "visitBlockNode:",
  2345. category: 'visiting',
  2346. fn: function (aNode){
  2347. var self=this;
  2348. var blockNode,blockContext,block,interpreter;
  2349. return smalltalk.withContext(function($ctx1) {
  2350. var $1,$2,$3,$4,$5;
  2351. blockNode=_st(_st(_st(aNode)._nodes())._first())._copy();
  2352. _st(blockNode)._parent_(nil);
  2353. $1=_st(_st(self._context())._class())._new();
  2354. _st($1)._outerContext_(self._context());
  2355. $2=_st($1)._yourself();
  2356. blockContext=$2;
  2357. block=(function(){
  2358. return smalltalk.withContext(function($ctx2) {
  2359. interpreter=_st(self._class())._new();
  2360. interpreter;
  2361. $3=interpreter;
  2362. _st($3)._context_(blockContext);
  2363. _st($3)._node_(_st(blockNode)._nextChild());
  2364. $4=_st($3)._proceed();
  2365. $4;
  2366. self._returnValue_(_st(interpreter)._returnValue());
  2367. $5=_st(_st(interpreter)._stack())._isEmpty();
  2368. if(smalltalk.assert($5)){
  2369. return nil;
  2370. } else {
  2371. return _st(interpreter)._pop();
  2372. };
  2373. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  2374. self._push_(block);
  2375. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,blockNode:blockNode,blockContext:blockContext,block:block,interpreter:interpreter},smalltalk.Interpreter)})},
  2376. args: ["aNode"],
  2377. source: "visitBlockNode: aNode\x0a\x09\x22Do not evaluate the block node.\x0a\x09Instead, put all instructions into a block that we push to the stack for later evaluation\x22\x0a\x09\x0a\x09| blockNode blockContext block interpreter |\x0a\x09\x0a\x09\x22Copy the sequence node without the parent to avoid evaluating nodes up the block. \x0a\x09#nextNode should not go anymore up than the block itself\x22\x0a\x09blockNode := aNode nodes first copy.\x0a\x09blockNode parent: nil.\x0a\x09\x09\x0a\x09blockContext := self context class new\x0a\x09\x09outerContext: self context;\x0a\x09\x09yourself.\x0a\x09\x0a\x09block := [\x0a\x09\x09interpreter := self class new.\x0a\x09\x09interpreter\x0a\x09\x09\x09context: blockContext;\x0a\x09\x09\x09node: blockNode nextChild;\x0a\x09\x09\x09proceed.\x0a\x09\x09\x0a\x09\x09\x22Non local returns hanlding\x22\x0a\x09\x09self returnValue: interpreter returnValue.\x0a\x09\x09\x0a\x09\x09\x22Answer the last evaluation of the block or nil\x22\x0a\x09\x09interpreter stack isEmpty\x0a\x09\x09\x09ifTrue: [ nil ]\x0a\x09\x09\x09ifFalse: [ interpreter pop ] ].\x0a\x09\x0a\x09self push: block",
  2378. messageSends: ["copy", "first", "nodes", "parent:", "outerContext:", "new", "class", "context", "yourself", "context:", "node:", "nextChild", "proceed", "returnValue:", "returnValue", "ifTrue:ifFalse:", "isEmpty", "stack", "pop", "push:"],
  2379. referencedClasses: []
  2380. }),
  2381. smalltalk.Interpreter);
  2382. smalltalk.addMethod(
  2383. smalltalk.method({
  2384. selector: "visitClassReferenceNode:",
  2385. category: 'visiting',
  2386. fn: function (aNode){
  2387. var self=this;
  2388. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  2389. return smalltalk.withContext(function($ctx1) {
  2390. self._push_(_st(_st($Smalltalk())._current())._at_(_st(aNode)._value()));
  2391. return self}, function($ctx1) {$ctx1.fill(self,"visitClassReferenceNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2392. args: ["aNode"],
  2393. source: "visitClassReferenceNode: aNode\x0a\x09self push: (Smalltalk current at: aNode value)",
  2394. messageSends: ["push:", "at:", "value", "current"],
  2395. referencedClasses: ["Smalltalk"]
  2396. }),
  2397. smalltalk.Interpreter);
  2398. smalltalk.addMethod(
  2399. smalltalk.method({
  2400. selector: "visitDynamicArrayNode:",
  2401. category: 'visiting',
  2402. fn: function (aNode){
  2403. var self=this;
  2404. var array;
  2405. return smalltalk.withContext(function($ctx1) {
  2406. array=[];
  2407. _st(_st(aNode)._nodes())._do_((function(each){
  2408. return smalltalk.withContext(function($ctx2) {
  2409. return _st(array)._addFirst_(self._pop());
  2410. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  2411. self._push_(array);
  2412. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},smalltalk.Interpreter)})},
  2413. args: ["aNode"],
  2414. source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09\x0a\x09array := #().\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09array addFirst: self pop ].\x0a\x09\x0a\x09self push: array",
  2415. messageSends: ["do:", "nodes", "addFirst:", "pop", "push:"],
  2416. referencedClasses: []
  2417. }),
  2418. smalltalk.Interpreter);
  2419. smalltalk.addMethod(
  2420. smalltalk.method({
  2421. selector: "visitDynamicDictionaryNode:",
  2422. category: 'visiting',
  2423. fn: function (aNode){
  2424. var self=this;
  2425. var hashedCollection;
  2426. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  2427. return smalltalk.withContext(function($ctx1) {
  2428. hashedCollection=_st($HashedCollection())._new();
  2429. _st(_st(aNode)._nodes())._do_((function(each){
  2430. return smalltalk.withContext(function($ctx2) {
  2431. return _st(hashedCollection)._add_(self._pop());
  2432. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  2433. self._push_(hashedCollection);
  2434. return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,hashedCollection:hashedCollection},smalltalk.Interpreter)})},
  2435. args: ["aNode"],
  2436. source: "visitDynamicDictionaryNode: aNode\x0a\x09| hashedCollection |\x0a\x09\x0a\x09hashedCollection := HashedCollection new.\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09hashedCollection add: self pop ].\x0a\x09\x0a\x09self push: hashedCollection",
  2437. messageSends: ["new", "do:", "nodes", "add:", "pop", "push:"],
  2438. referencedClasses: ["HashedCollection"]
  2439. }),
  2440. smalltalk.Interpreter);
  2441. smalltalk.addMethod(
  2442. smalltalk.method({
  2443. selector: "visitJSStatementNode:",
  2444. category: 'visiting',
  2445. fn: function (aNode){
  2446. var self=this;
  2447. return smalltalk.withContext(function($ctx1) {
  2448. self._returnValue_(self._eval_(_st(aNode)._source()));
  2449. return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2450. args: ["aNode"],
  2451. source: "visitJSStatementNode: aNode\x0a\x09self returnValue: (self eval: aNode source)",
  2452. messageSends: ["returnValue:", "eval:", "source"],
  2453. referencedClasses: []
  2454. }),
  2455. smalltalk.Interpreter);
  2456. smalltalk.addMethod(
  2457. smalltalk.method({
  2458. selector: "visitNode:",
  2459. category: 'visiting',
  2460. fn: function (aNode){
  2461. var self=this;
  2462. return smalltalk.withContext(function($ctx1) {
  2463. return self}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2464. args: ["aNode"],
  2465. source: "visitNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
  2466. messageSends: [],
  2467. referencedClasses: []
  2468. }),
  2469. smalltalk.Interpreter);
  2470. smalltalk.addMethod(
  2471. smalltalk.method({
  2472. selector: "visitReturnNode:",
  2473. category: 'visiting',
  2474. fn: function (aNode){
  2475. var self=this;
  2476. return smalltalk.withContext(function($ctx1) {
  2477. self._returnValue_(self._pop());
  2478. return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2479. args: ["aNode"],
  2480. source: "visitReturnNode: aNode\x0a\x09self returnValue: self pop",
  2481. messageSends: ["returnValue:", "pop"],
  2482. referencedClasses: []
  2483. }),
  2484. smalltalk.Interpreter);
  2485. smalltalk.addMethod(
  2486. smalltalk.method({
  2487. selector: "visitSendNode:",
  2488. category: 'visiting',
  2489. fn: function (aNode){
  2490. var self=this;
  2491. var receiver,args,message,result;
  2492. return smalltalk.withContext(function($ctx1) {
  2493. var $1;
  2494. args=_st(_st(aNode)._arguments())._collect_((function(each){
  2495. return smalltalk.withContext(function($ctx2) {
  2496. return self._pop();
  2497. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  2498. receiver=self._pop();
  2499. message=self._messageFromSendNode_arguments_(aNode,_st(args)._reversed());
  2500. result=self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend());
  2501. _st(self._context())._pc_(_st(_st(self._context())._pc()).__plus((1)));
  2502. $1=_st(_st(aNode)._isCascadeSendNode())._and_((function(){
  2503. return smalltalk.withContext(function($ctx2) {
  2504. return _st(_st(aNode)._isLastChild())._not();
  2505. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2506. if(smalltalk.assert($1)){
  2507. self._push_(receiver);
  2508. } else {
  2509. self._push_(result);
  2510. };
  2511. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},smalltalk.Interpreter)})},
  2512. args: ["aNode"],
  2513. source: "visitSendNode: aNode\x0a\x09| receiver args message result |\x0a\x09\x0a\x09args := aNode arguments collect: [ :each | self pop ].\x0a\x09receiver := self pop.\x0a\x09\x0a\x09message := self\x0a\x09\x09messageFromSendNode: aNode\x0a\x09\x09arguments: args reversed.\x0a\x09\x0a\x09result := self sendMessage: message to: receiver superSend: aNode superSend.\x0a\x09\x0a\x09self context pc: self context pc + 1.\x0a\x09\x0a\x09\x22For cascade sends, push the reciever if the send is not the last one\x22\x0a\x09(aNode isCascadeSendNode and: [ aNode isLastChild not ])\x0a\x09\x09ifTrue: [ self push: receiver ]\x0a\x09\x09ifFalse: [ self push: result ]",
  2514. messageSends: ["collect:", "arguments", "pop", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "pc:", "context", "+", "pc", "ifTrue:ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"],
  2515. referencedClasses: []
  2516. }),
  2517. smalltalk.Interpreter);
  2518. smalltalk.addMethod(
  2519. smalltalk.method({
  2520. selector: "visitValueNode:",
  2521. category: 'visiting',
  2522. fn: function (aNode){
  2523. var self=this;
  2524. return smalltalk.withContext(function($ctx1) {
  2525. self._push_(_st(aNode)._value());
  2526. return self}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2527. args: ["aNode"],
  2528. source: "visitValueNode: aNode\x0a\x09self push: aNode value",
  2529. messageSends: ["push:", "value"],
  2530. referencedClasses: []
  2531. }),
  2532. smalltalk.Interpreter);
  2533. smalltalk.addMethod(
  2534. smalltalk.method({
  2535. selector: "visitVariableNode:",
  2536. category: 'visiting',
  2537. fn: function (aNode){
  2538. var self=this;
  2539. return smalltalk.withContext(function($ctx1) {
  2540. var $1,$3,$2;
  2541. $1=self;
  2542. $3=_st(_st(aNode)._binding())._isInstanceVar();
  2543. if(smalltalk.assert($3)){
  2544. $2=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
  2545. } else {
  2546. $2=_st(self._context())._localAt_(_st(aNode)._value());
  2547. };
  2548. _st($1)._push_($2);
  2549. return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2550. args: ["aNode"],
  2551. source: "visitVariableNode: aNode\x0a\x09\x22TODO: what about other vars (JS globals for instance)?\x22\x0a\x09\x0a\x09self push: (aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value ])",
  2552. messageSends: ["push:", "ifTrue:ifFalse:", "instVarAt:", "value", "receiver", "context", "localAt:", "isInstanceVar", "binding"],
  2553. referencedClasses: []
  2554. }),
  2555. smalltalk.Interpreter);
  2556. smalltalk.addMethod(
  2557. smalltalk.method({
  2558. selector: "interpreter:continue:",
  2559. category: '*Compiler-Interpreter',
  2560. fn: function (anInterpreter,aBlock){
  2561. var self=this;
  2562. return smalltalk.withContext(function($ctx1) {
  2563. var $1;
  2564. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  2565. return $1;
  2566. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.Node)})},
  2567. args: ["anInterpreter", "aBlock"],
  2568. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  2569. messageSends: ["interpretNode:continue:"],
  2570. referencedClasses: []
  2571. }),
  2572. smalltalk.Node);
  2573. smalltalk.addMethod(
  2574. smalltalk.method({
  2575. selector: "isSteppingNode",
  2576. category: '*Compiler-Interpreter',
  2577. fn: function (){
  2578. var self=this;
  2579. return smalltalk.withContext(function($ctx1) {
  2580. return false;
  2581. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
  2582. args: [],
  2583. source: "isSteppingNode\x0a\x09^ false",
  2584. messageSends: [],
  2585. referencedClasses: []
  2586. }),
  2587. smalltalk.Node);
  2588. smalltalk.addMethod(
  2589. smalltalk.method({
  2590. selector: "interpreter:continue:",
  2591. category: '*Compiler-Interpreter',
  2592. fn: function (anInterpreter,aBlock){
  2593. var self=this;
  2594. return smalltalk.withContext(function($ctx1) {
  2595. var $1;
  2596. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  2597. return $1;
  2598. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.AssignmentNode)})},
  2599. args: ["anInterpreter", "aBlock"],
  2600. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  2601. messageSends: ["interpretAssignmentNode:continue:"],
  2602. referencedClasses: []
  2603. }),
  2604. smalltalk.AssignmentNode);
  2605. smalltalk.addMethod(
  2606. smalltalk.method({
  2607. selector: "isSteppingNode",
  2608. category: '*Compiler-Interpreter',
  2609. fn: function (){
  2610. var self=this;
  2611. return smalltalk.withContext(function($ctx1) {
  2612. return true;
  2613. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.AssignmentNode)})},
  2614. args: [],
  2615. source: "isSteppingNode\x0a\x09^ true",
  2616. messageSends: [],
  2617. referencedClasses: []
  2618. }),
  2619. smalltalk.AssignmentNode);
  2620. smalltalk.addMethod(
  2621. smalltalk.method({
  2622. selector: "interpreter:continue:",
  2623. category: '*Compiler-Interpreter',
  2624. fn: function (anInterpreter,aBlock){
  2625. var self=this;
  2626. return smalltalk.withContext(function($ctx1) {
  2627. var $1;
  2628. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  2629. return $1;
  2630. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockNode)})},
  2631. args: ["anInterpreter", "aBlock"],
  2632. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  2633. messageSends: ["interpretBlockNode:continue:"],
  2634. referencedClasses: []
  2635. }),
  2636. smalltalk.BlockNode);
  2637. smalltalk.addMethod(
  2638. smalltalk.method({
  2639. selector: "isSteppingNode",
  2640. category: '*Compiler-Interpreter',
  2641. fn: function (){
  2642. var self=this;
  2643. return smalltalk.withContext(function($ctx1) {
  2644. return true;
  2645. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
  2646. args: [],
  2647. source: "isSteppingNode\x0a\x09^ true",
  2648. messageSends: [],
  2649. referencedClasses: []
  2650. }),
  2651. smalltalk.BlockNode);
  2652. smalltalk.addMethod(
  2653. smalltalk.method({
  2654. selector: "interpreter:continue:",
  2655. category: '*Compiler-Interpreter',
  2656. fn: function (anInterpreter,aBlock){
  2657. var self=this;
  2658. return smalltalk.withContext(function($ctx1) {
  2659. var $1;
  2660. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  2661. return $1;
  2662. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.CascadeNode)})},
  2663. args: ["anInterpreter", "aBlock"],
  2664. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  2665. messageSends: ["interpretCascadeNode:continue:"],
  2666. referencedClasses: []
  2667. }),
  2668. smalltalk.CascadeNode);
  2669. smalltalk.addMethod(
  2670. smalltalk.method({
  2671. selector: "interpreter:continue:",
  2672. category: '*Compiler-Interpreter',
  2673. fn: function (anInterpreter,aBlock){
  2674. var self=this;
  2675. return smalltalk.withContext(function($ctx1) {
  2676. var $1;
  2677. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  2678. return $1;
  2679. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicArrayNode)})},
  2680. args: ["anInterpreter", "aBlock"],
  2681. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  2682. messageSends: ["interpretDynamicArrayNode:continue:"],
  2683. referencedClasses: []
  2684. }),
  2685. smalltalk.DynamicArrayNode);
  2686. smalltalk.addMethod(
  2687. smalltalk.method({
  2688. selector: "isSteppingNode",
  2689. category: '*Compiler-Interpreter',
  2690. fn: function (){
  2691. var self=this;
  2692. return smalltalk.withContext(function($ctx1) {
  2693. return true;
  2694. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
  2695. args: [],
  2696. source: "isSteppingNode\x0a\x09^ true",
  2697. messageSends: [],
  2698. referencedClasses: []
  2699. }),
  2700. smalltalk.DynamicArrayNode);
  2701. smalltalk.addMethod(
  2702. smalltalk.method({
  2703. selector: "interpreter:continue:",
  2704. category: '*Compiler-Interpreter',
  2705. fn: function (anInterpreter,aBlock){
  2706. var self=this;
  2707. return smalltalk.withContext(function($ctx1) {
  2708. var $1;
  2709. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  2710. return $1;
  2711. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicDictionaryNode)})},
  2712. args: ["anInterpreter", "aBlock"],
  2713. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  2714. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  2715. referencedClasses: []
  2716. }),
  2717. smalltalk.DynamicDictionaryNode);
  2718. smalltalk.addMethod(
  2719. smalltalk.method({
  2720. selector: "isSteppingNode",
  2721. category: '*Compiler-Interpreter',
  2722. fn: function (){
  2723. var self=this;
  2724. return smalltalk.withContext(function($ctx1) {
  2725. return true;
  2726. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
  2727. args: [],
  2728. source: "isSteppingNode\x0a\x09^ true",
  2729. messageSends: [],
  2730. referencedClasses: []
  2731. }),
  2732. smalltalk.DynamicDictionaryNode);
  2733. smalltalk.addMethod(
  2734. smalltalk.method({
  2735. selector: "interpreter:continue:",
  2736. category: '*Compiler-Interpreter',
  2737. fn: function (anInterpreter,aBlock){
  2738. var self=this;
  2739. return smalltalk.withContext(function($ctx1) {
  2740. var $1;
  2741. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  2742. return $1;
  2743. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.JSStatementNode)})},
  2744. args: ["anInterpreter", "aBlock"],
  2745. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  2746. messageSends: ["interpretJSStatementNode:continue:"],
  2747. referencedClasses: []
  2748. }),
  2749. smalltalk.JSStatementNode);
  2750. smalltalk.addMethod(
  2751. smalltalk.method({
  2752. selector: "isSteppingNode",
  2753. category: '*Compiler-Interpreter',
  2754. fn: function (){
  2755. var self=this;
  2756. return smalltalk.withContext(function($ctx1) {
  2757. return true;
  2758. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
  2759. args: [],
  2760. source: "isSteppingNode\x0a\x09^ true",
  2761. messageSends: [],
  2762. referencedClasses: []
  2763. }),
  2764. smalltalk.JSStatementNode);
  2765. smalltalk.addMethod(
  2766. smalltalk.method({
  2767. selector: "interpreter:continue:",
  2768. category: '*Compiler-Interpreter',
  2769. fn: function (anInterpreter,aBlock){
  2770. var self=this;
  2771. return smalltalk.withContext(function($ctx1) {
  2772. var $1;
  2773. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  2774. return $1;
  2775. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.MethodNode)})},
  2776. args: ["anInterpreter", "aBlock"],
  2777. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  2778. messageSends: ["interpretMethodNode:continue:"],
  2779. referencedClasses: []
  2780. }),
  2781. smalltalk.MethodNode);
  2782. smalltalk.addMethod(
  2783. smalltalk.method({
  2784. selector: "interpreter:continue:",
  2785. category: '*Compiler-Interpreter',
  2786. fn: function (anInterpreter,aBlock){
  2787. var self=this;
  2788. return smalltalk.withContext(function($ctx1) {
  2789. var $1;
  2790. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  2791. return $1;
  2792. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ReturnNode)})},
  2793. args: ["anInterpreter", "aBlock"],
  2794. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  2795. messageSends: ["interpretReturnNode:continue:"],
  2796. referencedClasses: []
  2797. }),
  2798. smalltalk.ReturnNode);
  2799. smalltalk.addMethod(
  2800. smalltalk.method({
  2801. selector: "interpreter:continue:",
  2802. category: '*Compiler-Interpreter',
  2803. fn: function (anInterpreter,aBlock){
  2804. var self=this;
  2805. return smalltalk.withContext(function($ctx1) {
  2806. var $1;
  2807. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  2808. return $1;
  2809. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SendNode)})},
  2810. args: ["anInterpreter", "aBlock"],
  2811. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  2812. messageSends: ["interpretSendNode:continue:"],
  2813. referencedClasses: []
  2814. }),
  2815. smalltalk.SendNode);
  2816. smalltalk.addMethod(
  2817. smalltalk.method({
  2818. selector: "isSteppingNode",
  2819. category: '*Compiler-Interpreter',
  2820. fn: function (){
  2821. var self=this;
  2822. return smalltalk.withContext(function($ctx1) {
  2823. return true;
  2824. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
  2825. args: [],
  2826. source: "isSteppingNode\x0a\x09^ true",
  2827. messageSends: [],
  2828. referencedClasses: []
  2829. }),
  2830. smalltalk.SendNode);
  2831. smalltalk.addMethod(
  2832. smalltalk.method({
  2833. selector: "interpreter:continue:",
  2834. category: '*Compiler-Interpreter',
  2835. fn: function (anInterpreter,aBlock){
  2836. var self=this;
  2837. return smalltalk.withContext(function($ctx1) {
  2838. var $1;
  2839. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  2840. return $1;
  2841. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SequenceNode)})},
  2842. args: ["anInterpreter", "aBlock"],
  2843. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  2844. messageSends: ["interpretSequenceNode:continue:"],
  2845. referencedClasses: []
  2846. }),
  2847. smalltalk.SequenceNode);
  2848. smalltalk.addMethod(
  2849. smalltalk.method({
  2850. selector: "interpreter:continue:",
  2851. category: '*Compiler-Interpreter',
  2852. fn: function (anInterpreter,aBlock){
  2853. var self=this;
  2854. return smalltalk.withContext(function($ctx1) {
  2855. var $1;
  2856. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  2857. return $1;
  2858. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockSequenceNode)})},
  2859. args: ["anInterpreter", "aBlock"],
  2860. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  2861. messageSends: ["interpretBlockSequenceNode:continue:"],
  2862. referencedClasses: []
  2863. }),
  2864. smalltalk.BlockSequenceNode);
  2865. smalltalk.addMethod(
  2866. smalltalk.method({
  2867. selector: "interpreter:continue:",
  2868. category: '*Compiler-Interpreter',
  2869. fn: function (anInterpreter,aBlock){
  2870. var self=this;
  2871. return smalltalk.withContext(function($ctx1) {
  2872. var $1;
  2873. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  2874. return $1;
  2875. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ValueNode)})},
  2876. args: ["anInterpreter", "aBlock"],
  2877. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  2878. messageSends: ["interpretValueNode:continue:"],
  2879. referencedClasses: []
  2880. }),
  2881. smalltalk.ValueNode);
  2882. smalltalk.addMethod(
  2883. smalltalk.method({
  2884. selector: "interpreter:continue:",
  2885. category: '*Compiler-Interpreter',
  2886. fn: function (anInterpreter,aBlock){
  2887. var self=this;
  2888. return smalltalk.withContext(function($ctx1) {
  2889. var $1;
  2890. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  2891. return $1;
  2892. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.VariableNode)})},
  2893. args: ["anInterpreter", "aBlock"],
  2894. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  2895. messageSends: ["interpretVariableNode:continue:"],
  2896. referencedClasses: []
  2897. }),
  2898. smalltalk.VariableNode);
  2899. smalltalk.addMethod(
  2900. smalltalk.method({
  2901. selector: "interpreter:continue:",
  2902. category: '*Compiler-Interpreter',
  2903. fn: function (anInterpreter,aBlock){
  2904. var self=this;
  2905. return smalltalk.withContext(function($ctx1) {
  2906. var $1;
  2907. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  2908. return $1;
  2909. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ClassReferenceNode)})},
  2910. args: ["anInterpreter", "aBlock"],
  2911. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  2912. messageSends: ["interpretClassReferenceNode:continue:"],
  2913. referencedClasses: []
  2914. }),
  2915. smalltalk.ClassReferenceNode);