Compiler-Interpreter.js 127 KB

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