1
0

Compiler-Core.js 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971
  1. smalltalk.addPackage('Compiler-Core', {});
  2. smalltalk.addClass('Compiler', smalltalk.Object, ['currentClass', 'source', 'unknownVariables', 'codeGeneratorClass'], 'Compiler-Core');
  3. smalltalk.Compiler.comment="I provide the public interface for compiling Amber source code into JavaScript.\x0a\x0aThe code generator used to produce JavaScript can be plugged with `#codeGeneratorClass`. \x0aThe default code generator is an instance of `InlinedCodeGenerator`"
  4. smalltalk.addMethod(
  5. "_codeGeneratorClass",
  6. smalltalk.method({
  7. selector: "codeGeneratorClass",
  8. category: 'accessing',
  9. fn: function (){
  10. var self=this;
  11. var $1;
  12. if(($receiver = self["@codeGeneratorClass"]) == nil || $receiver == undefined){
  13. $1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
  14. } else {
  15. $1=self["@codeGeneratorClass"];
  16. };
  17. return $1;
  18. },
  19. args: [],
  20. source: "codeGeneratorClass\x0a\x09^codeGeneratorClass ifNil: [InliningCodeGenerator]",
  21. messageSends: ["ifNil:"],
  22. referencedClasses: ["InliningCodeGenerator"]
  23. }),
  24. smalltalk.Compiler);
  25. smalltalk.addMethod(
  26. "_codeGeneratorClass_",
  27. smalltalk.method({
  28. selector: "codeGeneratorClass:",
  29. category: 'accessing',
  30. fn: function (aClass){
  31. var self=this;
  32. self["@codeGeneratorClass"]=aClass;
  33. return self},
  34. args: ["aClass"],
  35. source: "codeGeneratorClass: aClass\x0a\x09codeGeneratorClass := aClass",
  36. messageSends: [],
  37. referencedClasses: []
  38. }),
  39. smalltalk.Compiler);
  40. smalltalk.addMethod(
  41. "_compile_",
  42. smalltalk.method({
  43. selector: "compile:",
  44. category: 'compiling',
  45. fn: function (aString){
  46. var self=this;
  47. var $1;
  48. $1=smalltalk.send(self,"_compileNode_",[smalltalk.send(self,"_parse_",[aString])]);
  49. return $1;
  50. },
  51. args: ["aString"],
  52. source: "compile: aString\x0a\x09^self compileNode: (self parse: aString)",
  53. messageSends: ["compileNode:", "parse:"],
  54. referencedClasses: []
  55. }),
  56. smalltalk.Compiler);
  57. smalltalk.addMethod(
  58. "_compile_forClass_",
  59. smalltalk.method({
  60. selector: "compile:forClass:",
  61. category: 'compiling',
  62. fn: function (aString,aClass){
  63. var self=this;
  64. var $1;
  65. smalltalk.send(self,"_currentClass_",[aClass]);
  66. smalltalk.send(self,"_source_",[aString]);
  67. $1=smalltalk.send(self,"_compile_",[aString]);
  68. return $1;
  69. },
  70. args: ["aString", "aClass"],
  71. source: "compile: aString forClass: aClass\x0a\x09self currentClass: aClass.\x0a\x09self source: aString.\x0a\x09^self compile: aString",
  72. messageSends: ["currentClass:", "source:", "compile:"],
  73. referencedClasses: []
  74. }),
  75. smalltalk.Compiler);
  76. smalltalk.addMethod(
  77. "_compileExpression_",
  78. smalltalk.method({
  79. selector: "compileExpression:",
  80. category: 'compiling',
  81. fn: function (aString){
  82. var self=this;
  83. var $1;
  84. smalltalk.send(self,"_currentClass_",[(smalltalk.DoIt || DoIt)]);
  85. smalltalk.send(self,"_source_",[smalltalk.send(smalltalk.send("doIt ^[","__comma",[aString]),"__comma",["] value"])]);
  86. $1=smalltalk.send(self,"_compileNode_",[smalltalk.send(self,"_parse_",[smalltalk.send(self,"_source",[])])]);
  87. return $1;
  88. },
  89. args: ["aString"],
  90. source: "compileExpression: aString\x0a\x09self currentClass: DoIt.\x0a\x09self source: 'doIt ^[', aString, '] value'.\x0a\x09^self compileNode: (self parse: self source)",
  91. messageSends: ["currentClass:", "source:", ",", "compileNode:", "parse:", "source"],
  92. referencedClasses: ["DoIt"]
  93. }),
  94. smalltalk.Compiler);
  95. smalltalk.addMethod(
  96. "_compileNode_",
  97. smalltalk.method({
  98. selector: "compileNode:",
  99. category: 'compiling',
  100. fn: function (aNode){
  101. var self=this;
  102. var $1;
  103. var generator;
  104. var result;
  105. generator=smalltalk.send(smalltalk.send(self,"_codeGeneratorClass",[]),"_new",[]);
  106. smalltalk.send(generator,"_source_",[smalltalk.send(self,"_source",[])]);
  107. $1=smalltalk.send(generator,"_currentClass_",[smalltalk.send(self,"_currentClass",[])]);
  108. result=smalltalk.send(generator,"_compileNode_",[aNode]);
  109. smalltalk.send(self,"_unknownVariables_",[[]]);
  110. return result;
  111. },
  112. args: ["aNode"],
  113. source: "compileNode: aNode\x0a\x09| generator result |\x0a\x09generator := self codeGeneratorClass new.\x0a\x09generator\x0a\x09\x09source: self source;\x0a\x09\x09currentClass: self currentClass.\x0a\x09result := generator compileNode: aNode.\x0a\x09self unknownVariables: #().\x0a\x09^result",
  114. messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "compileNode:", "unknownVariables:"],
  115. referencedClasses: []
  116. }),
  117. smalltalk.Compiler);
  118. smalltalk.addMethod(
  119. "_currentClass",
  120. smalltalk.method({
  121. selector: "currentClass",
  122. category: 'accessing',
  123. fn: function (){
  124. var self=this;
  125. return self["@currentClass"];
  126. },
  127. args: [],
  128. source: "currentClass\x0a\x09^currentClass",
  129. messageSends: [],
  130. referencedClasses: []
  131. }),
  132. smalltalk.Compiler);
  133. smalltalk.addMethod(
  134. "_currentClass_",
  135. smalltalk.method({
  136. selector: "currentClass:",
  137. category: 'accessing',
  138. fn: function (aClass){
  139. var self=this;
  140. self["@currentClass"]=aClass;
  141. return self},
  142. args: ["aClass"],
  143. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  144. messageSends: [],
  145. referencedClasses: []
  146. }),
  147. smalltalk.Compiler);
  148. smalltalk.addMethod(
  149. "_eval_",
  150. smalltalk.method({
  151. selector: "eval:",
  152. category: 'compiling',
  153. fn: function (aString){
  154. var self=this;
  155. return eval(aString);
  156. ;
  157. return self},
  158. args: ["aString"],
  159. source: "eval: aString\x0a\x09<return eval(aString)>",
  160. messageSends: [],
  161. referencedClasses: []
  162. }),
  163. smalltalk.Compiler);
  164. smalltalk.addMethod(
  165. "_evaluateExpression_",
  166. smalltalk.method({
  167. selector: "evaluateExpression:",
  168. category: 'compiling',
  169. fn: function (aString){
  170. var self=this;
  171. var result;
  172. smalltalk.send((smalltalk.DoIt || DoIt),"_addCompiledMethod_",[smalltalk.send(self,"_eval_",[smalltalk.send(self,"_compileExpression_",[aString])])]);
  173. result=smalltalk.send(smalltalk.send((smalltalk.DoIt || DoIt),"_new",[]),"_doIt",[]);
  174. smalltalk.send((smalltalk.DoIt || DoIt),"_removeCompiledMethod_",[smalltalk.send(smalltalk.send((smalltalk.DoIt || DoIt),"_methodDictionary",[]),"_at_",["doIt"])]);
  175. return result;
  176. },
  177. args: ["aString"],
  178. source: "evaluateExpression: aString\x0a\x09\x22Unlike #eval: evaluate a Smalltalk expression and answer the returned object\x22\x0a\x09| result |\x0a\x09DoIt addCompiledMethod: (self eval: (self compileExpression: aString)).\x0a\x09result := DoIt new doIt.\x0a\x09DoIt removeCompiledMethod: (DoIt methodDictionary at: 'doIt').\x0a\x09^result",
  179. messageSends: ["addCompiledMethod:", "eval:", "compileExpression:", "doIt", "new", "removeCompiledMethod:", "at:", "methodDictionary"],
  180. referencedClasses: ["DoIt"]
  181. }),
  182. smalltalk.Compiler);
  183. smalltalk.addMethod(
  184. "_install_forClass_category_",
  185. smalltalk.method({
  186. selector: "install:forClass:category:",
  187. category: 'compiling',
  188. fn: function (aString,aBehavior,anotherString){
  189. var self=this;
  190. var compiled;
  191. compiled=smalltalk.send(self,"_eval_",[smalltalk.send(self,"_compile_forClass_",[aString,aBehavior])]);
  192. smalltalk.send(compiled,"_category_",[anotherString]);
  193. smalltalk.send(aBehavior,"_addCompiledMethod_",[compiled]);
  194. return compiled;
  195. },
  196. args: ["aString", "aBehavior", "anotherString"],
  197. source: "install: aString forClass: aBehavior category: anotherString\x0a\x09| compiled |\x0a\x09compiled := self eval: (self compile: aString forClass: aBehavior).\x0a\x09compiled category: anotherString.\x0a\x09aBehavior addCompiledMethod: compiled.\x0a\x09^compiled",
  198. messageSends: ["eval:", "compile:forClass:", "category:", "addCompiledMethod:"],
  199. referencedClasses: []
  200. }),
  201. smalltalk.Compiler);
  202. smalltalk.addMethod(
  203. "_parse_",
  204. smalltalk.method({
  205. selector: "parse:",
  206. category: 'compiling',
  207. fn: function (aString){
  208. var self=this;
  209. var $1;
  210. $1=smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_parse_",[aString]);
  211. return $1;
  212. },
  213. args: ["aString"],
  214. source: "parse: aString\x0a ^Smalltalk current parse: aString",
  215. messageSends: ["parse:", "current"],
  216. referencedClasses: ["Smalltalk"]
  217. }),
  218. smalltalk.Compiler);
  219. smalltalk.addMethod(
  220. "_parseExpression_",
  221. smalltalk.method({
  222. selector: "parseExpression:",
  223. category: 'compiling',
  224. fn: function (aString){
  225. var self=this;
  226. var $1;
  227. $1=smalltalk.send(self,"_parse_",[smalltalk.send(smalltalk.send("doIt ^[","__comma",[aString]),"__comma",["] value"])]);
  228. return $1;
  229. },
  230. args: ["aString"],
  231. source: "parseExpression: aString\x0a ^self parse: 'doIt ^[', aString, '] value'",
  232. messageSends: ["parse:", ","],
  233. referencedClasses: []
  234. }),
  235. smalltalk.Compiler);
  236. smalltalk.addMethod(
  237. "_recompile_",
  238. smalltalk.method({
  239. selector: "recompile:",
  240. category: 'compiling',
  241. fn: function (aClass){
  242. var self=this;
  243. var $1;
  244. smalltalk.send(smalltalk.send(aClass,"_methodDictionary",[]),"_do_",[(function(each){
  245. smalltalk.send(console,"_log_",[smalltalk.send(smalltalk.send(smalltalk.send(aClass,"_name",[]),"__comma",[" >> "]),"__comma",[smalltalk.send(each,"_selector",[])])]);
  246. return smalltalk.send(self,"_install_forClass_category_",[smalltalk.send(each,"_source",[]),aClass,smalltalk.send(each,"_category",[])]);
  247. })]);
  248. smalltalk.send(self,"_setupClass_",[aClass]);
  249. $1=smalltalk.send(aClass,"_isMetaclass",[]);
  250. if(! smalltalk.assert($1)){
  251. smalltalk.send(self,"_recompile_",[smalltalk.send(aClass,"_class",[])]);
  252. };
  253. return self},
  254. args: ["aClass"],
  255. source: "recompile: aClass\x0a\x09aClass methodDictionary do: [:each |\x0a\x09\x09console log: aClass name, ' >> ', each selector.\x0a\x09\x09self install: each source forClass: aClass category: each category].\x0a\x09self setupClass: aClass.\x0a\x09aClass isMetaclass ifFalse: [self recompile: aClass class]",
  256. messageSends: ["do:", "log:", ",", "selector", "name", "install:forClass:category:", "source", "category", "methodDictionary", "setupClass:", "ifFalse:", "recompile:", "class", "isMetaclass"],
  257. referencedClasses: []
  258. }),
  259. smalltalk.Compiler);
  260. smalltalk.addMethod(
  261. "_recompileAll",
  262. smalltalk.method({
  263. selector: "recompileAll",
  264. category: 'compiling',
  265. fn: function (){
  266. var self=this;
  267. var $1;
  268. smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_classes",[]),"_do_",[(function(each){
  269. smalltalk.send((smalltalk.Transcript || Transcript),"_show_",[each]);
  270. $1=smalltalk.send((smalltalk.Transcript || Transcript),"_cr",[]);
  271. $1;
  272. return smalltalk.send((function(){
  273. return smalltalk.send(self,"_recompile_",[each]);
  274. }),"_valueWithTimeout_",[(100)]);
  275. })]);
  276. return self},
  277. args: [],
  278. source: "recompileAll\x0a\x09Smalltalk current classes do: [:each |\x0a\x09\x09Transcript show: each; cr.\x0a\x09\x09[self recompile: each] valueWithTimeout: 100]",
  279. messageSends: ["do:", "show:", "cr", "valueWithTimeout:", "recompile:", "classes", "current"],
  280. referencedClasses: ["Transcript", "Smalltalk"]
  281. }),
  282. smalltalk.Compiler);
  283. smalltalk.addMethod(
  284. "_setupClass_",
  285. smalltalk.method({
  286. selector: "setupClass:",
  287. category: 'compiling',
  288. fn: function (aClass){
  289. var self=this;
  290. smalltalk.init(aClass);
  291. ;
  292. return self},
  293. args: ["aClass"],
  294. source: "setupClass: aClass\x0a\x09<smalltalk.init(aClass)>",
  295. messageSends: [],
  296. referencedClasses: []
  297. }),
  298. smalltalk.Compiler);
  299. smalltalk.addMethod(
  300. "_source",
  301. smalltalk.method({
  302. selector: "source",
  303. category: 'accessing',
  304. fn: function (){
  305. var self=this;
  306. var $1;
  307. if(($receiver = self["@source"]) == nil || $receiver == undefined){
  308. $1="";
  309. } else {
  310. $1=self["@source"];
  311. };
  312. return $1;
  313. },
  314. args: [],
  315. source: "source\x0a\x09^source ifNil: ['']",
  316. messageSends: ["ifNil:"],
  317. referencedClasses: []
  318. }),
  319. smalltalk.Compiler);
  320. smalltalk.addMethod(
  321. "_source_",
  322. smalltalk.method({
  323. selector: "source:",
  324. category: 'accessing',
  325. fn: function (aString){
  326. var self=this;
  327. self["@source"]=aString;
  328. return self},
  329. args: ["aString"],
  330. source: "source: aString\x0a\x09source := aString",
  331. messageSends: [],
  332. referencedClasses: []
  333. }),
  334. smalltalk.Compiler);
  335. smalltalk.addMethod(
  336. "_unknownVariables",
  337. smalltalk.method({
  338. selector: "unknownVariables",
  339. category: 'accessing',
  340. fn: function (){
  341. var self=this;
  342. return self["@unknownVariables"];
  343. },
  344. args: [],
  345. source: "unknownVariables\x0a\x09^unknownVariables",
  346. messageSends: [],
  347. referencedClasses: []
  348. }),
  349. smalltalk.Compiler);
  350. smalltalk.addMethod(
  351. "_unknownVariables_",
  352. smalltalk.method({
  353. selector: "unknownVariables:",
  354. category: 'accessing',
  355. fn: function (aCollection){
  356. var self=this;
  357. self["@unknownVariables"]=aCollection;
  358. return self},
  359. args: ["aCollection"],
  360. source: "unknownVariables: aCollection\x0a\x09unknownVariables := aCollection",
  361. messageSends: [],
  362. referencedClasses: []
  363. }),
  364. smalltalk.Compiler);
  365. smalltalk.addMethod(
  366. "_recompile_",
  367. smalltalk.method({
  368. selector: "recompile:",
  369. category: 'compiling',
  370. fn: function (aClass){
  371. var self=this;
  372. smalltalk.send(smalltalk.send(self,"_new",[]),"_recompile_",[aClass]);
  373. return self},
  374. args: ["aClass"],
  375. source: "recompile: aClass\x0a\x09self new recompile: aClass",
  376. messageSends: ["recompile:", "new"],
  377. referencedClasses: []
  378. }),
  379. smalltalk.Compiler.klass);
  380. smalltalk.addMethod(
  381. "_recompileAll",
  382. smalltalk.method({
  383. selector: "recompileAll",
  384. category: 'compiling',
  385. fn: function (){
  386. var self=this;
  387. smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_classes",[]),"_do_",[(function(each){
  388. return smalltalk.send(self,"_recompile_",[each]);
  389. })]);
  390. return self},
  391. args: [],
  392. source: "recompileAll\x0a\x09Smalltalk current classes do: [:each |\x0a\x09\x09self recompile: each]",
  393. messageSends: ["do:", "recompile:", "classes", "current"],
  394. referencedClasses: ["Smalltalk"]
  395. }),
  396. smalltalk.Compiler.klass);
  397. smalltalk.addClass('DoIt', smalltalk.Object, [], 'Compiler-Core');
  398. smalltalk.DoIt.comment="`DoIt` is the class used to compile and evaluate expressions. See `Compiler >> evaluateExpression:`."
  399. smalltalk.addClass('NodeVisitor', smalltalk.Object, [], 'Compiler-Core');
  400. smalltalk.NodeVisitor.comment="I am the abstract super class of all AST node visitors."
  401. smalltalk.addMethod(
  402. "_visit_",
  403. smalltalk.method({
  404. selector: "visit:",
  405. category: 'visiting',
  406. fn: function (aNode){
  407. var self=this;
  408. var $1;
  409. $1=smalltalk.send(aNode,"_accept_",[self]);
  410. return $1;
  411. },
  412. args: ["aNode"],
  413. source: "visit: aNode\x0a\x09^ aNode accept: self",
  414. messageSends: ["accept:"],
  415. referencedClasses: []
  416. }),
  417. smalltalk.NodeVisitor);
  418. smalltalk.addMethod(
  419. "_visitAll_",
  420. smalltalk.method({
  421. selector: "visitAll:",
  422. category: 'visiting',
  423. fn: function (aCollection){
  424. var self=this;
  425. var $1;
  426. $1=smalltalk.send(aCollection,"_do_",[(function(each){
  427. return smalltalk.send(self,"_visit_",[each]);
  428. })]);
  429. return $1;
  430. },
  431. args: ["aCollection"],
  432. source: "visitAll: aCollection\x0a\x09^ aCollection do: [ :each | self visit: each ]",
  433. messageSends: ["do:", "visit:"],
  434. referencedClasses: []
  435. }),
  436. smalltalk.NodeVisitor);
  437. smalltalk.addMethod(
  438. "_visitAssignmentNode_",
  439. smalltalk.method({
  440. selector: "visitAssignmentNode:",
  441. category: 'visiting',
  442. fn: function (aNode){
  443. var self=this;
  444. var $1;
  445. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  446. return $1;
  447. },
  448. args: ["aNode"],
  449. source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
  450. messageSends: ["visitNode:"],
  451. referencedClasses: []
  452. }),
  453. smalltalk.NodeVisitor);
  454. smalltalk.addMethod(
  455. "_visitBlockNode_",
  456. smalltalk.method({
  457. selector: "visitBlockNode:",
  458. category: 'visiting',
  459. fn: function (aNode){
  460. var self=this;
  461. var $1;
  462. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  463. return $1;
  464. },
  465. args: ["aNode"],
  466. source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
  467. messageSends: ["visitNode:"],
  468. referencedClasses: []
  469. }),
  470. smalltalk.NodeVisitor);
  471. smalltalk.addMethod(
  472. "_visitBlockSequenceNode_",
  473. smalltalk.method({
  474. selector: "visitBlockSequenceNode:",
  475. category: 'visiting',
  476. fn: function (aNode){
  477. var self=this;
  478. var $1;
  479. $1=smalltalk.send(self,"_visitSequenceNode_",[aNode]);
  480. return $1;
  481. },
  482. args: ["aNode"],
  483. source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
  484. messageSends: ["visitSequenceNode:"],
  485. referencedClasses: []
  486. }),
  487. smalltalk.NodeVisitor);
  488. smalltalk.addMethod(
  489. "_visitCascadeNode_",
  490. smalltalk.method({
  491. selector: "visitCascadeNode:",
  492. category: 'visiting',
  493. fn: function (aNode){
  494. var self=this;
  495. var $1;
  496. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  497. return $1;
  498. },
  499. args: ["aNode"],
  500. source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
  501. messageSends: ["visitNode:"],
  502. referencedClasses: []
  503. }),
  504. smalltalk.NodeVisitor);
  505. smalltalk.addMethod(
  506. "_visitClassReferenceNode_",
  507. smalltalk.method({
  508. selector: "visitClassReferenceNode:",
  509. category: 'visiting',
  510. fn: function (aNode){
  511. var self=this;
  512. var $1;
  513. $1=smalltalk.send(self,"_visitVariableNode_",[aNode]);
  514. return $1;
  515. },
  516. args: ["aNode"],
  517. source: "visitClassReferenceNode: aNode\x0a\x09^ self visitVariableNode: aNode",
  518. messageSends: ["visitVariableNode:"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.NodeVisitor);
  522. smalltalk.addMethod(
  523. "_visitDynamicArrayNode_",
  524. smalltalk.method({
  525. selector: "visitDynamicArrayNode:",
  526. category: 'visiting',
  527. fn: function (aNode){
  528. var self=this;
  529. var $1;
  530. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  531. return $1;
  532. },
  533. args: ["aNode"],
  534. source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
  535. messageSends: ["visitNode:"],
  536. referencedClasses: []
  537. }),
  538. smalltalk.NodeVisitor);
  539. smalltalk.addMethod(
  540. "_visitDynamicDictionaryNode_",
  541. smalltalk.method({
  542. selector: "visitDynamicDictionaryNode:",
  543. category: 'visiting',
  544. fn: function (aNode){
  545. var self=this;
  546. var $1;
  547. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  548. return $1;
  549. },
  550. args: ["aNode"],
  551. source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
  552. messageSends: ["visitNode:"],
  553. referencedClasses: []
  554. }),
  555. smalltalk.NodeVisitor);
  556. smalltalk.addMethod(
  557. "_visitJSStatementNode_",
  558. smalltalk.method({
  559. selector: "visitJSStatementNode:",
  560. category: 'visiting',
  561. fn: function (aNode){
  562. var self=this;
  563. var $1;
  564. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  565. return $1;
  566. },
  567. args: ["aNode"],
  568. source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
  569. messageSends: ["visitNode:"],
  570. referencedClasses: []
  571. }),
  572. smalltalk.NodeVisitor);
  573. smalltalk.addMethod(
  574. "_visitMethodNode_",
  575. smalltalk.method({
  576. selector: "visitMethodNode:",
  577. category: 'visiting',
  578. fn: function (aNode){
  579. var self=this;
  580. var $1;
  581. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  582. return $1;
  583. },
  584. args: ["aNode"],
  585. source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
  586. messageSends: ["visitNode:"],
  587. referencedClasses: []
  588. }),
  589. smalltalk.NodeVisitor);
  590. smalltalk.addMethod(
  591. "_visitNode_",
  592. smalltalk.method({
  593. selector: "visitNode:",
  594. category: 'visiting',
  595. fn: function (aNode){
  596. var self=this;
  597. var $1;
  598. $1=smalltalk.send(self,"_visitAll_",[smalltalk.send(aNode,"_nodes",[])]);
  599. return $1;
  600. },
  601. args: ["aNode"],
  602. source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
  603. messageSends: ["visitAll:", "nodes"],
  604. referencedClasses: []
  605. }),
  606. smalltalk.NodeVisitor);
  607. smalltalk.addMethod(
  608. "_visitReturnNode_",
  609. smalltalk.method({
  610. selector: "visitReturnNode:",
  611. category: 'visiting',
  612. fn: function (aNode){
  613. var self=this;
  614. var $1;
  615. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  616. return $1;
  617. },
  618. args: ["aNode"],
  619. source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
  620. messageSends: ["visitNode:"],
  621. referencedClasses: []
  622. }),
  623. smalltalk.NodeVisitor);
  624. smalltalk.addMethod(
  625. "_visitSendNode_",
  626. smalltalk.method({
  627. selector: "visitSendNode:",
  628. category: 'visiting',
  629. fn: function (aNode){
  630. var self=this;
  631. var $1;
  632. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  633. return $1;
  634. },
  635. args: ["aNode"],
  636. source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
  637. messageSends: ["visitNode:"],
  638. referencedClasses: []
  639. }),
  640. smalltalk.NodeVisitor);
  641. smalltalk.addMethod(
  642. "_visitSequenceNode_",
  643. smalltalk.method({
  644. selector: "visitSequenceNode:",
  645. category: 'visiting',
  646. fn: function (aNode){
  647. var self=this;
  648. var $1;
  649. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  650. return $1;
  651. },
  652. args: ["aNode"],
  653. source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
  654. messageSends: ["visitNode:"],
  655. referencedClasses: []
  656. }),
  657. smalltalk.NodeVisitor);
  658. smalltalk.addMethod(
  659. "_visitValueNode_",
  660. smalltalk.method({
  661. selector: "visitValueNode:",
  662. category: 'visiting',
  663. fn: function (aNode){
  664. var self=this;
  665. var $1;
  666. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  667. return $1;
  668. },
  669. args: ["aNode"],
  670. source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
  671. messageSends: ["visitNode:"],
  672. referencedClasses: []
  673. }),
  674. smalltalk.NodeVisitor);
  675. smalltalk.addMethod(
  676. "_visitVariableNode_",
  677. smalltalk.method({
  678. selector: "visitVariableNode:",
  679. category: 'visiting',
  680. fn: function (aNode){
  681. var self=this;
  682. var $1;
  683. $1=smalltalk.send(self,"_visitNode_",[aNode]);
  684. return $1;
  685. },
  686. args: ["aNode"],
  687. source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
  688. messageSends: ["visitNode:"],
  689. referencedClasses: []
  690. }),
  691. smalltalk.NodeVisitor);
  692. smalltalk.addClass('AbstractCodeGenerator', smalltalk.NodeVisitor, ['currentClass', 'source'], 'Compiler-Core');
  693. smalltalk.AbstractCodeGenerator.comment="I am the abstract super class of all code generators and provide their common API."
  694. smalltalk.addMethod(
  695. "_classNameFor_",
  696. smalltalk.method({
  697. selector: "classNameFor:",
  698. category: 'accessing',
  699. fn: function (aClass){
  700. var self=this;
  701. var $2,$3,$1;
  702. $2=smalltalk.send(aClass,"_isMetaclass",[]);
  703. if(smalltalk.assert($2)){
  704. $1=smalltalk.send(smalltalk.send(smalltalk.send(aClass,"_instanceClass",[]),"_name",[]),"__comma",[".klass"]);
  705. } else {
  706. $3=smalltalk.send(aClass,"_isNil",[]);
  707. if(smalltalk.assert($3)){
  708. $1="nil";
  709. } else {
  710. $1=smalltalk.send(aClass,"_name",[]);
  711. };
  712. };
  713. return $1;
  714. },
  715. args: ["aClass"],
  716. source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09 ifTrue: [aClass instanceClass name, '.klass']\x0a\x09 ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09 ifTrue: ['nil']\x0a\x09\x09 ifFalse: [aClass name]]",
  717. messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
  718. referencedClasses: []
  719. }),
  720. smalltalk.AbstractCodeGenerator);
  721. smalltalk.addMethod(
  722. "_compileNode_",
  723. smalltalk.method({
  724. selector: "compileNode:",
  725. category: 'compiling',
  726. fn: function (aNode){
  727. var self=this;
  728. smalltalk.send(self,"_subclassResponsibility",[]);
  729. return self},
  730. args: ["aNode"],
  731. source: "compileNode: aNode\x0a\x09self subclassResponsibility",
  732. messageSends: ["subclassResponsibility"],
  733. referencedClasses: []
  734. }),
  735. smalltalk.AbstractCodeGenerator);
  736. smalltalk.addMethod(
  737. "_currentClass",
  738. smalltalk.method({
  739. selector: "currentClass",
  740. category: 'accessing',
  741. fn: function (){
  742. var self=this;
  743. return self["@currentClass"];
  744. },
  745. args: [],
  746. source: "currentClass\x0a\x09^currentClass",
  747. messageSends: [],
  748. referencedClasses: []
  749. }),
  750. smalltalk.AbstractCodeGenerator);
  751. smalltalk.addMethod(
  752. "_currentClass_",
  753. smalltalk.method({
  754. selector: "currentClass:",
  755. category: 'accessing',
  756. fn: function (aClass){
  757. var self=this;
  758. self["@currentClass"]=aClass;
  759. return self},
  760. args: ["aClass"],
  761. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  762. messageSends: [],
  763. referencedClasses: []
  764. }),
  765. smalltalk.AbstractCodeGenerator);
  766. smalltalk.addMethod(
  767. "_pseudoVariables",
  768. smalltalk.method({
  769. selector: "pseudoVariables",
  770. category: 'accessing',
  771. fn: function (){
  772. var self=this;
  773. return ["self", "super", "true", "false", "nil", "thisContext"];
  774. },
  775. args: [],
  776. source: "pseudoVariables\x0a\x09^#('self' 'super' 'true' 'false' 'nil' 'thisContext')",
  777. messageSends: [],
  778. referencedClasses: []
  779. }),
  780. smalltalk.AbstractCodeGenerator);
  781. smalltalk.addMethod(
  782. "_safeVariableNameFor_",
  783. smalltalk.method({
  784. selector: "safeVariableNameFor:",
  785. category: 'accessing',
  786. fn: function (aString){
  787. var self=this;
  788. var $2,$1;
  789. $2=smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_reservedWords",[]),"_includes_",[aString]);
  790. if(smalltalk.assert($2)){
  791. $1=smalltalk.send(aString,"__comma",["_"]);
  792. } else {
  793. $1=aString;
  794. };
  795. return $1;
  796. },
  797. args: ["aString"],
  798. source: "safeVariableNameFor: aString\x0a\x09^(Smalltalk current reservedWords includes: aString)\x0a\x09\x09ifTrue: [aString, '_']\x0a\x09\x09ifFalse: [aString]",
  799. messageSends: ["ifTrue:ifFalse:", ",", "includes:", "reservedWords", "current"],
  800. referencedClasses: ["Smalltalk"]
  801. }),
  802. smalltalk.AbstractCodeGenerator);
  803. smalltalk.addMethod(
  804. "_source",
  805. smalltalk.method({
  806. selector: "source",
  807. category: 'accessing',
  808. fn: function (){
  809. var self=this;
  810. var $1;
  811. if(($receiver = self["@source"]) == nil || $receiver == undefined){
  812. $1="";
  813. } else {
  814. $1=self["@source"];
  815. };
  816. return $1;
  817. },
  818. args: [],
  819. source: "source\x0a\x09^source ifNil: ['']",
  820. messageSends: ["ifNil:"],
  821. referencedClasses: []
  822. }),
  823. smalltalk.AbstractCodeGenerator);
  824. smalltalk.addMethod(
  825. "_source_",
  826. smalltalk.method({
  827. selector: "source:",
  828. category: 'accessing',
  829. fn: function (aString){
  830. var self=this;
  831. self["@source"]=aString;
  832. return self},
  833. args: ["aString"],
  834. source: "source: aString\x0a\x09source := aString",
  835. messageSends: [],
  836. referencedClasses: []
  837. }),
  838. smalltalk.AbstractCodeGenerator);
  839. smalltalk.addClass('CodeGenerator', smalltalk.AbstractCodeGenerator, [], 'Compiler-Core');
  840. smalltalk.CodeGenerator.comment="I am a basic code generator. I generate a valid JavaScript output, but no not perform any inlining.\x0aSee `InliningCodeGenerator` for an optimized JavaScript code generation."
  841. smalltalk.addMethod(
  842. "_compileNode_",
  843. smalltalk.method({
  844. selector: "compileNode:",
  845. category: 'compiling',
  846. fn: function (aNode){
  847. var self=this;
  848. var $2,$3,$1;
  849. var ir;
  850. var stream;
  851. smalltalk.send(smalltalk.send(self,"_semanticAnalyzer",[]),"_visit_",[aNode]);
  852. ir=smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[aNode]);
  853. $2=smalltalk.send(self,"_irTranslator",[]);
  854. smalltalk.send($2,"_visit_",[ir]);
  855. $3=smalltalk.send($2,"_contents",[]);
  856. $1=$3;
  857. return $1;
  858. },
  859. args: ["aNode"],
  860. source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09^ self irTranslator\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
  861. messageSends: ["visit:", "semanticAnalyzer", "translator", "irTranslator", "contents"],
  862. referencedClasses: []
  863. }),
  864. smalltalk.CodeGenerator);
  865. smalltalk.addMethod(
  866. "_irTranslator",
  867. smalltalk.method({
  868. selector: "irTranslator",
  869. category: 'compiling',
  870. fn: function (){
  871. var self=this;
  872. var $1;
  873. $1=smalltalk.send((smalltalk.IRJSTranslator || IRJSTranslator),"_new",[]);
  874. return $1;
  875. },
  876. args: [],
  877. source: "irTranslator\x0a\x09^ IRJSTranslator new",
  878. messageSends: ["new"],
  879. referencedClasses: ["IRJSTranslator"]
  880. }),
  881. smalltalk.CodeGenerator);
  882. smalltalk.addMethod(
  883. "_semanticAnalyzer",
  884. smalltalk.method({
  885. selector: "semanticAnalyzer",
  886. category: 'compiling',
  887. fn: function (){
  888. var self=this;
  889. var $1;
  890. $1=smalltalk.send((smalltalk.SemanticAnalyzer || SemanticAnalyzer),"_on_",[smalltalk.send(self,"_currentClass",[])]);
  891. return $1;
  892. },
  893. args: [],
  894. source: "semanticAnalyzer\x0a\x09^ SemanticAnalyzer on: self currentClass",
  895. messageSends: ["on:", "currentClass"],
  896. referencedClasses: ["SemanticAnalyzer"]
  897. }),
  898. smalltalk.CodeGenerator);
  899. smalltalk.addMethod(
  900. "_translator",
  901. smalltalk.method({
  902. selector: "translator",
  903. category: 'compiling',
  904. fn: function (){
  905. var self=this;
  906. var $2,$3,$1;
  907. $2=smalltalk.send((smalltalk.IRASTTranslator || IRASTTranslator),"_new",[]);
  908. smalltalk.send($2,"_source_",[smalltalk.send(self,"_source",[])]);
  909. smalltalk.send($2,"_theClass_",[smalltalk.send(self,"_currentClass",[])]);
  910. $3=smalltalk.send($2,"_yourself",[]);
  911. $1=$3;
  912. return $1;
  913. },
  914. args: [],
  915. source: "translator\x0a\x09^ IRASTTranslator new\x0a\x09\x09source: self source;\x0a\x09\x09theClass: self currentClass;\x0a\x09\x09yourself",
  916. messageSends: ["source:", "source", "new", "theClass:", "currentClass", "yourself"],
  917. referencedClasses: ["IRASTTranslator"]
  918. }),
  919. smalltalk.CodeGenerator);
  920. smalltalk.addClass('FunCodeGenerator', smalltalk.AbstractCodeGenerator, ['stream', 'nestedBlocks', 'earlyReturn', 'currentSelector', 'unknownVariables', 'tempVariables', 'messageSends', 'referencedClasses', 'classReferenced', 'argVariables'], 'Compiler-Core');
  921. smalltalk.addMethod(
  922. "_argVariables",
  923. smalltalk.method({
  924. selector: "argVariables",
  925. category: 'accessing',
  926. fn: function (){
  927. var self=this;
  928. var $1;
  929. $1=smalltalk.send(self["@argVariables"],"_copy",[]);
  930. return $1;
  931. },
  932. args: [],
  933. source: "argVariables\x0a\x09^argVariables copy",
  934. messageSends: ["copy"],
  935. referencedClasses: []
  936. }),
  937. smalltalk.FunCodeGenerator);
  938. smalltalk.addMethod(
  939. "_checkClass_for_",
  940. smalltalk.method({
  941. selector: "checkClass:for:",
  942. category: 'optimizations',
  943. fn: function (aClassName,receiver){
  944. var self=this;
  945. smalltalk.send(self["@stream"],"_nextPutAll_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("((($receiver = ","__comma",[receiver]),"__comma",[").klass === smalltalk."]),"__comma",[aClassName]),"__comma",[") ? "])]);
  946. return self},
  947. args: ["aClassName", "receiver"],
  948. source: "checkClass: aClassName for: receiver\x0a stream nextPutAll: '((($receiver = ', receiver, ').klass === smalltalk.', aClassName, ') ? '",
  949. messageSends: ["nextPutAll:", ","],
  950. referencedClasses: []
  951. }),
  952. smalltalk.FunCodeGenerator);
  953. smalltalk.addMethod(
  954. "_compileNode_",
  955. smalltalk.method({
  956. selector: "compileNode:",
  957. category: 'compiling',
  958. fn: function (aNode){
  959. var self=this;
  960. var $1;
  961. self["@stream"]=smalltalk.send("","_writeStream",[]);
  962. smalltalk.send(self,"_visit_",[aNode]);
  963. $1=smalltalk.send(self["@stream"],"_contents",[]);
  964. return $1;
  965. },
  966. args: ["aNode"],
  967. source: "compileNode: aNode\x0a\x09stream := '' writeStream.\x0a\x09self visit: aNode.\x0a\x09^stream contents",
  968. messageSends: ["writeStream", "visit:", "contents"],
  969. referencedClasses: []
  970. }),
  971. smalltalk.FunCodeGenerator);
  972. smalltalk.addMethod(
  973. "_initialize",
  974. smalltalk.method({
  975. selector: "initialize",
  976. category: 'initialization',
  977. fn: function (){
  978. var self=this;
  979. smalltalk.send(self,"_initialize",[],smalltalk.AbstractCodeGenerator);
  980. self["@stream"]=smalltalk.send("","_writeStream",[]);
  981. self["@unknownVariables"]=[];
  982. self["@tempVariables"]=[];
  983. self["@argVariables"]=[];
  984. self["@messageSends"]=[];
  985. self["@classReferenced"]=[];
  986. return self},
  987. args: [],
  988. source: "initialize\x0a\x09super initialize.\x0a\x09stream := '' writeStream. \x0a\x09unknownVariables := #().\x0a\x09tempVariables := #().\x0a\x09argVariables := #().\x0a\x09messageSends := #().\x0a\x09classReferenced := #()",
  989. messageSends: ["initialize", "writeStream"],
  990. referencedClasses: []
  991. }),
  992. smalltalk.FunCodeGenerator);
  993. smalltalk.addMethod(
  994. "_inline_receiver_argumentNodes_",
  995. smalltalk.method({
  996. selector: "inline:receiver:argumentNodes:",
  997. category: 'optimizations',
  998. fn: function (aSelector,receiver,aCollection){
  999. var self=this;
  1000. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16;
  1001. var inlined;
  1002. inlined=false;
  1003. $1=smalltalk.send(aSelector,"__eq",["ifFalse:"]);
  1004. if(smalltalk.assert($1)){
  1005. $2=smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]);
  1006. if(smalltalk.assert($2)){
  1007. smalltalk.send(self,"_checkClass_for_",["Boolean",receiver]);
  1008. smalltalk.send(self["@stream"],"_nextPutAll_",["(! $receiver ? "]);
  1009. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1010. smalltalk.send(self["@stream"],"_nextPutAll_",["() : nil)"]);
  1011. inlined=true;
  1012. inlined;
  1013. };
  1014. };
  1015. $3=smalltalk.send(aSelector,"__eq",["ifTrue:"]);
  1016. if(smalltalk.assert($3)){
  1017. $4=smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]);
  1018. if(smalltalk.assert($4)){
  1019. smalltalk.send(self,"_checkClass_for_",["Boolean",receiver]);
  1020. smalltalk.send(self["@stream"],"_nextPutAll_",["($receiver ? "]);
  1021. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1022. smalltalk.send(self["@stream"],"_nextPutAll_",["() : nil)"]);
  1023. inlined=true;
  1024. inlined;
  1025. };
  1026. };
  1027. $5=smalltalk.send(aSelector,"__eq",["ifTrue:ifFalse:"]);
  1028. if(smalltalk.assert($5)){
  1029. $6=smalltalk.send(smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]),"_and_",[(function(){
  1030. return smalltalk.send(smalltalk.send(aCollection,"_second",[]),"_isBlockNode",[]);
  1031. })]);
  1032. if(smalltalk.assert($6)){
  1033. smalltalk.send(self,"_checkClass_for_",["Boolean",receiver]);
  1034. smalltalk.send(self["@stream"],"_nextPutAll_",["($receiver ? "]);
  1035. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1036. smalltalk.send(self["@stream"],"_nextPutAll_",["() : "]);
  1037. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_second",[])]);
  1038. smalltalk.send(self["@stream"],"_nextPutAll_",["())"]);
  1039. inlined=true;
  1040. inlined;
  1041. };
  1042. };
  1043. $7=smalltalk.send(aSelector,"__eq",["ifFalse:ifTrue:"]);
  1044. if(smalltalk.assert($7)){
  1045. $8=smalltalk.send(smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]),"_and_",[(function(){
  1046. return smalltalk.send(smalltalk.send(aCollection,"_second",[]),"_isBlockNode",[]);
  1047. })]);
  1048. if(smalltalk.assert($8)){
  1049. smalltalk.send(self,"_checkClass_for_",["Boolean",receiver]);
  1050. smalltalk.send(self["@stream"],"_nextPutAll_",["(! $receiver ? "]);
  1051. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1052. smalltalk.send(self["@stream"],"_nextPutAll_",["() : "]);
  1053. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_second",[])]);
  1054. smalltalk.send(self["@stream"],"_nextPutAll_",["())"]);
  1055. inlined=true;
  1056. inlined;
  1057. };
  1058. };
  1059. $9=smalltalk.send(aSelector,"__eq",["<"]);
  1060. if(smalltalk.assert($9)){
  1061. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1062. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver <"]);
  1063. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1064. inlined=true;
  1065. inlined;
  1066. };
  1067. $10=smalltalk.send(aSelector,"__eq",["<="]);
  1068. if(smalltalk.assert($10)){
  1069. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1070. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver <="]);
  1071. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1072. inlined=true;
  1073. inlined;
  1074. };
  1075. $11=smalltalk.send(aSelector,"__eq",[">"]);
  1076. if(smalltalk.assert($11)){
  1077. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1078. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver >"]);
  1079. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1080. inlined=true;
  1081. inlined;
  1082. };
  1083. $12=smalltalk.send(aSelector,"__eq",[">="]);
  1084. if(smalltalk.assert($12)){
  1085. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1086. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver >="]);
  1087. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1088. inlined=true;
  1089. inlined;
  1090. };
  1091. $13=smalltalk.send(aSelector,"__eq",["+"]);
  1092. if(smalltalk.assert($13)){
  1093. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1094. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver +"]);
  1095. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1096. inlined=true;
  1097. inlined;
  1098. };
  1099. $14=smalltalk.send(aSelector,"__eq",["-"]);
  1100. if(smalltalk.assert($14)){
  1101. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1102. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver -"]);
  1103. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1104. inlined=true;
  1105. inlined;
  1106. };
  1107. $15=smalltalk.send(aSelector,"__eq",["*"]);
  1108. if(smalltalk.assert($15)){
  1109. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1110. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver *"]);
  1111. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1112. inlined=true;
  1113. inlined;
  1114. };
  1115. $16=smalltalk.send(aSelector,"__eq",["/"]);
  1116. if(smalltalk.assert($16)){
  1117. smalltalk.send(self,"_checkClass_for_",["Number",receiver]);
  1118. smalltalk.send(self["@stream"],"_nextPutAll_",["$receiver /"]);
  1119. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1120. inlined=true;
  1121. inlined;
  1122. };
  1123. return inlined;
  1124. },
  1125. args: ["aSelector", "receiver", "aCollection"],
  1126. source: "inline: aSelector receiver: receiver argumentNodes: aCollection\x0a | inlined |\x0a inlined := false.\x0a\x0a\x09\x22-- Booleans --\x22\x0a\x0a\x09(aSelector = 'ifFalse:') ifTrue: [\x0a\x09\x09aCollection first isBlockNode ifTrue: [\x0a \x09self checkClass: 'Boolean' for: receiver.\x0a \x09stream nextPutAll: '(! $receiver ? '.\x0a \x09self visit: aCollection first.\x0a \x09\x09stream nextPutAll: '() : nil)'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'ifTrue:') ifTrue: [\x0a\x09\x09aCollection first isBlockNode ifTrue: [\x0a \x09self checkClass: 'Boolean' for: receiver.\x0a \x09stream nextPutAll: '($receiver ? '.\x0a \x09self visit: aCollection first.\x0a \x09\x09stream nextPutAll: '() : nil)'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'ifTrue:ifFalse:') ifTrue: [\x0a\x09\x09(aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [\x0a \x09self checkClass: 'Boolean' for: receiver.\x0a \x09stream nextPutAll: '($receiver ? '.\x0a \x09self visit: aCollection first.\x0a \x09\x09stream nextPutAll: '() : '.\x0a \x09\x09self visit: aCollection second.\x0a \x09\x09stream nextPutAll: '())'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'ifFalse:ifTrue:') ifTrue: [\x0a\x09\x09(aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [\x0a \x09self checkClass: 'Boolean' for: receiver.\x0a \x09stream nextPutAll: '(! $receiver ? '.\x0a \x09self visit: aCollection first.\x0a \x09\x09stream nextPutAll: '() : '.\x0a \x09\x09self visit: aCollection second.\x0a \x09\x09stream nextPutAll: '())'.\x0a \x09inlined := true]].\x0a\x0a\x09\x22-- Numbers --\x22\x0a\x0a\x09(aSelector = '<') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver <'.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a\x09(aSelector = '<=') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver <='.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a\x09(aSelector = '>') ifTrue: [ \x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver >'.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a\x09(aSelector = '>=') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver >='.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a (aSelector = '+') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver +'.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a (aSelector = '-') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver -'.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a (aSelector = '*') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver *'.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a (aSelector = '/') ifTrue: [\x0a self checkClass: 'Number' for: receiver.\x0a stream nextPutAll: '$receiver /'.\x0a self visit: aCollection first.\x0a inlined := true].\x0a\x0a ^inlined",
  1127. messageSends: ["ifTrue:", "checkClass:for:", "nextPutAll:", "visit:", "first", "isBlockNode", "=", "second", "and:"],
  1128. referencedClasses: []
  1129. }),
  1130. smalltalk.FunCodeGenerator);
  1131. smalltalk.addMethod(
  1132. "_inlineLiteral_receiverNode_argumentNodes_",
  1133. smalltalk.method({
  1134. selector: "inlineLiteral:receiverNode:argumentNodes:",
  1135. category: 'optimizations',
  1136. fn: function (aSelector,anObject,aCollection){
  1137. var self=this;
  1138. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32;
  1139. var inlined;
  1140. inlined=false;
  1141. $1=smalltalk.send(aSelector,"__eq",["whileTrue:"]);
  1142. if(smalltalk.assert($1)){
  1143. $2=smalltalk.send(smalltalk.send(anObject,"_isBlockNode",[]),"_and_",[(function(){
  1144. return smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]);
  1145. })]);
  1146. if(smalltalk.assert($2)){
  1147. smalltalk.send(self["@stream"],"_nextPutAll_",["(function(){while("]);
  1148. smalltalk.send(self,"_visit_",[anObject]);
  1149. smalltalk.send(self["@stream"],"_nextPutAll_",["()) {"]);
  1150. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1151. smalltalk.send(self["@stream"],"_nextPutAll_",["()}})()"]);
  1152. inlined=true;
  1153. inlined;
  1154. };
  1155. };
  1156. $3=smalltalk.send(aSelector,"__eq",["whileFalse:"]);
  1157. if(smalltalk.assert($3)){
  1158. $4=smalltalk.send(smalltalk.send(anObject,"_isBlockNode",[]),"_and_",[(function(){
  1159. return smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]);
  1160. })]);
  1161. if(smalltalk.assert($4)){
  1162. smalltalk.send(self["@stream"],"_nextPutAll_",["(function(){while(!"]);
  1163. smalltalk.send(self,"_visit_",[anObject]);
  1164. smalltalk.send(self["@stream"],"_nextPutAll_",["()) {"]);
  1165. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1166. smalltalk.send(self["@stream"],"_nextPutAll_",["()}})()"]);
  1167. inlined=true;
  1168. inlined;
  1169. };
  1170. };
  1171. $5=smalltalk.send(aSelector,"__eq",["whileTrue"]);
  1172. if(smalltalk.assert($5)){
  1173. $6=smalltalk.send(anObject,"_isBlockNode",[]);
  1174. if(smalltalk.assert($6)){
  1175. smalltalk.send(self["@stream"],"_nextPutAll_",["(function(){while("]);
  1176. smalltalk.send(self,"_visit_",[anObject]);
  1177. smalltalk.send(self["@stream"],"_nextPutAll_",["()) {}})()"]);
  1178. inlined=true;
  1179. inlined;
  1180. };
  1181. };
  1182. $7=smalltalk.send(aSelector,"__eq",["whileFalse"]);
  1183. if(smalltalk.assert($7)){
  1184. $8=smalltalk.send(anObject,"_isBlockNode",[]);
  1185. if(smalltalk.assert($8)){
  1186. smalltalk.send(self["@stream"],"_nextPutAll_",["(function(){while(!"]);
  1187. smalltalk.send(self,"_visit_",[anObject]);
  1188. smalltalk.send(self["@stream"],"_nextPutAll_",["()) {}})()"]);
  1189. inlined=true;
  1190. inlined;
  1191. };
  1192. };
  1193. $9=smalltalk.send(aSelector,"__eq",["+"]);
  1194. if(smalltalk.assert($9)){
  1195. $10=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1196. if(smalltalk.assert($10)){
  1197. smalltalk.send(self,"_visit_",[anObject]);
  1198. smalltalk.send(self["@stream"],"_nextPutAll_",[" + "]);
  1199. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1200. inlined=true;
  1201. inlined;
  1202. };
  1203. };
  1204. $11=smalltalk.send(aSelector,"__eq",["-"]);
  1205. if(smalltalk.assert($11)){
  1206. $12=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1207. if(smalltalk.assert($12)){
  1208. smalltalk.send(self,"_visit_",[anObject]);
  1209. smalltalk.send(self["@stream"],"_nextPutAll_",[" - "]);
  1210. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1211. inlined=true;
  1212. inlined;
  1213. };
  1214. };
  1215. $13=smalltalk.send(aSelector,"__eq",["*"]);
  1216. if(smalltalk.assert($13)){
  1217. $14=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1218. if(smalltalk.assert($14)){
  1219. smalltalk.send(self,"_visit_",[anObject]);
  1220. smalltalk.send(self["@stream"],"_nextPutAll_",[" * "]);
  1221. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1222. inlined=true;
  1223. inlined;
  1224. };
  1225. };
  1226. $15=smalltalk.send(aSelector,"__eq",["/"]);
  1227. if(smalltalk.assert($15)){
  1228. $16=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1229. if(smalltalk.assert($16)){
  1230. smalltalk.send(self,"_visit_",[anObject]);
  1231. smalltalk.send(self["@stream"],"_nextPutAll_",[" / "]);
  1232. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1233. inlined=true;
  1234. inlined;
  1235. };
  1236. };
  1237. $17=smalltalk.send(aSelector,"__eq",["<"]);
  1238. if(smalltalk.assert($17)){
  1239. $18=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1240. if(smalltalk.assert($18)){
  1241. smalltalk.send(self,"_visit_",[anObject]);
  1242. smalltalk.send(self["@stream"],"_nextPutAll_",[" < "]);
  1243. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1244. inlined=true;
  1245. inlined;
  1246. };
  1247. };
  1248. $19=smalltalk.send(aSelector,"__eq",["<="]);
  1249. if(smalltalk.assert($19)){
  1250. $20=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1251. if(smalltalk.assert($20)){
  1252. smalltalk.send(self,"_visit_",[anObject]);
  1253. smalltalk.send(self["@stream"],"_nextPutAll_",[" <= "]);
  1254. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1255. inlined=true;
  1256. inlined;
  1257. };
  1258. };
  1259. $21=smalltalk.send(aSelector,"__eq",[">"]);
  1260. if(smalltalk.assert($21)){
  1261. $22=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1262. if(smalltalk.assert($22)){
  1263. smalltalk.send(self,"_visit_",[anObject]);
  1264. smalltalk.send(self["@stream"],"_nextPutAll_",[" > "]);
  1265. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1266. inlined=true;
  1267. inlined;
  1268. };
  1269. };
  1270. $23=smalltalk.send(aSelector,"__eq",[">="]);
  1271. if(smalltalk.assert($23)){
  1272. $24=smalltalk.send(self,"_isNode_ofClass_",[anObject,(smalltalk.Number || Number)]);
  1273. if(smalltalk.assert($24)){
  1274. smalltalk.send(self,"_visit_",[anObject]);
  1275. smalltalk.send(self["@stream"],"_nextPutAll_",[" >= "]);
  1276. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1277. inlined=true;
  1278. inlined;
  1279. };
  1280. };
  1281. $25=smalltalk.send(aSelector,"__eq",["ifNil:"]);
  1282. if(smalltalk.assert($25)){
  1283. $26=smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]);
  1284. if(smalltalk.assert($26)){
  1285. smalltalk.send(self["@stream"],"_nextPutAll_",["(($receiver = "]);
  1286. smalltalk.send(self,"_visit_",[anObject]);
  1287. smalltalk.send(self["@stream"],"_nextPutAll_",[") == nil || $receiver == undefined) ? "]);
  1288. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1289. smalltalk.send(self["@stream"],"_nextPutAll_",["() : $receiver"]);
  1290. inlined=true;
  1291. inlined;
  1292. };
  1293. };
  1294. $27=smalltalk.send(aSelector,"__eq",["ifNotNil:"]);
  1295. if(smalltalk.assert($27)){
  1296. $28=smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]);
  1297. if(smalltalk.assert($28)){
  1298. smalltalk.send(self["@stream"],"_nextPutAll_",["(($receiver = "]);
  1299. smalltalk.send(self,"_visit_",[anObject]);
  1300. smalltalk.send(self["@stream"],"_nextPutAll_",[") != nil && $receiver != undefined) ? "]);
  1301. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1302. smalltalk.send(self["@stream"],"_nextPutAll_",["() : nil"]);
  1303. inlined=true;
  1304. inlined;
  1305. };
  1306. };
  1307. $29=smalltalk.send(aSelector,"__eq",["ifNil:ifNotNil:"]);
  1308. if(smalltalk.assert($29)){
  1309. $30=smalltalk.send(smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]),"_and_",[(function(){
  1310. return smalltalk.send(smalltalk.send(aCollection,"_second",[]),"_isBlockNode",[]);
  1311. })]);
  1312. if(smalltalk.assert($30)){
  1313. smalltalk.send(self["@stream"],"_nextPutAll_",["(($receiver = "]);
  1314. smalltalk.send(self,"_visit_",[anObject]);
  1315. smalltalk.send(self["@stream"],"_nextPutAll_",[") == nil || $receiver == undefined) ? "]);
  1316. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1317. smalltalk.send(self["@stream"],"_nextPutAll_",["() : "]);
  1318. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_second",[])]);
  1319. smalltalk.send(self["@stream"],"_nextPutAll_",["()"]);
  1320. inlined=true;
  1321. inlined;
  1322. };
  1323. };
  1324. $31=smalltalk.send(aSelector,"__eq",["ifNotNil:ifNil:"]);
  1325. if(smalltalk.assert($31)){
  1326. $32=smalltalk.send(smalltalk.send(smalltalk.send(aCollection,"_first",[]),"_isBlockNode",[]),"_and_",[(function(){
  1327. return smalltalk.send(smalltalk.send(aCollection,"_second",[]),"_isBlockNode",[]);
  1328. })]);
  1329. if(smalltalk.assert($32)){
  1330. smalltalk.send(self["@stream"],"_nextPutAll_",["(($receiver = "]);
  1331. smalltalk.send(self,"_visit_",[anObject]);
  1332. smalltalk.send(self["@stream"],"_nextPutAll_",[") == nil || $receiver == undefined) ? "]);
  1333. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_second",[])]);
  1334. smalltalk.send(self["@stream"],"_nextPutAll_",["() : "]);
  1335. smalltalk.send(self,"_visit_",[smalltalk.send(aCollection,"_first",[])]);
  1336. smalltalk.send(self["@stream"],"_nextPutAll_",["()"]);
  1337. inlined=true;
  1338. inlined;
  1339. };
  1340. };
  1341. return inlined;
  1342. },
  1343. args: ["aSelector", "anObject", "aCollection"],
  1344. source: "inlineLiteral: aSelector receiverNode: anObject argumentNodes: aCollection\x0a | inlined |\x0a inlined := false.\x0a \x0a\x09\x22-- BlockClosures --\x22\x0a\x0a\x09(aSelector = 'whileTrue:') ifTrue: [\x0a \x09(anObject isBlockNode and: [aCollection first isBlockNode]) ifTrue: [\x0a \x09stream nextPutAll: '(function(){while('.\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: '()) {'.\x0a \x09self visit: aCollection first.\x0a \x09\x09stream nextPutAll: '()}})()'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'whileFalse:') ifTrue: [\x0a \x09(anObject isBlockNode and: [aCollection first isBlockNode]) ifTrue: [\x0a \x09stream nextPutAll: '(function(){while(!'.\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: '()) {'.\x0a \x09self visit: aCollection first.\x0a \x09\x09stream nextPutAll: '()}})()'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'whileTrue') ifTrue: [\x0a \x09anObject isBlockNode ifTrue: [\x0a \x09stream nextPutAll: '(function(){while('.\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: '()) {}})()'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'whileFalse') ifTrue: [\x0a \x09anObject isBlockNode ifTrue: [\x0a \x09stream nextPutAll: '(function(){while(!'.\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: '()) {}})()'.\x0a \x09inlined := true]].\x0a\x0a\x09\x22-- Numbers --\x22\x0a\x0a\x09(aSelector = '+') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' + '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '-') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' - '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '*') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' * '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '/') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' / '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '<') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' < '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '<=') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' <= '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '>') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' > '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = '>=') ifTrue: [\x0a \x09(self isNode: anObject ofClass: Number) ifTrue: [\x0a \x09self visit: anObject.\x0a \x09stream nextPutAll: ' >= '.\x0a \x09self visit: aCollection first.\x0a \x09inlined := true]].\x0a \x09 \x0a\x09\x22-- UndefinedObject --\x22\x0a\x0a\x09(aSelector = 'ifNil:') ifTrue: [\x0a\x09\x09aCollection first isBlockNode ifTrue: [\x0a \x09\x09stream nextPutAll: '(($receiver = '.\x0a \x09\x09self visit: anObject.\x0a \x09\x09stream nextPutAll: ') == nil || $receiver == undefined) ? '.\x0a \x09self visit: aCollection first.\x0a \x09stream nextPutAll: '() : $receiver'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'ifNotNil:') ifTrue: [\x0a\x09\x09aCollection first isBlockNode ifTrue: [\x0a \x09\x09stream nextPutAll: '(($receiver = '.\x0a \x09\x09self visit: anObject.\x0a \x09\x09stream nextPutAll: ') != nil && $receiver != undefined) ? '.\x0a \x09self visit: aCollection first.\x0a \x09stream nextPutAll: '() : nil'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'ifNil:ifNotNil:') ifTrue: [\x0a\x09\x09(aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [\x0a \x09\x09stream nextPutAll: '(($receiver = '.\x0a \x09\x09self visit: anObject.\x0a \x09\x09stream nextPutAll: ') == nil || $receiver == undefined) ? '.\x0a \x09self visit: aCollection first.\x0a \x09stream nextPutAll: '() : '.\x0a \x09self visit: aCollection second.\x0a \x09stream nextPutAll: '()'.\x0a \x09inlined := true]].\x0a\x0a\x09(aSelector = 'ifNotNil:ifNil:') ifTrue: [\x0a\x09\x09(aCollection first isBlockNode and: [aCollection second isBlockNode]) ifTrue: [\x0a \x09\x09stream nextPutAll: '(($receiver = '.\x0a \x09\x09self visit: anObject.\x0a \x09\x09stream nextPutAll: ') == nil || $receiver == undefined) ? '.\x0a \x09self visit: aCollection second.\x0a \x09stream nextPutAll: '() : '.\x0a \x09self visit: aCollection first.\x0a \x09stream nextPutAll: '()'.\x0a \x09inlined := true]].\x0a \x0a ^inlined",
  1345. messageSends: ["ifTrue:", "nextPutAll:", "visit:", "first", "and:", "isBlockNode", "=", "isNode:ofClass:", "second"],
  1346. referencedClasses: ["Number"]
  1347. }),
  1348. smalltalk.FunCodeGenerator);
  1349. smalltalk.addMethod(
  1350. "_isNode_ofClass_",
  1351. smalltalk.method({
  1352. selector: "isNode:ofClass:",
  1353. category: 'optimizations',
  1354. fn: function (aNode,aClass){
  1355. var self=this;
  1356. var $1;
  1357. $1=smalltalk.send(smalltalk.send(aNode,"_isValueNode",[]),"_and_",[(function(){
  1358. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aNode,"_value",[]),"_class",[]),"__eq",[aClass]),"_or_",[(function(){
  1359. return smalltalk.send(smalltalk.send(smalltalk.send(aNode,"_value",[]),"__eq",["self"]),"_and_",[(function(){
  1360. return smalltalk.send(smalltalk.send(self,"_currentClass",[]),"__eq",[aClass]);
  1361. })]);
  1362. })]);
  1363. })]);
  1364. return $1;
  1365. },
  1366. args: ["aNode", "aClass"],
  1367. source: "isNode: aNode ofClass: aClass\x0a\x09^aNode isValueNode and: [\x0a \x09aNode value class = aClass or: [\x0a \x09\x09aNode value = 'self' and: [self currentClass = aClass]]]",
  1368. messageSends: ["and:", "or:", "=", "currentClass", "value", "class", "isValueNode"],
  1369. referencedClasses: []
  1370. }),
  1371. smalltalk.FunCodeGenerator);
  1372. smalltalk.addMethod(
  1373. "_knownVariables",
  1374. smalltalk.method({
  1375. selector: "knownVariables",
  1376. category: 'accessing',
  1377. fn: function (){
  1378. var self=this;
  1379. var $2,$3,$1;
  1380. $2=smalltalk.send(self,"_pseudoVariables",[]);
  1381. smalltalk.send($2,"_addAll_",[smalltalk.send(self,"_tempVariables",[])]);
  1382. smalltalk.send($2,"_addAll_",[smalltalk.send(self,"_argVariables",[])]);
  1383. $3=smalltalk.send($2,"_yourself",[]);
  1384. $1=$3;
  1385. return $1;
  1386. },
  1387. args: [],
  1388. source: "knownVariables\x0a\x09^self pseudoVariables \x0a\x09\x09addAll: self tempVariables;\x0a\x09\x09addAll: self argVariables;\x0a\x09\x09yourself",
  1389. messageSends: ["addAll:", "tempVariables", "pseudoVariables", "argVariables", "yourself"],
  1390. referencedClasses: []
  1391. }),
  1392. smalltalk.FunCodeGenerator);
  1393. smalltalk.addMethod(
  1394. "_performOptimizations",
  1395. smalltalk.method({
  1396. selector: "performOptimizations",
  1397. category: 'testing',
  1398. fn: function (){
  1399. var self=this;
  1400. var $1;
  1401. $1=smalltalk.send(smalltalk.send(self,"_class",[]),"_performOptimizations",[]);
  1402. return $1;
  1403. },
  1404. args: [],
  1405. source: "performOptimizations\x0a\x09^self class performOptimizations",
  1406. messageSends: ["performOptimizations", "class"],
  1407. referencedClasses: []
  1408. }),
  1409. smalltalk.FunCodeGenerator);
  1410. smalltalk.addMethod(
  1411. "_send_to_arguments_superSend_",
  1412. smalltalk.method({
  1413. selector: "send:to:arguments:superSend:",
  1414. category: 'visiting',
  1415. fn: function (aSelector,aReceiver,aCollection,aBoolean){
  1416. var self=this;
  1417. var $1;
  1418. $1=smalltalk.send((smalltalk.String || String),"_streamContents_",[(function(str){
  1419. var tmp;
  1420. tmp=self["@stream"];
  1421. tmp;
  1422. smalltalk.send(str,"_nextPutAll_",["smalltalk.send("]);
  1423. smalltalk.send(str,"_nextPutAll_",[aReceiver]);
  1424. smalltalk.send(str,"_nextPutAll_",[smalltalk.send(smalltalk.send(", \x22","__comma",[smalltalk.send(aSelector,"_asSelector",[])]),"__comma",["\x22, ["])]);
  1425. self["@stream"]=str;
  1426. self["@stream"];
  1427. smalltalk.send(aCollection,"_do_separatedBy_",[(function(each){
  1428. return smalltalk.send(self,"_visit_",[each]);
  1429. }),(function(){
  1430. return smalltalk.send(self["@stream"],"_nextPutAll_",[", "]);
  1431. })]);
  1432. self["@stream"]=tmp;
  1433. self["@stream"];
  1434. smalltalk.send(str,"_nextPutAll_",["]"]);
  1435. if(smalltalk.assert(aBoolean)){
  1436. smalltalk.send(str,"_nextPutAll_",[smalltalk.send(smalltalk.send(", smalltalk.","__comma",[smalltalk.send(self,"_classNameFor_",[smalltalk.send(self,"_currentClass",[])])]),"__comma",[".superclass || nil"])]);
  1437. };
  1438. return smalltalk.send(str,"_nextPutAll_",[")"]);
  1439. })]);
  1440. return $1;
  1441. },
  1442. args: ["aSelector", "aReceiver", "aCollection", "aBoolean"],
  1443. source: "send: aSelector to: aReceiver arguments: aCollection superSend: aBoolean\x0a\x09^String streamContents: [:str || tmp |\x0a \x09tmp := stream.\x0a\x09\x09str nextPutAll: 'smalltalk.send('.\x0a\x09\x09str nextPutAll: aReceiver.\x0a\x09\x09str nextPutAll: ', \x22', aSelector asSelector, '\x22, ['.\x0a stream := str.\x0a\x09\x09aCollection\x0a\x09 \x09\x09do: [:each | self visit: each]\x0a\x09 \x09\x09separatedBy: [stream nextPutAll: ', '].\x0a stream := tmp.\x0a str nextPutAll: ']'.\x0a\x09\x09aBoolean ifTrue: [\x0a\x09\x09\x09str nextPutAll: ', smalltalk.', (self classNameFor: self currentClass), '.superclass || nil'].\x0a\x09\x09str nextPutAll: ')']",
  1444. messageSends: ["streamContents:", "nextPutAll:", ",", "asSelector", "do:separatedBy:", "visit:", "ifTrue:", "classNameFor:", "currentClass"],
  1445. referencedClasses: ["String"]
  1446. }),
  1447. smalltalk.FunCodeGenerator);
  1448. smalltalk.addMethod(
  1449. "_tempVariables",
  1450. smalltalk.method({
  1451. selector: "tempVariables",
  1452. category: 'accessing',
  1453. fn: function (){
  1454. var self=this;
  1455. var $1;
  1456. $1=smalltalk.send(self["@tempVariables"],"_copy",[]);
  1457. return $1;
  1458. },
  1459. args: [],
  1460. source: "tempVariables\x0a\x09^tempVariables copy",
  1461. messageSends: ["copy"],
  1462. referencedClasses: []
  1463. }),
  1464. smalltalk.FunCodeGenerator);
  1465. smalltalk.addMethod(
  1466. "_unknownVariables",
  1467. smalltalk.method({
  1468. selector: "unknownVariables",
  1469. category: 'accessing',
  1470. fn: function (){
  1471. var self=this;
  1472. var $1;
  1473. $1=smalltalk.send(self["@unknownVariables"],"_copy",[]);
  1474. return $1;
  1475. },
  1476. args: [],
  1477. source: "unknownVariables\x0a\x09^unknownVariables copy",
  1478. messageSends: ["copy"],
  1479. referencedClasses: []
  1480. }),
  1481. smalltalk.FunCodeGenerator);
  1482. smalltalk.addMethod(
  1483. "_visit_",
  1484. smalltalk.method({
  1485. selector: "visit:",
  1486. category: 'visiting',
  1487. fn: function (aNode){
  1488. var self=this;
  1489. smalltalk.send(aNode,"_accept_",[self]);
  1490. return self},
  1491. args: ["aNode"],
  1492. source: "visit: aNode\x0a\x09aNode accept: self",
  1493. messageSends: ["accept:"],
  1494. referencedClasses: []
  1495. }),
  1496. smalltalk.FunCodeGenerator);
  1497. smalltalk.addMethod(
  1498. "_visitAssignmentNode_",
  1499. smalltalk.method({
  1500. selector: "visitAssignmentNode:",
  1501. category: 'visiting',
  1502. fn: function (aNode){
  1503. var self=this;
  1504. smalltalk.send(self["@stream"],"_nextPutAll_",["("]);
  1505. smalltalk.send(self,"_visit_",[smalltalk.send(aNode,"_left",[])]);
  1506. smalltalk.send(self["@stream"],"_nextPutAll_",["="]);
  1507. smalltalk.send(self,"_visit_",[smalltalk.send(aNode,"_right",[])]);
  1508. smalltalk.send(self["@stream"],"_nextPutAll_",[")"]);
  1509. return self},
  1510. args: ["aNode"],
  1511. source: "visitAssignmentNode: aNode\x0a\x09stream nextPutAll: '('.\x0a\x09self visit: aNode left.\x0a\x09stream nextPutAll: '='.\x0a\x09self visit: aNode right.\x0a\x09stream nextPutAll: ')'",
  1512. messageSends: ["nextPutAll:", "visit:", "left", "right"],
  1513. referencedClasses: []
  1514. }),
  1515. smalltalk.FunCodeGenerator);
  1516. smalltalk.addMethod(
  1517. "_visitBlockNode_",
  1518. smalltalk.method({
  1519. selector: "visitBlockNode:",
  1520. category: 'visiting',
  1521. fn: function (aNode){
  1522. var self=this;
  1523. smalltalk.send(self["@stream"],"_nextPutAll_",["(function("]);
  1524. smalltalk.send(smalltalk.send(aNode,"_parameters",[]),"_do_separatedBy_",[(function(each){
  1525. smalltalk.send(self["@tempVariables"],"_add_",[each]);
  1526. return smalltalk.send(self["@stream"],"_nextPutAll_",[each]);
  1527. }),(function(){
  1528. return smalltalk.send(self["@stream"],"_nextPutAll_",[", "]);
  1529. })]);
  1530. smalltalk.send(self["@stream"],"_nextPutAll_",["){"]);
  1531. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_",[(function(each){
  1532. return smalltalk.send(self,"_visit_",[each]);
  1533. })]);
  1534. smalltalk.send(self["@stream"],"_nextPutAll_",["})"]);
  1535. return self},
  1536. args: ["aNode"],
  1537. source: "visitBlockNode: aNode\x0a\x09stream nextPutAll: '(function('.\x0a\x09aNode parameters \x0a\x09 do: [:each |\x0a\x09\x09tempVariables add: each.\x0a\x09\x09stream nextPutAll: each]\x0a\x09 separatedBy: [stream nextPutAll: ', '].\x0a\x09stream nextPutAll: '){'.\x0a\x09aNode nodes do: [:each | self visit: each].\x0a\x09stream nextPutAll: '})'",
  1538. messageSends: ["nextPutAll:", "do:separatedBy:", "add:", "parameters", "do:", "visit:", "nodes"],
  1539. referencedClasses: []
  1540. }),
  1541. smalltalk.FunCodeGenerator);
  1542. smalltalk.addMethod(
  1543. "_visitBlockSequenceNode_",
  1544. smalltalk.method({
  1545. selector: "visitBlockSequenceNode:",
  1546. category: 'visiting',
  1547. fn: function (aNode){
  1548. var self=this;
  1549. var $1,$2,$3;
  1550. var index;
  1551. self["@nestedBlocks"]=smalltalk.send(self["@nestedBlocks"],"__plus",[(1)]);
  1552. $1=smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_isEmpty",[]);
  1553. if(smalltalk.assert($1)){
  1554. smalltalk.send(self["@stream"],"_nextPutAll_",["return nil;"]);
  1555. } else {
  1556. smalltalk.send(smalltalk.send(aNode,"_temps",[]),"_do_",[(function(each){
  1557. var temp;
  1558. temp=smalltalk.send(self,"_safeVariableNameFor_",[each]);
  1559. temp;
  1560. smalltalk.send(self["@tempVariables"],"_add_",[temp]);
  1561. smalltalk.send(self["@stream"],"_nextPutAll_",[smalltalk.send(smalltalk.send("var ","__comma",[temp]),"__comma",["=nil;"])]);
  1562. $2=smalltalk.send(self["@stream"],"_lf",[]);
  1563. return $2;
  1564. })]);
  1565. index=(0);
  1566. index;
  1567. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_",[(function(each){
  1568. index=smalltalk.send(index,"__plus",[(1)]);
  1569. index;
  1570. $3=smalltalk.send(index,"__eq",[smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_size",[])]);
  1571. if(smalltalk.assert($3)){
  1572. smalltalk.send(self["@stream"],"_nextPutAll_",["return "]);
  1573. };
  1574. smalltalk.send(self,"_visit_",[each]);
  1575. return smalltalk.send(self["@stream"],"_nextPutAll_",[";"]);
  1576. })]);
  1577. };
  1578. self["@nestedBlocks"]=smalltalk.send(self["@nestedBlocks"],"__minus",[(1)]);
  1579. return self},
  1580. args: ["aNode"],
  1581. source: "visitBlockSequenceNode: aNode\x0a\x09| index |\x0a\x09nestedBlocks := nestedBlocks + 1.\x0a\x09aNode nodes isEmpty\x0a\x09 ifTrue: [\x0a\x09\x09stream nextPutAll: 'return nil;']\x0a\x09 ifFalse: [\x0a\x09\x09aNode temps do: [:each | | temp |\x0a temp := self safeVariableNameFor: each.\x0a\x09\x09 tempVariables add: temp.\x0a\x09\x09 stream nextPutAll: 'var ', temp, '=nil;'; lf].\x0a\x09\x09index := 0.\x0a\x09\x09aNode nodes do: [:each |\x0a\x09\x09 index := index + 1.\x0a\x09\x09 index = aNode nodes size ifTrue: [\x0a\x09\x09\x09stream nextPutAll: 'return '].\x0a\x09\x09 self visit: each.\x0a\x09\x09 stream nextPutAll: ';']].\x0a\x09nestedBlocks := nestedBlocks - 1",
  1582. messageSends: ["+", "ifTrue:ifFalse:", "nextPutAll:", "do:", "safeVariableNameFor:", "add:", ",", "lf", "temps", "ifTrue:", "=", "size", "nodes", "visit:", "isEmpty", "-"],
  1583. referencedClasses: []
  1584. }),
  1585. smalltalk.FunCodeGenerator);
  1586. smalltalk.addMethod(
  1587. "_visitCascadeNode_",
  1588. smalltalk.method({
  1589. selector: "visitCascadeNode:",
  1590. category: 'visiting',
  1591. fn: function (aNode){
  1592. var self=this;
  1593. var $1,$2;
  1594. var index;
  1595. index=(0);
  1596. $1=smalltalk.send(self["@tempVariables"],"_includes_",["$rec"]);
  1597. if(! smalltalk.assert($1)){
  1598. smalltalk.send(self["@tempVariables"],"_add_",["$rec"]);
  1599. };
  1600. smalltalk.send(self["@stream"],"_nextPutAll_",["(function($rec){"]);
  1601. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_",[(function(each){
  1602. index=smalltalk.send(index,"__plus",[(1)]);
  1603. index;
  1604. $2=smalltalk.send(index,"__eq",[smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_size",[])]);
  1605. if(smalltalk.assert($2)){
  1606. smalltalk.send(self["@stream"],"_nextPutAll_",["return "]);
  1607. };
  1608. smalltalk.send(each,"_receiver_",[smalltalk.send(smalltalk.send((smalltalk.VariableNode || VariableNode),"_new",[]),"_value_",["$rec"])]);
  1609. smalltalk.send(self,"_visit_",[each]);
  1610. return smalltalk.send(self["@stream"],"_nextPutAll_",[";"]);
  1611. })]);
  1612. smalltalk.send(self["@stream"],"_nextPutAll_",["})("]);
  1613. smalltalk.send(self,"_visit_",[smalltalk.send(aNode,"_receiver",[])]);
  1614. smalltalk.send(self["@stream"],"_nextPutAll_",[")"]);
  1615. return self},
  1616. args: ["aNode"],
  1617. source: "visitCascadeNode: aNode\x0a\x09| index |\x0a\x09index := 0.\x0a\x09(tempVariables includes: '$rec') ifFalse: [\x0a\x09\x09tempVariables add: '$rec'].\x0a\x09stream nextPutAll: '(function($rec){'.\x0a\x09aNode nodes do: [:each |\x0a\x09 index := index + 1.\x0a\x09 index = aNode nodes size ifTrue: [\x0a\x09\x09stream nextPutAll: 'return '].\x0a\x09 each receiver: (VariableNode new value: '$rec').\x0a\x09 self visit: each.\x0a\x09 stream nextPutAll: ';'].\x0a\x09stream nextPutAll: '})('.\x0a\x09self visit: aNode receiver.\x0a\x09stream nextPutAll: ')'",
  1618. messageSends: ["ifFalse:", "add:", "includes:", "nextPutAll:", "do:", "+", "ifTrue:", "=", "size", "nodes", "receiver:", "value:", "new", "visit:", "receiver"],
  1619. referencedClasses: ["VariableNode"]
  1620. }),
  1621. smalltalk.FunCodeGenerator);
  1622. smalltalk.addMethod(
  1623. "_visitClassReferenceNode_",
  1624. smalltalk.method({
  1625. selector: "visitClassReferenceNode:",
  1626. category: 'visiting',
  1627. fn: function (aNode){
  1628. var self=this;
  1629. var $1;
  1630. $1=smalltalk.send(self["@referencedClasses"],"_includes_",[smalltalk.send(aNode,"_value",[])]);
  1631. if(! smalltalk.assert($1)){
  1632. smalltalk.send(self["@referencedClasses"],"_add_",[smalltalk.send(aNode,"_value",[])]);
  1633. };
  1634. smalltalk.send(self["@stream"],"_nextPutAll_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(smalltalk.","__comma",[smalltalk.send(aNode,"_value",[])]),"__comma",[" || "]),"__comma",[smalltalk.send(aNode,"_value",[])]),"__comma",[")"])]);
  1635. return self},
  1636. args: ["aNode"],
  1637. source: "visitClassReferenceNode: aNode\x0a\x09(referencedClasses includes: aNode value) ifFalse: [\x0a\x09\x09referencedClasses add: aNode value].\x0a\x09stream nextPutAll: '(smalltalk.', aNode value, ' || ', aNode value, ')'",
  1638. messageSends: ["ifFalse:", "add:", "value", "includes:", "nextPutAll:", ","],
  1639. referencedClasses: []
  1640. }),
  1641. smalltalk.FunCodeGenerator);
  1642. smalltalk.addMethod(
  1643. "_visitDynamicArrayNode_",
  1644. smalltalk.method({
  1645. selector: "visitDynamicArrayNode:",
  1646. category: 'visiting',
  1647. fn: function (aNode){
  1648. var self=this;
  1649. smalltalk.send(self["@stream"],"_nextPutAll_",["["]);
  1650. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_separatedBy_",[(function(each){
  1651. return smalltalk.send(self,"_visit_",[each]);
  1652. }),(function(){
  1653. return smalltalk.send(self["@stream"],"_nextPutAll_",[","]);
  1654. })]);
  1655. smalltalk.send(self["@stream"],"_nextPutAll_",["]"]);
  1656. return self},
  1657. args: ["aNode"],
  1658. source: "visitDynamicArrayNode: aNode\x0a\x09stream nextPutAll: '['.\x0a\x09aNode nodes \x0a\x09\x09do: [:each | self visit: each]\x0a\x09\x09separatedBy: [stream nextPutAll: ','].\x0a\x09stream nextPutAll: ']'",
  1659. messageSends: ["nextPutAll:", "do:separatedBy:", "visit:", "nodes"],
  1660. referencedClasses: []
  1661. }),
  1662. smalltalk.FunCodeGenerator);
  1663. smalltalk.addMethod(
  1664. "_visitDynamicDictionaryNode_",
  1665. smalltalk.method({
  1666. selector: "visitDynamicDictionaryNode:",
  1667. category: 'visiting',
  1668. fn: function (aNode){
  1669. var self=this;
  1670. smalltalk.send(self["@stream"],"_nextPutAll_",["smalltalk.HashedCollection._fromPairs_(["]);
  1671. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_separatedBy_",[(function(each){
  1672. return smalltalk.send(self,"_visit_",[each]);
  1673. }),(function(){
  1674. return smalltalk.send(self["@stream"],"_nextPutAll_",[","]);
  1675. })]);
  1676. smalltalk.send(self["@stream"],"_nextPutAll_",["])"]);
  1677. return self},
  1678. args: ["aNode"],
  1679. source: "visitDynamicDictionaryNode: aNode\x0a\x09stream nextPutAll: 'smalltalk.HashedCollection._fromPairs_(['.\x0a\x09\x09aNode nodes \x0a\x09\x09\x09do: [:each | self visit: each]\x0a\x09\x09\x09separatedBy: [stream nextPutAll: ','].\x0a\x09\x09stream nextPutAll: '])'",
  1680. messageSends: ["nextPutAll:", "do:separatedBy:", "visit:", "nodes"],
  1681. referencedClasses: []
  1682. }),
  1683. smalltalk.FunCodeGenerator);
  1684. smalltalk.addMethod(
  1685. "_visitFailure_",
  1686. smalltalk.method({
  1687. selector: "visitFailure:",
  1688. category: 'visiting',
  1689. fn: function (aFailure){
  1690. var self=this;
  1691. smalltalk.send(self,"_error_",[smalltalk.send(aFailure,"_asString",[])]);
  1692. return self},
  1693. args: ["aFailure"],
  1694. source: "visitFailure: aFailure\x0a\x09self error: aFailure asString",
  1695. messageSends: ["error:", "asString"],
  1696. referencedClasses: []
  1697. }),
  1698. smalltalk.FunCodeGenerator);
  1699. smalltalk.addMethod(
  1700. "_visitJSStatementNode_",
  1701. smalltalk.method({
  1702. selector: "visitJSStatementNode:",
  1703. category: 'visiting',
  1704. fn: function (aNode){
  1705. var self=this;
  1706. smalltalk.send(self["@stream"],"_nextPutAll_",[smalltalk.send(aNode,"_source",[])]);
  1707. return self},
  1708. args: ["aNode"],
  1709. source: "visitJSStatementNode: aNode\x0a\x09stream nextPutAll: aNode source",
  1710. messageSends: ["nextPutAll:", "source"],
  1711. referencedClasses: []
  1712. }),
  1713. smalltalk.FunCodeGenerator);
  1714. smalltalk.addMethod(
  1715. "_visitMethodNode_",
  1716. smalltalk.method({
  1717. selector: "visitMethodNode:",
  1718. category: 'visiting',
  1719. fn: function (aNode) {
  1720. var self=this;
  1721. var str=nil;
  1722. var currentSelector=nil;
  1723. (self['@currentSelector']=smalltalk.send(smalltalk.send(aNode, "_selector", []), "_asSelector", []));
  1724. (self['@nestedBlocks']=(0));
  1725. (self['@earlyReturn']=false);
  1726. (self['@messageSends']=[]);
  1727. (self['@referencedClasses']=[]);
  1728. (self['@unknownVariables']=[]);
  1729. (self['@tempVariables']=[]);
  1730. (self['@argVariables']=[]);
  1731. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["smalltalk.method({"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("selector: \x22", "__comma", [smalltalk.send(aNode, "_selector", [])]), "__comma", ["\x22,"])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1732. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("source: ", "__comma", [smalltalk.send(smalltalk.send(self, "_source", []), "_asJavascript", [])]), "__comma", [","])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1733. smalltalk.send(self['@stream'], "_nextPutAll_", ["fn: function("]);
  1734. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_separatedBy_", [(function(each){smalltalk.send(self['@argVariables'], "_add_", [each]);return smalltalk.send(self['@stream'], "_nextPutAll_", [each]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [", "]);})]);
  1735. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["){"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", ["var self=this;"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1736. (str=self['@stream']);
  1737. (self['@stream']=smalltalk.send("", "_writeStream", []));
  1738. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);
  1739. ((($receiver = self['@earlyReturn']).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function($rec){smalltalk.send($rec, "_nextPutAll_", ["var $early={};"]);smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["try{"]);})(str);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function($rec){smalltalk.send($rec, "_nextPutAll_", ["var $early={};"]);smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["try{"]);})(str);})]));
  1740. smalltalk.send(str, "_nextPutAll_", [smalltalk.send(self['@stream'], "_contents", [])]);
  1741. (self['@stream']=str);
  1742. (function($rec){smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["return self;"]);})(self['@stream']);
  1743. ((($receiver = self['@earlyReturn']).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function($rec){smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["} catch(e) {if(e===$early)return e[0]; throw e}"]);})(self['@stream']);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function($rec){smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["} catch(e) {if(e===$early)return e[0]; throw e}"]);})(self['@stream']);})]));
  1744. smalltalk.send(self['@stream'], "_nextPutAll_", ["}"]);
  1745. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(",", "__comma", [smalltalk.send((smalltalk.String || String), "_lf", [])]), "__comma", ["messageSends: "])]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(self['@messageSends'], "_asJavascript", []), "__comma", [","])]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("args: ", "__comma", [smalltalk.send(self['@argVariables'], "_asJavascript", [])]), "__comma", [","])]);smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["referencedClasses: ["]);})(self['@stream']);
  1746. smalltalk.send(self['@referencedClasses'], "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(each, "_printString", [])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  1747. smalltalk.send(self['@stream'], "_nextPutAll_", ["]"]);
  1748. smalltalk.send(self['@stream'], "_nextPutAll_", ["})"]);
  1749. return self;},
  1750. args: ["aNode"],
  1751. source: "visitMethodNode: aNode\x0a\x09| str currentSelector | \x0a\x09currentSelector := aNode selector asSelector.\x0a\x09nestedBlocks := 0.\x0a\x09earlyReturn := false.\x0a\x09messageSends := #().\x0a\x09referencedClasses := #().\x0a\x09unknownVariables := #().\x0a\x09tempVariables := #().\x0a\x09argVariables := #().\x0a\x09stream \x0a\x09 nextPutAll: 'smalltalk.method({'; lf;\x0a\x09 nextPutAll: 'selector: \x22', aNode selector, '\x22,'; lf.\x0a\x09stream nextPutAll: 'source: ', self source asJavascript, ',';lf.\x0a\x09stream nextPutAll: 'fn: function('.\x0a\x09aNode arguments \x0a\x09 do: [:each | \x0a\x09\x09argVariables add: each.\x0a\x09\x09stream nextPutAll: each]\x0a\x09 separatedBy: [stream nextPutAll: ', '].\x0a\x09stream \x0a\x09 nextPutAll: '){'; lf;\x0a\x09 nextPutAll: 'var self=this;'; lf.\x0a\x09str := stream.\x0a\x09stream := '' writeStream.\x0a\x09aNode nodes do: [:each |\x0a\x09 self visit: each].\x0a\x09earlyReturn ifTrue: [\x0a\x09 str nextPutAll: 'var $early={};'; lf; nextPutAll: 'try{'].\x0a\x09str nextPutAll: stream contents.\x0a\x09stream := str.\x0a\x09stream \x0a\x09 lf; \x0a\x09 nextPutAll: 'return self;'.\x0a\x09earlyReturn ifTrue: [\x0a\x09 stream lf; nextPutAll: '} catch(e) {if(e===$early)return e[0]; throw e}'].\x0a\x09stream nextPutAll: '}'.\x0a\x09stream \x0a\x09\x09nextPutAll: ',', String lf, 'messageSends: ';\x0a\x09\x09nextPutAll: messageSends asJavascript, ','; lf;\x0a \x09nextPutAll: 'args: ', argVariables asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ['.\x0a\x09referencedClasses \x0a\x09\x09do: [:each | stream nextPutAll: each printString]\x0a\x09\x09separatedBy: [stream nextPutAll: ','].\x0a\x09stream nextPutAll: ']'.\x0a\x09stream nextPutAll: '})'",
  1752. messageSends: ["asSelector", "selector", "nextPutAll:", "lf", ",", "asJavascript", "source", "do:separatedBy:", "arguments", "add:", "writeStream", "do:", "nodes", "visit:", "ifTrue:", "contents", "printString"],
  1753. referencedClasses: ["String"]
  1754. }),
  1755. smalltalk.FunCodeGenerator);
  1756. smalltalk.addMethod(
  1757. "_visitReturnNode_",
  1758. smalltalk.method({
  1759. selector: "visitReturnNode:",
  1760. category: 'visiting',
  1761. fn: function (aNode) {
  1762. var self=this;
  1763. ((($receiver = ((($receiver = self['@nestedBlocks']).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (self['@earlyReturn']=true);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (self['@earlyReturn']=true);})]));
  1764. ((($receiver = ((($receiver = self['@nestedBlocks']).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(function(){throw $early=["]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["return "]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(function(){throw $early=["]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["return "]);})]));
  1765. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);
  1766. ((($receiver = ((($receiver = self['@nestedBlocks']).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["]})()"]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["]})()"]);})]));
  1767. return self;},
  1768. args: ["aNode"],
  1769. source: "visitReturnNode: aNode\x0a\x09nestedBlocks > 0 ifTrue: [\x0a\x09 earlyReturn := true].\x0a\x09nestedBlocks > 0\x0a\x09 ifTrue: [\x0a\x09\x09stream\x0a\x09\x09 nextPutAll: '(function(){throw $early=[']\x0a\x09 ifFalse: [stream nextPutAll: 'return '].\x0a\x09aNode nodes do: [:each |\x0a\x09 self visit: each].\x0a\x09nestedBlocks > 0 ifTrue: [\x0a\x09 stream nextPutAll: ']})()']",
  1770. messageSends: ["ifTrue:", ">", "ifTrue:ifFalse:", "nextPutAll:", "do:", "nodes", "visit:"],
  1771. referencedClasses: []
  1772. }),
  1773. smalltalk.FunCodeGenerator);
  1774. smalltalk.addMethod(
  1775. "_visitSendNode_",
  1776. smalltalk.method({
  1777. selector: "visitSendNode:",
  1778. category: 'visiting',
  1779. fn: function (aNode) {
  1780. var self=this;
  1781. var str=nil;
  1782. var receiver=nil;
  1783. var superSend=nil;
  1784. var inlined=nil;
  1785. (str=self['@stream']);
  1786. ((($receiver = smalltalk.send(self['@messageSends'], "_includes_", [smalltalk.send(aNode, "_selector", [])])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@messageSends'], "_add_", [smalltalk.send(aNode, "_selector", [])]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@messageSends'], "_add_", [smalltalk.send(aNode, "_selector", [])]);})]));
  1787. (self['@stream']=smalltalk.send("", "_writeStream", []));
  1788. smalltalk.send(self, "_visit_", [smalltalk.send(aNode, "_receiver", [])]);
  1789. (superSend=smalltalk.send(smalltalk.send(self['@stream'], "_contents", []), "__eq", ["super"]));
  1790. (receiver=((($receiver = superSend).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "self";})() : (function(){return smalltalk.send(self['@stream'], "_contents", []);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return "self";}), (function(){return smalltalk.send(self['@stream'], "_contents", []);})])));
  1791. (self['@stream']=str);
  1792. ((($receiver = smalltalk.send(self, "_performOptimizations", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return ((($receiver = smalltalk.send(self, "_inlineLiteral_receiverNode_argumentNodes_", [smalltalk.send(aNode, "_selector", []), smalltalk.send(aNode, "_receiver", []), smalltalk.send(aNode, "_arguments", [])])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return ((($receiver = smalltalk.send(self, "_inline_receiver_argumentNodes_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})]));})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return ((($receiver = smalltalk.send(self, "_inline_receiver_argumentNodes_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})]));})]));})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return ((($receiver = smalltalk.send(self, "_inlineLiteral_receiverNode_argumentNodes_", [smalltalk.send(aNode, "_selector", []), smalltalk.send(aNode, "_receiver", []), smalltalk.send(aNode, "_arguments", [])])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return ((($receiver = smalltalk.send(self, "_inline_receiver_argumentNodes_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})]));})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return ((($receiver = smalltalk.send(self, "_inline_receiver_argumentNodes_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(" : ", "__comma", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), "$receiver", smalltalk.send(aNode, "_arguments", []), superSend])]), "__comma", [")"])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})]));})]));}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(self, "_send_to_arguments_superSend_", [smalltalk.send(aNode, "_selector", []), receiver, smalltalk.send(aNode, "_arguments", []), superSend])]);})]));
  1793. return self;},
  1794. args: ["aNode"],
  1795. source: "visitSendNode: aNode\x0a | str receiver superSend inlined |\x0a str := stream.\x0a (messageSends includes: aNode selector) ifFalse: [\x0a messageSends add: aNode selector].\x0a stream := '' writeStream.\x0a self visit: aNode receiver.\x0a superSend := stream contents = 'super'.\x0a receiver := superSend ifTrue: ['self'] ifFalse: [stream contents].\x0a stream := str.\x0a\x09\x0a\x09self performOptimizations \x0a\x09\x09ifTrue: [\x0a\x09\x09\x09(self inlineLiteral: aNode selector receiverNode: aNode receiver argumentNodes: aNode arguments) ifFalse: [\x0a\x09\x09\x09\x09(self inline: aNode selector receiver: receiver argumentNodes: aNode arguments)\x0a \x09\x09\x09ifTrue: [stream nextPutAll: ' : ', (self send: aNode selector to: '$receiver' arguments: aNode arguments superSend: superSend), ')']\x0a \x09\x09\x09ifFalse: [stream nextPutAll: (self send: aNode selector to: receiver arguments: aNode arguments superSend: superSend)]]]\x0a\x09\x09ifFalse: [stream nextPutAll: (self send: aNode selector to: receiver arguments: aNode arguments superSend: superSend)]",
  1796. messageSends: ["ifFalse:", "includes:", "selector", "add:", "writeStream", "visit:", "receiver", "=", "contents", "ifTrue:ifFalse:", "performOptimizations", "inlineLiteral:receiverNode:argumentNodes:", "arguments", "inline:receiver:argumentNodes:", "nextPutAll:", ",", "send:to:arguments:superSend:"],
  1797. referencedClasses: []
  1798. }),
  1799. smalltalk.FunCodeGenerator);
  1800. smalltalk.addMethod(
  1801. "_visitSequenceNode_",
  1802. smalltalk.method({
  1803. selector: "visitSequenceNode:",
  1804. category: 'visiting',
  1805. fn: function (aNode) {
  1806. var self=this;
  1807. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [(function(each){var temp=nil;
  1808. (temp=smalltalk.send(self, "_safeVariableNameFor_", [each]));smalltalk.send(self['@tempVariables'], "_add_", [temp]);return (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("var ", "__comma", [temp]), "__comma", ["=nil;"])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);})]);
  1809. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_separatedBy_", [(function(each){smalltalk.send(self, "_visit_", [each]);return smalltalk.send(self['@stream'], "_nextPutAll_", [";"]);}), (function(){return smalltalk.send(self['@stream'], "_lf", []);})]);
  1810. return self;},
  1811. args: ["aNode"],
  1812. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [:each || temp |\x0a temp := self safeVariableNameFor: each.\x0a\x09 tempVariables add: temp.\x0a\x09 stream nextPutAll: 'var ', temp, '=nil;'; lf].\x0a\x09aNode nodes do: [:each |\x0a\x09 self visit: each.\x0a\x09 stream nextPutAll: ';']\x0a\x09 separatedBy: [stream lf]",
  1813. messageSends: ["do:", "temps", "safeVariableNameFor:", "add:", "nextPutAll:", ",", "lf", "do:separatedBy:", "nodes", "visit:"],
  1814. referencedClasses: []
  1815. }),
  1816. smalltalk.FunCodeGenerator);
  1817. smalltalk.addMethod(
  1818. "_visitValueNode_",
  1819. smalltalk.method({
  1820. selector: "visitValueNode:",
  1821. category: 'visiting',
  1822. fn: function (aNode) {
  1823. var self=this;
  1824. smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(aNode, "_value", []), "_asJavascript", [])]);
  1825. return self;},
  1826. args: ["aNode"],
  1827. source: "visitValueNode: aNode\x0a\x09stream nextPutAll: aNode value asJavascript",
  1828. messageSends: ["nextPutAll:", "asJavascript", "value"],
  1829. referencedClasses: []
  1830. }),
  1831. smalltalk.FunCodeGenerator);
  1832. smalltalk.addMethod(
  1833. "_visitVariableNode_",
  1834. smalltalk.method({
  1835. selector: "visitVariableNode:",
  1836. category: 'visiting',
  1837. fn: function (aNode) {
  1838. var self=this;
  1839. var varName=nil;
  1840. ((($receiver = smalltalk.send(smalltalk.send(smalltalk.send(self, "_currentClass", []), "_allInstanceVariableNames", []), "_includes_", [smalltalk.send(aNode, "_value", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send("self['@", "__comma", [smalltalk.send(aNode, "_value", [])]), "__comma", ["']"])]);})() : (function(){(varName=smalltalk.send(self, "_safeVariableNameFor_", [smalltalk.send(aNode, "_value", [])]));return ((($receiver = smalltalk.send(smalltalk.send(self, "_knownVariables", []), "_includes_", [varName])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){smalltalk.send(self['@unknownVariables'], "_add_", [smalltalk.send(aNode, "_value", [])]);return ((($receiver = smalltalk.send(aNode, "_assigned", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})]));})() : (function(){return ((($receiver = smalltalk.send(smalltalk.send(aNode, "_value", []), "__eq", ["thisContext"])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})]));})()) : smalltalk.send($receiver, "_ifFalse_ifTrue_", [(function(){smalltalk.send(self['@unknownVariables'], "_add_", [smalltalk.send(aNode, "_value", [])]);return ((($receiver = smalltalk.send(aNode, "_assigned", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})]));}), (function(){return ((($receiver = smalltalk.send(smalltalk.send(aNode, "_value", []), "__eq", ["thisContext"])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})]));})]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send("self['@", "__comma", [smalltalk.send(aNode, "_value", [])]), "__comma", ["']"])]);}), (function(){(varName=smalltalk.send(self, "_safeVariableNameFor_", [smalltalk.send(aNode, "_value", [])]));return ((($receiver = smalltalk.send(smalltalk.send(self, "_knownVariables", []), "_includes_", [varName])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){smalltalk.send(self['@unknownVariables'], "_add_", [smalltalk.send(aNode, "_value", [])]);return ((($receiver = smalltalk.send(aNode, "_assigned", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})]));})() : (function(){return ((($receiver = smalltalk.send(smalltalk.send(aNode, "_value", []), "__eq", ["thisContext"])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})]));})()) : smalltalk.send($receiver, "_ifFalse_ifTrue_", [(function(){smalltalk.send(self['@unknownVariables'], "_add_", [smalltalk.send(aNode, "_value", [])]);return ((($receiver = smalltalk.send(aNode, "_assigned", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(typeof ", "__comma", [varName]), "__comma", [" == 'undefined' ? nil : "]), "__comma", [varName]), "__comma", [")"])]);})]));}), (function(){return ((($receiver = smalltalk.send(smalltalk.send(aNode, "_value", []), "__eq", ["thisContext"])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);})() : (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@stream'], "_nextPutAll_", ["(smalltalk.getThisContext())"]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [varName]);})]));})]));})]));
  1841. return self;},
  1842. args: ["aNode"],
  1843. source: "visitVariableNode: aNode\x0a\x09| varName |\x0a\x09(self currentClass allInstanceVariableNames includes: aNode value) \x0a\x09\x09ifTrue: [stream nextPutAll: 'self[''@', aNode value, ''']']\x0a\x09\x09ifFalse: [\x0a \x09varName := self safeVariableNameFor: aNode value.\x0a\x09\x09\x09(self knownVariables includes: varName) \x0a \x09\x09ifFalse: [\x0a \x09unknownVariables add: aNode value.\x0a \x09aNode assigned \x0a \x09\x09ifTrue: [stream nextPutAll: varName]\x0a \x09\x09ifFalse: [stream nextPutAll: '(typeof ', varName, ' == ''undefined'' ? nil : ', varName, ')']]\x0a \x09\x09ifTrue: [\x0a \x09aNode value = 'thisContext'\x0a \x09\x09ifTrue: [stream nextPutAll: '(smalltalk.getThisContext())']\x0a \x09\x09\x09\x09ifFalse: [stream nextPutAll: varName]]]",
  1844. messageSends: ["ifTrue:ifFalse:", "includes:", "allInstanceVariableNames", "currentClass", "value", "nextPutAll:", ",", "safeVariableNameFor:", "ifFalse:ifTrue:", "knownVariables", "add:", "assigned", "="],
  1845. referencedClasses: []
  1846. }),
  1847. smalltalk.FunCodeGenerator);
  1848. smalltalk.FunCodeGenerator.klass.iVarNames = ['performOptimizations'];
  1849. smalltalk.addMethod(
  1850. "_performOptimizations",
  1851. smalltalk.method({
  1852. selector: "performOptimizations",
  1853. category: 'accessing',
  1854. fn: function () {
  1855. var self=this;
  1856. return (($receiver = self['@performOptimizations']) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver;
  1857. return self;},
  1858. args: [],
  1859. source: "performOptimizations\x0a\x09^performOptimizations ifNil: [true]",
  1860. messageSends: ["ifNil:"],
  1861. referencedClasses: []
  1862. }),
  1863. smalltalk.FunCodeGenerator.klass);
  1864. smalltalk.addMethod(
  1865. "_performOptimizations_",
  1866. smalltalk.method({
  1867. selector: "performOptimizations:",
  1868. category: 'accessing',
  1869. fn: function (aBoolean) {
  1870. var self=this;
  1871. (self['@performOptimizations']=aBoolean);
  1872. return self;},
  1873. args: ["aBoolean"],
  1874. source: "performOptimizations: aBoolean\x0a\x09performOptimizations := aBoolean",
  1875. messageSends: [],
  1876. referencedClasses: []
  1877. }),
  1878. smalltalk.FunCodeGenerator.klass);