Compiler-Core.js 97 KB

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