Compiler-Interpreter.js 113 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086
  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,$2,$3,$5,$4;
  2541. $1=_st(_st(aNode)._binding())._isUnknownVar();
  2542. if(smalltalk.assert($1)){
  2543. $2=self._push_(_st(window)._at_ifAbsent_(_st(aNode)._value(),(function(){
  2544. return smalltalk.withContext(function($ctx2) {
  2545. return self._error_("Unknown variable");
  2546. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  2547. return $2;
  2548. };
  2549. $3=self;
  2550. $5=_st(_st(aNode)._binding())._isInstanceVar();
  2551. if(smalltalk.assert($5)){
  2552. $4=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
  2553. } else {
  2554. $4=_st(self._context())._localAt_(_st(aNode)._value());
  2555. };
  2556. _st($3)._push_($4);
  2557. return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},smalltalk.Interpreter)})},
  2558. args: ["aNode"],
  2559. source: "visitVariableNode: aNode\x0a\x09aNode binding isUnknownVar ifTrue: [\x0a\x09\x09^ self push: (window at: aNode value ifAbsent: [ self error: 'Unknown variable' ]) ].\x0a\x09\x09\x0a\x09self push: (aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value ])",
  2560. messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:"],
  2561. referencedClasses: []
  2562. }),
  2563. smalltalk.Interpreter);
  2564. smalltalk.addMethod(
  2565. smalltalk.method({
  2566. selector: "interpreter:continue:",
  2567. category: '*Compiler-Interpreter',
  2568. fn: function (anInterpreter,aBlock){
  2569. var self=this;
  2570. return smalltalk.withContext(function($ctx1) {
  2571. var $1;
  2572. $1=_st(anInterpreter)._interpretNode_continue_(self,aBlock);
  2573. return $1;
  2574. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.Node)})},
  2575. args: ["anInterpreter", "aBlock"],
  2576. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretNode: self continue: aBlock",
  2577. messageSends: ["interpretNode:continue:"],
  2578. referencedClasses: []
  2579. }),
  2580. smalltalk.Node);
  2581. smalltalk.addMethod(
  2582. smalltalk.method({
  2583. selector: "isSteppingNode",
  2584. category: '*Compiler-Interpreter',
  2585. fn: function (){
  2586. var self=this;
  2587. return smalltalk.withContext(function($ctx1) {
  2588. return false;
  2589. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
  2590. args: [],
  2591. source: "isSteppingNode\x0a\x09^ false",
  2592. messageSends: [],
  2593. referencedClasses: []
  2594. }),
  2595. smalltalk.Node);
  2596. smalltalk.addMethod(
  2597. smalltalk.method({
  2598. selector: "interpreter:continue:",
  2599. category: '*Compiler-Interpreter',
  2600. fn: function (anInterpreter,aBlock){
  2601. var self=this;
  2602. return smalltalk.withContext(function($ctx1) {
  2603. var $1;
  2604. $1=_st(anInterpreter)._interpretAssignmentNode_continue_(self,aBlock);
  2605. return $1;
  2606. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.AssignmentNode)})},
  2607. args: ["anInterpreter", "aBlock"],
  2608. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretAssignmentNode: self continue: aBlock",
  2609. messageSends: ["interpretAssignmentNode:continue:"],
  2610. referencedClasses: []
  2611. }),
  2612. smalltalk.AssignmentNode);
  2613. smalltalk.addMethod(
  2614. smalltalk.method({
  2615. selector: "isSteppingNode",
  2616. category: '*Compiler-Interpreter',
  2617. fn: function (){
  2618. var self=this;
  2619. return smalltalk.withContext(function($ctx1) {
  2620. return true;
  2621. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.AssignmentNode)})},
  2622. args: [],
  2623. source: "isSteppingNode\x0a\x09^ true",
  2624. messageSends: [],
  2625. referencedClasses: []
  2626. }),
  2627. smalltalk.AssignmentNode);
  2628. smalltalk.addMethod(
  2629. smalltalk.method({
  2630. selector: "interpreter:continue:",
  2631. category: '*Compiler-Interpreter',
  2632. fn: function (anInterpreter,aBlock){
  2633. var self=this;
  2634. return smalltalk.withContext(function($ctx1) {
  2635. var $1;
  2636. $1=_st(anInterpreter)._interpretBlockNode_continue_(self,aBlock);
  2637. return $1;
  2638. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockNode)})},
  2639. args: ["anInterpreter", "aBlock"],
  2640. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockNode: self continue: aBlock",
  2641. messageSends: ["interpretBlockNode:continue:"],
  2642. referencedClasses: []
  2643. }),
  2644. smalltalk.BlockNode);
  2645. smalltalk.addMethod(
  2646. smalltalk.method({
  2647. selector: "isSteppingNode",
  2648. category: '*Compiler-Interpreter',
  2649. fn: function (){
  2650. var self=this;
  2651. return smalltalk.withContext(function($ctx1) {
  2652. return true;
  2653. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
  2654. args: [],
  2655. source: "isSteppingNode\x0a\x09^ true",
  2656. messageSends: [],
  2657. referencedClasses: []
  2658. }),
  2659. smalltalk.BlockNode);
  2660. smalltalk.addMethod(
  2661. smalltalk.method({
  2662. selector: "interpreter:continue:",
  2663. category: '*Compiler-Interpreter',
  2664. fn: function (anInterpreter,aBlock){
  2665. var self=this;
  2666. return smalltalk.withContext(function($ctx1) {
  2667. var $1;
  2668. $1=_st(anInterpreter)._interpretCascadeNode_continue_(self,aBlock);
  2669. return $1;
  2670. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.CascadeNode)})},
  2671. args: ["anInterpreter", "aBlock"],
  2672. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretCascadeNode: self continue: aBlock",
  2673. messageSends: ["interpretCascadeNode:continue:"],
  2674. referencedClasses: []
  2675. }),
  2676. smalltalk.CascadeNode);
  2677. smalltalk.addMethod(
  2678. smalltalk.method({
  2679. selector: "interpreter:continue:",
  2680. category: '*Compiler-Interpreter',
  2681. fn: function (anInterpreter,aBlock){
  2682. var self=this;
  2683. return smalltalk.withContext(function($ctx1) {
  2684. var $1;
  2685. $1=_st(anInterpreter)._interpretDynamicArrayNode_continue_(self,aBlock);
  2686. return $1;
  2687. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicArrayNode)})},
  2688. args: ["anInterpreter", "aBlock"],
  2689. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicArrayNode: self continue: aBlock",
  2690. messageSends: ["interpretDynamicArrayNode:continue:"],
  2691. referencedClasses: []
  2692. }),
  2693. smalltalk.DynamicArrayNode);
  2694. smalltalk.addMethod(
  2695. smalltalk.method({
  2696. selector: "isSteppingNode",
  2697. category: '*Compiler-Interpreter',
  2698. fn: function (){
  2699. var self=this;
  2700. return smalltalk.withContext(function($ctx1) {
  2701. return true;
  2702. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
  2703. args: [],
  2704. source: "isSteppingNode\x0a\x09^ true",
  2705. messageSends: [],
  2706. referencedClasses: []
  2707. }),
  2708. smalltalk.DynamicArrayNode);
  2709. smalltalk.addMethod(
  2710. smalltalk.method({
  2711. selector: "interpreter:continue:",
  2712. category: '*Compiler-Interpreter',
  2713. fn: function (anInterpreter,aBlock){
  2714. var self=this;
  2715. return smalltalk.withContext(function($ctx1) {
  2716. var $1;
  2717. $1=_st(anInterpreter)._interpretDynamicDictionaryNode_continue_(self,aBlock);
  2718. return $1;
  2719. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.DynamicDictionaryNode)})},
  2720. args: ["anInterpreter", "aBlock"],
  2721. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretDynamicDictionaryNode: self continue: aBlock",
  2722. messageSends: ["interpretDynamicDictionaryNode:continue:"],
  2723. referencedClasses: []
  2724. }),
  2725. smalltalk.DynamicDictionaryNode);
  2726. smalltalk.addMethod(
  2727. smalltalk.method({
  2728. selector: "isSteppingNode",
  2729. category: '*Compiler-Interpreter',
  2730. fn: function (){
  2731. var self=this;
  2732. return smalltalk.withContext(function($ctx1) {
  2733. return true;
  2734. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
  2735. args: [],
  2736. source: "isSteppingNode\x0a\x09^ true",
  2737. messageSends: [],
  2738. referencedClasses: []
  2739. }),
  2740. smalltalk.DynamicDictionaryNode);
  2741. smalltalk.addMethod(
  2742. smalltalk.method({
  2743. selector: "interpreter:continue:",
  2744. category: '*Compiler-Interpreter',
  2745. fn: function (anInterpreter,aBlock){
  2746. var self=this;
  2747. return smalltalk.withContext(function($ctx1) {
  2748. var $1;
  2749. $1=_st(anInterpreter)._interpretJSStatementNode_continue_(self,aBlock);
  2750. return $1;
  2751. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.JSStatementNode)})},
  2752. args: ["anInterpreter", "aBlock"],
  2753. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretJSStatementNode: self continue: aBlock",
  2754. messageSends: ["interpretJSStatementNode:continue:"],
  2755. referencedClasses: []
  2756. }),
  2757. smalltalk.JSStatementNode);
  2758. smalltalk.addMethod(
  2759. smalltalk.method({
  2760. selector: "isSteppingNode",
  2761. category: '*Compiler-Interpreter',
  2762. fn: function (){
  2763. var self=this;
  2764. return smalltalk.withContext(function($ctx1) {
  2765. return true;
  2766. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
  2767. args: [],
  2768. source: "isSteppingNode\x0a\x09^ true",
  2769. messageSends: [],
  2770. referencedClasses: []
  2771. }),
  2772. smalltalk.JSStatementNode);
  2773. smalltalk.addMethod(
  2774. smalltalk.method({
  2775. selector: "interpreter:continue:",
  2776. category: '*Compiler-Interpreter',
  2777. fn: function (anInterpreter,aBlock){
  2778. var self=this;
  2779. return smalltalk.withContext(function($ctx1) {
  2780. var $1;
  2781. $1=_st(anInterpreter)._interpretMethodNode_continue_(self,aBlock);
  2782. return $1;
  2783. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.MethodNode)})},
  2784. args: ["anInterpreter", "aBlock"],
  2785. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretMethodNode: self continue: aBlock",
  2786. messageSends: ["interpretMethodNode:continue:"],
  2787. referencedClasses: []
  2788. }),
  2789. smalltalk.MethodNode);
  2790. smalltalk.addMethod(
  2791. smalltalk.method({
  2792. selector: "interpreter:continue:",
  2793. category: '*Compiler-Interpreter',
  2794. fn: function (anInterpreter,aBlock){
  2795. var self=this;
  2796. return smalltalk.withContext(function($ctx1) {
  2797. var $1;
  2798. $1=_st(anInterpreter)._interpretReturnNode_continue_(self,aBlock);
  2799. return $1;
  2800. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ReturnNode)})},
  2801. args: ["anInterpreter", "aBlock"],
  2802. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretReturnNode: self continue: aBlock",
  2803. messageSends: ["interpretReturnNode:continue:"],
  2804. referencedClasses: []
  2805. }),
  2806. smalltalk.ReturnNode);
  2807. smalltalk.addMethod(
  2808. smalltalk.method({
  2809. selector: "interpreter:continue:",
  2810. category: '*Compiler-Interpreter',
  2811. fn: function (anInterpreter,aBlock){
  2812. var self=this;
  2813. return smalltalk.withContext(function($ctx1) {
  2814. var $1;
  2815. $1=_st(anInterpreter)._interpretSendNode_continue_(self,aBlock);
  2816. return $1;
  2817. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SendNode)})},
  2818. args: ["anInterpreter", "aBlock"],
  2819. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSendNode: self continue: aBlock",
  2820. messageSends: ["interpretSendNode:continue:"],
  2821. referencedClasses: []
  2822. }),
  2823. smalltalk.SendNode);
  2824. smalltalk.addMethod(
  2825. smalltalk.method({
  2826. selector: "isSteppingNode",
  2827. category: '*Compiler-Interpreter',
  2828. fn: function (){
  2829. var self=this;
  2830. return smalltalk.withContext(function($ctx1) {
  2831. return true;
  2832. }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
  2833. args: [],
  2834. source: "isSteppingNode\x0a\x09^ true",
  2835. messageSends: [],
  2836. referencedClasses: []
  2837. }),
  2838. smalltalk.SendNode);
  2839. smalltalk.addMethod(
  2840. smalltalk.method({
  2841. selector: "interpreter:continue:",
  2842. category: '*Compiler-Interpreter',
  2843. fn: function (anInterpreter,aBlock){
  2844. var self=this;
  2845. return smalltalk.withContext(function($ctx1) {
  2846. var $1;
  2847. $1=_st(anInterpreter)._interpretSequenceNode_continue_(self,aBlock);
  2848. return $1;
  2849. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.SequenceNode)})},
  2850. args: ["anInterpreter", "aBlock"],
  2851. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretSequenceNode: self continue: aBlock",
  2852. messageSends: ["interpretSequenceNode:continue:"],
  2853. referencedClasses: []
  2854. }),
  2855. smalltalk.SequenceNode);
  2856. smalltalk.addMethod(
  2857. smalltalk.method({
  2858. selector: "interpreter:continue:",
  2859. category: '*Compiler-Interpreter',
  2860. fn: function (anInterpreter,aBlock){
  2861. var self=this;
  2862. return smalltalk.withContext(function($ctx1) {
  2863. var $1;
  2864. $1=_st(anInterpreter)._interpretBlockSequenceNode_continue_(self,aBlock);
  2865. return $1;
  2866. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.BlockSequenceNode)})},
  2867. args: ["anInterpreter", "aBlock"],
  2868. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretBlockSequenceNode: self continue: aBlock",
  2869. messageSends: ["interpretBlockSequenceNode:continue:"],
  2870. referencedClasses: []
  2871. }),
  2872. smalltalk.BlockSequenceNode);
  2873. smalltalk.addMethod(
  2874. smalltalk.method({
  2875. selector: "interpreter:continue:",
  2876. category: '*Compiler-Interpreter',
  2877. fn: function (anInterpreter,aBlock){
  2878. var self=this;
  2879. return smalltalk.withContext(function($ctx1) {
  2880. var $1;
  2881. $1=_st(anInterpreter)._interpretValueNode_continue_(self,aBlock);
  2882. return $1;
  2883. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ValueNode)})},
  2884. args: ["anInterpreter", "aBlock"],
  2885. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretValueNode: self continue: aBlock",
  2886. messageSends: ["interpretValueNode:continue:"],
  2887. referencedClasses: []
  2888. }),
  2889. smalltalk.ValueNode);
  2890. smalltalk.addMethod(
  2891. smalltalk.method({
  2892. selector: "interpreter:continue:",
  2893. category: '*Compiler-Interpreter',
  2894. fn: function (anInterpreter,aBlock){
  2895. var self=this;
  2896. return smalltalk.withContext(function($ctx1) {
  2897. var $1;
  2898. $1=_st(anInterpreter)._interpretVariableNode_continue_(self,aBlock);
  2899. return $1;
  2900. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.VariableNode)})},
  2901. args: ["anInterpreter", "aBlock"],
  2902. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretVariableNode: self continue: aBlock",
  2903. messageSends: ["interpretVariableNode:continue:"],
  2904. referencedClasses: []
  2905. }),
  2906. smalltalk.VariableNode);
  2907. smalltalk.addMethod(
  2908. smalltalk.method({
  2909. selector: "interpreter:continue:",
  2910. category: '*Compiler-Interpreter',
  2911. fn: function (anInterpreter,aBlock){
  2912. var self=this;
  2913. return smalltalk.withContext(function($ctx1) {
  2914. var $1;
  2915. $1=_st(anInterpreter)._interpretClassReferenceNode_continue_(self,aBlock);
  2916. return $1;
  2917. }, function($ctx1) {$ctx1.fill(self,"interpreter:continue:",{anInterpreter:anInterpreter,aBlock:aBlock},smalltalk.ClassReferenceNode)})},
  2918. args: ["anInterpreter", "aBlock"],
  2919. source: "interpreter: anInterpreter continue: aBlock\x0a\x09^ anInterpreter interpretClassReferenceNode: self continue: aBlock",
  2920. messageSends: ["interpretClassReferenceNode:continue:"],
  2921. referencedClasses: []
  2922. }),
  2923. smalltalk.ClassReferenceNode);