1
0

Compiler-Core.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. smalltalk.addPackage('Compiler-Core', {});
  2. smalltalk.addClass('Compiler', smalltalk.Object, ['currentClass', 'source', 'unknownVariables', 'codeGeneratorClass'], 'Compiler-Core');
  3. smalltalk.addMethod(
  4. "_codeGeneratorClass",
  5. smalltalk.method({
  6. selector: "codeGeneratorClass",
  7. category: 'accessing',
  8. fn: function () {
  9. var self=this;
  10. return (($receiver = self['@codeGeneratorClass']) == nil || $receiver == undefined) ? (function(){return (smalltalk.FunCodeGenerator || FunCodeGenerator);})() : $receiver;
  11. return self;},
  12. args: [],
  13. source: "codeGeneratorClass\x0a\x09^codeGeneratorClass ifNil: [FunCodeGenerator]",
  14. messageSends: ["ifNil:"],
  15. referencedClasses: ["FunCodeGenerator"]
  16. }),
  17. smalltalk.Compiler);
  18. smalltalk.addMethod(
  19. "_codeGeneratorClass_",
  20. smalltalk.method({
  21. selector: "codeGeneratorClass:",
  22. category: 'accessing',
  23. fn: function (aClass) {
  24. var self=this;
  25. (self['@codeGeneratorClass']=aClass);
  26. return self;},
  27. args: ["aClass"],
  28. source: "codeGeneratorClass: aClass\x0a\x09codeGeneratorClass := aClass",
  29. messageSends: [],
  30. referencedClasses: []
  31. }),
  32. smalltalk.Compiler);
  33. smalltalk.addMethod(
  34. "_compile_",
  35. smalltalk.method({
  36. selector: "compile:",
  37. category: 'compiling',
  38. fn: function (aString) {
  39. var self=this;
  40. return smalltalk.send(self, "_compileNode_", [smalltalk.send(self, "_parse_", [aString])]);
  41. return self;},
  42. args: ["aString"],
  43. source: "compile: aString\x0a\x09^self compileNode: (self parse: aString)",
  44. messageSends: ["compileNode:", "parse:"],
  45. referencedClasses: []
  46. }),
  47. smalltalk.Compiler);
  48. smalltalk.addMethod(
  49. "_compile_forClass_",
  50. smalltalk.method({
  51. selector: "compile:forClass:",
  52. category: 'compiling',
  53. fn: function (aString, aClass) {
  54. var self=this;
  55. smalltalk.send(self, "_currentClass_", [aClass]);
  56. smalltalk.send(self, "_source_", [aString]);
  57. return smalltalk.send(self, "_compile_", [aString]);
  58. return self;},
  59. args: ["aString", "aClass"],
  60. source: "compile: aString forClass: aClass\x0a\x09self currentClass: aClass.\x0a\x09self source: aString.\x0a\x09^self compile: aString",
  61. messageSends: ["currentClass:", "source:", "compile:"],
  62. referencedClasses: []
  63. }),
  64. smalltalk.Compiler);
  65. smalltalk.addMethod(
  66. "_compileExpression_",
  67. smalltalk.method({
  68. selector: "compileExpression:",
  69. category: 'compiling',
  70. fn: function (aString) {
  71. var self=this;
  72. smalltalk.send(self, "_currentClass_", [(smalltalk.DoIt || DoIt)]);
  73. smalltalk.send(self, "_source_", [smalltalk.send(smalltalk.send("doIt ^[", "__comma", [aString]), "__comma", ["] value"])]);
  74. return smalltalk.send(self, "_compileNode_", [smalltalk.send(self, "_parse_", [smalltalk.send(self, "_source", [])])]);
  75. return self;},
  76. args: ["aString"],
  77. source: "compileExpression: aString\x0a\x09self currentClass: DoIt.\x0a\x09self source: 'doIt ^[', aString, '] value'.\x0a\x09^self compileNode: (self parse: self source)",
  78. messageSends: ["currentClass:", "source:", ",", "compileNode:", "parse:", "source"],
  79. referencedClasses: ["DoIt"]
  80. }),
  81. smalltalk.Compiler);
  82. smalltalk.addMethod(
  83. "_compileNode_",
  84. smalltalk.method({
  85. selector: "compileNode:",
  86. category: 'compiling',
  87. fn: function (aNode) {
  88. var self=this;
  89. var generator=nil;
  90. var result=nil;
  91. (generator=smalltalk.send(smalltalk.send(self, "_codeGeneratorClass", []), "_new", []));
  92. (function($rec){smalltalk.send($rec, "_source_", [smalltalk.send(self, "_source", [])]);return smalltalk.send($rec, "_currentClass_", [smalltalk.send(self, "_currentClass", [])]);})(generator);
  93. (result=smalltalk.send(generator, "_compileNode_", [aNode]));
  94. smalltalk.send(self, "_unknownVariables_", [[]]);
  95. return result;
  96. return self;},
  97. args: ["aNode"],
  98. 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",
  99. messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "compileNode:", "unknownVariables:"],
  100. referencedClasses: []
  101. }),
  102. smalltalk.Compiler);
  103. smalltalk.addMethod(
  104. "_currentClass",
  105. smalltalk.method({
  106. selector: "currentClass",
  107. category: 'accessing',
  108. fn: function () {
  109. var self=this;
  110. return self['@currentClass'];
  111. return self;},
  112. args: [],
  113. source: "currentClass\x0a\x09^currentClass",
  114. messageSends: [],
  115. referencedClasses: []
  116. }),
  117. smalltalk.Compiler);
  118. smalltalk.addMethod(
  119. "_currentClass_",
  120. smalltalk.method({
  121. selector: "currentClass:",
  122. category: 'accessing',
  123. fn: function (aClass) {
  124. var self=this;
  125. (self['@currentClass']=aClass);
  126. return self;},
  127. args: ["aClass"],
  128. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  129. messageSends: [],
  130. referencedClasses: []
  131. }),
  132. smalltalk.Compiler);
  133. smalltalk.addMethod(
  134. "_eval_",
  135. smalltalk.method({
  136. selector: "eval:",
  137. category: 'compiling',
  138. fn: function (aString) {
  139. var self=this;
  140. return eval(aString);
  141. return self;},
  142. args: ["aString"],
  143. source: "eval: aString\x0a\x09<return eval(aString)>",
  144. messageSends: [],
  145. referencedClasses: []
  146. }),
  147. smalltalk.Compiler);
  148. smalltalk.addMethod(
  149. "_evaluateExpression_",
  150. smalltalk.method({
  151. selector: "evaluateExpression:",
  152. category: 'compiling',
  153. fn: function (aString) {
  154. var self=this;
  155. var result=nil;
  156. smalltalk.send((smalltalk.DoIt || DoIt), "_addCompiledMethod_", [smalltalk.send(self, "_eval_", [smalltalk.send(self, "_compileExpression_", [aString])])]);
  157. (result=smalltalk.send(smalltalk.send((smalltalk.DoIt || DoIt), "_new", []), "_doIt", []));
  158. smalltalk.send((smalltalk.DoIt || DoIt), "_removeCompiledMethod_", [smalltalk.send(smalltalk.send((smalltalk.DoIt || DoIt), "_methodDictionary", []), "_at_", ["doIt"])]);
  159. return result;
  160. return self;},
  161. args: ["aString"],
  162. 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",
  163. messageSends: ["addCompiledMethod:", "eval:", "compileExpression:", "doIt", "new", "removeCompiledMethod:", "at:", "methodDictionary"],
  164. referencedClasses: ["DoIt"]
  165. }),
  166. smalltalk.Compiler);
  167. smalltalk.addMethod(
  168. "_parse_",
  169. smalltalk.method({
  170. selector: "parse:",
  171. category: 'compiling',
  172. fn: function (aString) {
  173. var self=this;
  174. return smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_parse_", [aString]);
  175. return self;},
  176. args: ["aString"],
  177. source: "parse: aString\x0a ^Smalltalk current parse: aString",
  178. messageSends: ["parse:", "current"],
  179. referencedClasses: ["Smalltalk"]
  180. }),
  181. smalltalk.Compiler);
  182. smalltalk.addMethod(
  183. "_parseExpression_",
  184. smalltalk.method({
  185. selector: "parseExpression:",
  186. category: 'compiling',
  187. fn: function (aString) {
  188. var self=this;
  189. return smalltalk.send(self, "_parse_", [smalltalk.send(smalltalk.send("doIt ^[", "__comma", [aString]), "__comma", ["] value"])]);
  190. return self;},
  191. args: ["aString"],
  192. source: "parseExpression: aString\x0a ^self parse: 'doIt ^[', aString, '] value'",
  193. messageSends: ["parse:", ","],
  194. referencedClasses: []
  195. }),
  196. smalltalk.Compiler);
  197. smalltalk.addMethod(
  198. "_recompile_",
  199. smalltalk.method({
  200. selector: "recompile:",
  201. category: 'compiling',
  202. fn: function (aClass) {
  203. var self=this;
  204. smalltalk.send(smalltalk.send(aClass, "_methodDictionary", []), "_do_", [(function(each){return smalltalk.send(self, "_install_forClass_category_", [smalltalk.send(each, "_source", []), aClass, smalltalk.send(each, "_category", [])]);})]);
  205. smalltalk.send(self, "_setupClass_", [aClass]);
  206. ((($receiver = smalltalk.send(aClass, "_isMetaclass", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self, "_recompile_", [smalltalk.send(aClass, "_class", [])]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self, "_recompile_", [smalltalk.send(aClass, "_class", [])]);})]));
  207. return self;},
  208. args: ["aClass"],
  209. source: "recompile: aClass\x0a\x09aClass methodDictionary do: [:each |\x0a\x09\x09self install: each source forClass: aClass category: each category].\x0a\x09self setupClass: aClass.\x0a\x09aClass isMetaclass ifFalse: [self recompile: aClass class]",
  210. messageSends: ["do:", "methodDictionary", "install:forClass:category:", "source", "category", "setupClass:", "ifFalse:", "isMetaclass", "recompile:", "class"],
  211. referencedClasses: []
  212. }),
  213. smalltalk.Compiler);
  214. smalltalk.addMethod(
  215. "_recompileAll",
  216. smalltalk.method({
  217. selector: "recompileAll",
  218. category: 'compiling',
  219. fn: function () {
  220. var self=this;
  221. smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_classes", []), "_do_", [(function(each){(function($rec){smalltalk.send($rec, "_show_", [each]);return smalltalk.send($rec, "_cr", []);})((smalltalk.Transcript || Transcript));return smalltalk.send((function(){return smalltalk.send(self, "_recompile_", [each]);}), "_valueWithTimeout_", [(100)]);})]);
  222. return self;},
  223. args: [],
  224. source: "recompileAll\x0a\x09Smalltalk current classes do: [:each |\x0a\x09\x09Transcript show: each; cr.\x0a\x09\x09[self recompile: each] valueWithTimeout: 100]",
  225. messageSends: ["do:", "classes", "current", "show:", "cr", "valueWithTimeout:", "recompile:"],
  226. referencedClasses: ["Smalltalk", "Transcript"]
  227. }),
  228. smalltalk.Compiler);
  229. smalltalk.addMethod(
  230. "_setupClass_",
  231. smalltalk.method({
  232. selector: "setupClass:",
  233. category: 'compiling',
  234. fn: function (aClass) {
  235. var self=this;
  236. smalltalk.init(aClass);
  237. return self;},
  238. args: ["aClass"],
  239. source: "setupClass: aClass\x0a\x09<smalltalk.init(aClass)>",
  240. messageSends: [],
  241. referencedClasses: []
  242. }),
  243. smalltalk.Compiler);
  244. smalltalk.addMethod(
  245. "_source",
  246. smalltalk.method({
  247. selector: "source",
  248. category: 'accessing',
  249. fn: function () {
  250. var self=this;
  251. return (($receiver = self['@source']) == nil || $receiver == undefined) ? (function(){return "";})() : $receiver;
  252. return self;},
  253. args: [],
  254. source: "source\x0a\x09^source ifNil: ['']",
  255. messageSends: ["ifNil:"],
  256. referencedClasses: []
  257. }),
  258. smalltalk.Compiler);
  259. smalltalk.addMethod(
  260. "_source_",
  261. smalltalk.method({
  262. selector: "source:",
  263. category: 'accessing',
  264. fn: function (aString) {
  265. var self=this;
  266. (self['@source']=aString);
  267. return self;},
  268. args: ["aString"],
  269. source: "source: aString\x0a\x09source := aString",
  270. messageSends: [],
  271. referencedClasses: []
  272. }),
  273. smalltalk.Compiler);
  274. smalltalk.addMethod(
  275. "_unknownVariables",
  276. smalltalk.method({
  277. selector: "unknownVariables",
  278. category: 'accessing',
  279. fn: function () {
  280. var self=this;
  281. return self['@unknownVariables'];
  282. return self;},
  283. args: [],
  284. source: "unknownVariables\x0a\x09^unknownVariables",
  285. messageSends: [],
  286. referencedClasses: []
  287. }),
  288. smalltalk.Compiler);
  289. smalltalk.addMethod(
  290. "_unknownVariables_",
  291. smalltalk.method({
  292. selector: "unknownVariables:",
  293. category: 'accessing',
  294. fn: function (aCollection) {
  295. var self=this;
  296. (self['@unknownVariables']=aCollection);
  297. return self;},
  298. args: ["aCollection"],
  299. source: "unknownVariables: aCollection\x0a\x09unknownVariables := aCollection",
  300. messageSends: [],
  301. referencedClasses: []
  302. }),
  303. smalltalk.Compiler);
  304. smalltalk.addMethod(
  305. "_recompile_",
  306. smalltalk.method({
  307. selector: "recompile:",
  308. category: 'compiling',
  309. fn: function (aClass) {
  310. var self=this;
  311. smalltalk.send(smalltalk.send(self, "_new", []), "_recompile_", [aClass]);
  312. return self;},
  313. args: ["aClass"],
  314. source: "recompile: aClass\x0a\x09self new recompile: aClass",
  315. messageSends: ["recompile:", "new"],
  316. referencedClasses: []
  317. }),
  318. smalltalk.Compiler.klass);
  319. smalltalk.addMethod(
  320. "_recompileAll",
  321. smalltalk.method({
  322. selector: "recompileAll",
  323. category: 'compiling',
  324. fn: function () {
  325. var self=this;
  326. smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_classes", []), "_do_", [(function(each){return smalltalk.send(self, "_recompile_", [each]);})]);
  327. return self;},
  328. args: [],
  329. source: "recompileAll\x0a\x09Smalltalk current classes do: [:each |\x0a\x09\x09self recompile: each]",
  330. messageSends: ["do:", "classes", "current", "recompile:"],
  331. referencedClasses: ["Smalltalk"]
  332. }),
  333. smalltalk.Compiler.klass);
  334. smalltalk.addClass('DoIt', smalltalk.Object, [], 'Compiler-Core');
  335. smalltalk.addClass('JSStream', smalltalk.Object, ['stream'], 'Compiler-Core');
  336. smalltalk.addMethod(
  337. "_contents",
  338. smalltalk.method({
  339. selector: "contents",
  340. category: 'accessing',
  341. fn: function () {
  342. var self=this;
  343. return smalltalk.send(self['@stream'], "_contents", []);
  344. return self;},
  345. args: [],
  346. source: "contents\x0a\x09^ stream contents",
  347. messageSends: ["contents"],
  348. referencedClasses: []
  349. }),
  350. smalltalk.JSStream);
  351. smalltalk.addMethod(
  352. "_initialize",
  353. smalltalk.method({
  354. selector: "initialize",
  355. category: 'initialization',
  356. fn: function () {
  357. var self=this;
  358. smalltalk.send(self, "_initialize", [], smalltalk.JSStream.superclass || nil);
  359. (self['@stream']=smalltalk.send("", "_writeStream", []));
  360. return self;},
  361. args: [],
  362. source: "initialize\x0a\x09super initialize.\x0a\x09stream := '' writeStream.",
  363. messageSends: ["initialize", "writeStream"],
  364. referencedClasses: []
  365. }),
  366. smalltalk.JSStream);
  367. smalltalk.addMethod(
  368. "_lf",
  369. smalltalk.method({
  370. selector: "lf",
  371. category: 'streaming',
  372. fn: function () {
  373. var self=this;
  374. smalltalk.send(self['@stream'], "_lf", []);
  375. return self;},
  376. args: [],
  377. source: "lf\x0a\x09stream lf",
  378. messageSends: ["lf"],
  379. referencedClasses: []
  380. }),
  381. smalltalk.JSStream);
  382. smalltalk.addMethod(
  383. "_nextPut_",
  384. smalltalk.method({
  385. selector: "nextPut:",
  386. category: 'streaming',
  387. fn: function (aString) {
  388. var self=this;
  389. smalltalk.send(self['@stream'], "_nextPut_", [aString]);
  390. return self;},
  391. args: ["aString"],
  392. source: "nextPut: aString\x0a\x09stream nextPut: aString",
  393. messageSends: ["nextPut:"],
  394. referencedClasses: []
  395. }),
  396. smalltalk.JSStream);
  397. smalltalk.addMethod(
  398. "_nextPutAll_",
  399. smalltalk.method({
  400. selector: "nextPutAll:",
  401. category: 'streaming',
  402. fn: function (aString) {
  403. var self=this;
  404. smalltalk.send(self['@stream'], "_nextPutAll_", [aString]);
  405. return self;},
  406. args: ["aString"],
  407. source: "nextPutAll: aString\x0a\x09stream nextPutAll: aString",
  408. messageSends: ["nextPutAll:"],
  409. referencedClasses: []
  410. }),
  411. smalltalk.JSStream);
  412. smalltalk.addMethod(
  413. "_nextPutAssignment_to_",
  414. smalltalk.method({
  415. selector: "nextPutAssignment:to:",
  416. category: 'streaming',
  417. fn: function (varInstruction, valueInstruction) {
  418. var self=this;
  419. smalltalk.send(varInstruction, "_emitOn_", [self]);
  420. smalltalk.send(self['@stream'], "_nextPutAll_", ["="]);
  421. smalltalk.send(valueInstruction, "_emitOn_", [self]);
  422. return self;},
  423. args: ["varInstruction", "valueInstruction"],
  424. source: "nextPutAssignment: varInstruction to: valueInstruction\x0a\x09varInstruction emitOn: self.\x0a\x09stream nextPutAll: '='.\x0a\x09valueInstruction emitOn: self",
  425. messageSends: ["emitOn:", "nextPutAll:"],
  426. referencedClasses: []
  427. }),
  428. smalltalk.JSStream);
  429. smalltalk.addMethod(
  430. "_nextPutClosureWith_arguments_",
  431. smalltalk.method({
  432. selector: "nextPutClosureWith:arguments:",
  433. category: 'streaming',
  434. fn: function (aBlock, anArray) {
  435. var self=this;
  436. smalltalk.send(self['@stream'], "_nextPutAll_", ["(function("]);
  437. smalltalk.send(anArray, "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [each]);}), (function(){return smalltalk.send(self['@stream'], "_nextPut_", [","]);})]);
  438. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["){"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  439. smalltalk.send(aBlock, "_value", []);
  440. smalltalk.send(self['@stream'], "_nextPutAll_", ["})"]);
  441. return self;},
  442. args: ["aBlock", "anArray"],
  443. source: "nextPutClosureWith: aBlock arguments: anArray\x0a\x09stream nextPutAll: '(function('.\x0a\x09anArray \x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPut: ',' ].\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: '})'",
  444. messageSends: ["nextPutAll:", "do:separatedBy:", "nextPut:", "lf", "value"],
  445. referencedClasses: []
  446. }),
  447. smalltalk.JSStream);
  448. smalltalk.addMethod(
  449. "_nextPutFunctionWith_arguments_",
  450. smalltalk.method({
  451. selector: "nextPutFunctionWith:arguments:",
  452. category: 'streaming',
  453. fn: function (aBlock, anArray) {
  454. var self=this;
  455. smalltalk.send(self['@stream'], "_nextPutAll_", ["fn: function("]);
  456. smalltalk.send(anArray, "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [each]);}), (function(){return smalltalk.send(self['@stream'], "_nextPut_", [","]);})]);
  457. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["){"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  458. smalltalk.send(self, "_nextPutVar_", ["$return"]);
  459. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["var self=this;"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  460. smalltalk.send(aBlock, "_value", []);
  461. smalltalk.send(self['@stream'], "_nextPutAll_", ["return $return || self;}"]);
  462. return self;},
  463. args: ["aBlock", "anArray"],
  464. source: "nextPutFunctionWith: aBlock arguments: anArray\x0a\x09stream nextPutAll: 'fn: function('.\x0a\x09anArray \x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPut: ',' ].\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09self nextPutVar: '$return'.\x0a\x09stream nextPutAll: 'var self=this;'; lf.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: 'return $return || self;}'",
  465. messageSends: ["nextPutAll:", "do:separatedBy:", "nextPut:", "lf", "nextPutVar:", "value"],
  466. referencedClasses: []
  467. }),
  468. smalltalk.JSStream);
  469. smalltalk.addMethod(
  470. "_nextPutMethodDeclaration_with_",
  471. smalltalk.method({
  472. selector: "nextPutMethodDeclaration:with:",
  473. category: 'streaming',
  474. fn: function (aMethod, aBlock) {
  475. var self=this;
  476. (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(aMethod, "_selector", [])]), "__comma", ["\x22,"])]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("source: ", "__comma", [smalltalk.send(smalltalk.send(aMethod, "_source", []), "_asJavascript", [])]), "__comma", [","])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  477. smalltalk.send(aBlock, "_value", []);
  478. (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(smalltalk.send(smalltalk.send(aMethod, "_messageSends", []), "_asArray", []), "_asJavascript", []), "__comma", [","])]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("args: ", "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aMethod, "_arguments", []), "_collect_", [(function(each){return smalltalk.send(each, "_value", []);})]), "_asArray", []), "_asJavascript", [])]), "__comma", [","])]);smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["referencedClasses: ["]);})(self['@stream']);
  479. smalltalk.send(smalltalk.send(aMethod, "_classReferences", []), "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(each, "_asJavascript", [])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  480. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["]"]);return smalltalk.send($rec, "_nextPutAll_", ["})"]);})(self['@stream']);
  481. return self;},
  482. args: ["aMethod", "aBlock"],
  483. source: "nextPutMethodDeclaration: aMethod with: aBlock\x0a\x09stream \x0a\x09\x09nextPutAll: 'smalltalk.method({'; lf;\x0a\x09\x09nextPutAll: 'selector: \x22', aMethod selector, '\x22,'; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf.\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: ',', String lf, 'messageSends: ';\x0a\x09\x09nextPutAll: aMethod messageSends asArray asJavascript, ','; lf;\x0a \x09nextPutAll: 'args: ', (aMethod arguments collect: [ :each | each value ]) asArray asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ['.\x0a\x09aMethod classReferences \x0a\x09\x09do: [:each | stream nextPutAll: each asJavascript]\x0a\x09\x09separatedBy: [stream nextPutAll: ','].\x0a\x09stream \x0a\x09\x09nextPutAll: ']';\x0a\x09\x09nextPutAll: '})'",
  484. messageSends: ["nextPutAll:", "lf", ",", "selector", "asJavascript", "source", "value", "asArray", "messageSends", "collect:", "arguments", "do:separatedBy:", "classReferences"],
  485. referencedClasses: ["String"]
  486. }),
  487. smalltalk.JSStream);
  488. smalltalk.addMethod(
  489. "_nextPutNonLocalReturnHandlingWith_",
  490. smalltalk.method({
  491. selector: "nextPutNonLocalReturnHandlingWith:",
  492. category: 'streaming',
  493. fn: function (aBlock) {
  494. var self=this;
  495. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["var $early={};"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", ["try {"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  496. smalltalk.send(aBlock, "_value", []);
  497. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["}"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", ["catch(e) {if(e===$early)return e[0]; throw e}"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  498. return self;},
  499. args: ["aBlock"],
  500. source: "nextPutNonLocalReturnHandlingWith: aBlock\x0a\x09stream \x0a\x09\x09nextPutAll: 'var $early={};'; lf;\x0a\x09\x09nextPutAll: 'try {'; lf.\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: '}'; lf;\x0a\x09\x09nextPutAll: 'catch(e) {if(e===$early)return e[0]; throw e}'; lf",
  501. messageSends: ["nextPutAll:", "lf", "value"],
  502. referencedClasses: []
  503. }),
  504. smalltalk.JSStream);
  505. smalltalk.addMethod(
  506. "_nextPutNonLocalReturnWith_",
  507. smalltalk.method({
  508. selector: "nextPutNonLocalReturnWith:",
  509. category: 'streaming',
  510. fn: function (aBlock) {
  511. var self=this;
  512. smalltalk.send(self['@stream'], "_nextPutAll_", ["(function(){throw $early=["]);
  513. smalltalk.send(aBlock, "_value", []);
  514. smalltalk.send(self['@stream'], "_nextPutAll_", ["]})()"]);
  515. return self;},
  516. args: ["aBlock"],
  517. source: "nextPutNonLocalReturnWith: aBlock\x0a\x09stream nextPutAll: '(function(){throw $early=['.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: ']})()'",
  518. messageSends: ["nextPutAll:", "value"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.JSStream);
  522. smalltalk.addMethod(
  523. "_nextPutReturnWith_",
  524. smalltalk.method({
  525. selector: "nextPutReturnWith:",
  526. category: 'streaming',
  527. fn: function (aBlock) {
  528. var self=this;
  529. smalltalk.send(self['@stream'], "_nextPutAll_", ["$return="]);
  530. smalltalk.send(aBlock, "_value", []);
  531. return self;},
  532. args: ["aBlock"],
  533. source: "nextPutReturnWith: aBlock\x0a\x09stream nextPutAll: '$return='.\x0a\x09aBlock value",
  534. messageSends: ["nextPutAll:", "value"],
  535. referencedClasses: []
  536. }),
  537. smalltalk.JSStream);
  538. smalltalk.addMethod(
  539. "_nextPutSendTo_selector_arguments_",
  540. smalltalk.method({
  541. selector: "nextPutSendTo:selector:arguments:",
  542. category: 'streaming',
  543. fn: function (receiver, selector, arguments) {
  544. var self=this;
  545. smalltalk.send(self['@stream'], "_nextPutAll_", ["smalltalk.send("]);
  546. smalltalk.send(receiver, "_emitOn_", [self]);
  547. smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(",\x22", "__comma", [smalltalk.send(selector, "_asSelector", [])]), "__comma", ["\x22,["])]);
  548. smalltalk.send(arguments, "_do_separatedBy_", [(function(each){return smalltalk.send(each, "_emitOn_", [self]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  549. smalltalk.send(self['@stream'], "_nextPutAll_", ["])"]);
  550. return self;},
  551. args: ["receiver", "selector", "arguments"],
  552. source: "nextPutSendTo: receiver selector: selector arguments: arguments\x0a\x09stream nextPutAll: 'smalltalk.send('.\x0a\x09receiver emitOn: self. \x0a\x09stream nextPutAll: ',\x22', selector asSelector, '\x22,['.\x0a\x09arguments \x0a\x09\x09do: [ :each | each emitOn: self ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ',' ].\x0a\x09stream nextPutAll: '])'",
  553. messageSends: ["nextPutAll:", "emitOn:", ",", "asSelector", "do:separatedBy:"],
  554. referencedClasses: []
  555. }),
  556. smalltalk.JSStream);
  557. smalltalk.addMethod(
  558. "_nextPutSequenceWith_",
  559. smalltalk.method({
  560. selector: "nextPutSequenceWith:",
  561. category: 'streaming',
  562. fn: function (aBlock) {
  563. var self=this;
  564. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["switch(smalltalk.thisContext.pc){"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  565. smalltalk.send(aBlock, "_value", []);
  566. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["};"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  567. return self;},
  568. args: ["aBlock"],
  569. source: "nextPutSequenceWith: aBlock\x0a\x09stream \x0a\x09\x09nextPutAll: 'switch(smalltalk.thisContext.pc){'; lf.\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: '};'; lf",
  570. messageSends: ["nextPutAll:", "lf", "value"],
  571. referencedClasses: []
  572. }),
  573. smalltalk.JSStream);
  574. smalltalk.addMethod(
  575. "_nextPutStatement_with_",
  576. smalltalk.method({
  577. selector: "nextPutStatement:with:",
  578. category: 'streaming',
  579. fn: function (anInteger, aBlock) {
  580. var self=this;
  581. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("case ", "__comma", [smalltalk.send(anInteger, "_asString", [])]), "__comma", [":"])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  582. smalltalk.send(aBlock, "_value", []);
  583. (function($rec){smalltalk.send($rec, "_nextPutAll_", [";"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("smalltalk.thisContext.pc=", "__comma", [smalltalk.send(((($receiver = anInteger).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])), "_asString", [])]), "__comma", [";"])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  584. return self;},
  585. args: ["anInteger", "aBlock"],
  586. source: "nextPutStatement: anInteger with: aBlock\x0a\x09stream \x0a\x09\x09nextPutAll: 'case ', anInteger asString, ':'; lf.\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: ';'; lf;\x0a\x09\x09nextPutAll: 'smalltalk.thisContext.pc=', (anInteger + 1) asString, ';'; lf",
  587. messageSends: ["nextPutAll:", ",", "asString", "lf", "value", "+"],
  588. referencedClasses: []
  589. }),
  590. smalltalk.JSStream);
  591. smalltalk.addMethod(
  592. "_nextPutVar_",
  593. smalltalk.method({
  594. selector: "nextPutVar:",
  595. category: 'streaming',
  596. fn: function (aString) {
  597. var self=this;
  598. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("var ", "__comma", [aString]), "__comma", [";"])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  599. return self;},
  600. args: ["aString"],
  601. source: "nextPutVar: aString\x0a\x09stream nextPutAll: 'var ', aString, ';'; lf",
  602. messageSends: ["nextPutAll:", ",", "lf"],
  603. referencedClasses: []
  604. }),
  605. smalltalk.JSStream);
  606. smalltalk.addMethod(
  607. "_nextPutVars_",
  608. smalltalk.method({
  609. selector: "nextPutVars:",
  610. category: 'streaming',
  611. fn: function (aCollection) {
  612. var self=this;
  613. smalltalk.send(self['@stream'], "_nextPutAll_", ["var "]);
  614. smalltalk.send(aCollection, "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [each]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  615. (function($rec){smalltalk.send($rec, "_nextPutAll_", [";"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  616. return self;},
  617. args: ["aCollection"],
  618. source: "nextPutVars: aCollection\x0a\x09stream nextPutAll: 'var '.\x0a\x09aCollection \x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ',' ].\x0a\x09stream nextPutAll: ';'; lf",
  619. messageSends: ["nextPutAll:", "do:separatedBy:", "lf"],
  620. referencedClasses: []
  621. }),
  622. smalltalk.JSStream);
  623. smalltalk.addClass('NodeVisitor', smalltalk.Object, [], 'Compiler-Core');
  624. smalltalk.addMethod(
  625. "_visit_",
  626. smalltalk.method({
  627. selector: "visit:",
  628. category: 'visiting',
  629. fn: function (aNode) {
  630. var self=this;
  631. smalltalk.send(aNode, "_accept_", [self]);
  632. return self;},
  633. args: ["aNode"],
  634. source: "visit: aNode\x0a\x09aNode accept: self",
  635. messageSends: ["accept:"],
  636. referencedClasses: []
  637. }),
  638. smalltalk.NodeVisitor);
  639. smalltalk.addMethod(
  640. "_visitAll_",
  641. smalltalk.method({
  642. selector: "visitAll:",
  643. category: 'visiting',
  644. fn: function (aCollection) {
  645. var self=this;
  646. smalltalk.send(aCollection, "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);
  647. return self;},
  648. args: ["aCollection"],
  649. source: "visitAll: aCollection\x0a\x09aCollection do: [ :each | self visit: each ]",
  650. messageSends: ["do:", "visit:"],
  651. referencedClasses: []
  652. }),
  653. smalltalk.NodeVisitor);
  654. smalltalk.addMethod(
  655. "_visitAssignmentNode_",
  656. smalltalk.method({
  657. selector: "visitAssignmentNode:",
  658. category: 'visiting',
  659. fn: function (aNode) {
  660. var self=this;
  661. smalltalk.send(self, "_visitNode_", [aNode]);
  662. return self;},
  663. args: ["aNode"],
  664. source: "visitAssignmentNode: aNode\x0a\x09self visitNode: aNode",
  665. messageSends: ["visitNode:"],
  666. referencedClasses: []
  667. }),
  668. smalltalk.NodeVisitor);
  669. smalltalk.addMethod(
  670. "_visitBlockNode_",
  671. smalltalk.method({
  672. selector: "visitBlockNode:",
  673. category: 'visiting',
  674. fn: function (aNode) {
  675. var self=this;
  676. smalltalk.send(self, "_visitNode_", [aNode]);
  677. return self;},
  678. args: ["aNode"],
  679. source: "visitBlockNode: aNode\x0a\x09self visitNode: aNode",
  680. messageSends: ["visitNode:"],
  681. referencedClasses: []
  682. }),
  683. smalltalk.NodeVisitor);
  684. smalltalk.addMethod(
  685. "_visitBlockSequenceNode_",
  686. smalltalk.method({
  687. selector: "visitBlockSequenceNode:",
  688. category: 'visiting',
  689. fn: function (aNode) {
  690. var self=this;
  691. smalltalk.send(self, "_visitSequenceNode_", [aNode]);
  692. return self;},
  693. args: ["aNode"],
  694. source: "visitBlockSequenceNode: aNode\x0a\x09self visitSequenceNode: aNode",
  695. messageSends: ["visitSequenceNode:"],
  696. referencedClasses: []
  697. }),
  698. smalltalk.NodeVisitor);
  699. smalltalk.addMethod(
  700. "_visitCascadeNode_",
  701. smalltalk.method({
  702. selector: "visitCascadeNode:",
  703. category: 'visiting',
  704. fn: function (aNode) {
  705. var self=this;
  706. smalltalk.send(self, "_visitNode_", [aNode]);
  707. return self;},
  708. args: ["aNode"],
  709. source: "visitCascadeNode: aNode\x0a\x09self visitNode: aNode",
  710. messageSends: ["visitNode:"],
  711. referencedClasses: []
  712. }),
  713. smalltalk.NodeVisitor);
  714. smalltalk.addMethod(
  715. "_visitClassReferenceNode_",
  716. smalltalk.method({
  717. selector: "visitClassReferenceNode:",
  718. category: 'visiting',
  719. fn: function (aNode) {
  720. var self=this;
  721. smalltalk.send(self, "_visitNode_", [aNode]);
  722. return self;},
  723. args: ["aNode"],
  724. source: "visitClassReferenceNode: aNode\x0a\x09self visitNode: aNode",
  725. messageSends: ["visitNode:"],
  726. referencedClasses: []
  727. }),
  728. smalltalk.NodeVisitor);
  729. smalltalk.addMethod(
  730. "_visitDynamicArrayNode_",
  731. smalltalk.method({
  732. selector: "visitDynamicArrayNode:",
  733. category: 'visiting',
  734. fn: function (aNode) {
  735. var self=this;
  736. smalltalk.send(self, "_visitNode_", [aNode]);
  737. return self;},
  738. args: ["aNode"],
  739. source: "visitDynamicArrayNode: aNode\x0a\x09self visitNode: aNode",
  740. messageSends: ["visitNode:"],
  741. referencedClasses: []
  742. }),
  743. smalltalk.NodeVisitor);
  744. smalltalk.addMethod(
  745. "_visitDynamicDictionaryNode_",
  746. smalltalk.method({
  747. selector: "visitDynamicDictionaryNode:",
  748. category: 'visiting',
  749. fn: function (aNode) {
  750. var self=this;
  751. smalltalk.send(self, "_visitNode_", [aNode]);
  752. return self;},
  753. args: ["aNode"],
  754. source: "visitDynamicDictionaryNode: aNode\x0a\x09self visitNode: aNode",
  755. messageSends: ["visitNode:"],
  756. referencedClasses: []
  757. }),
  758. smalltalk.NodeVisitor);
  759. smalltalk.addMethod(
  760. "_visitJSStatementNode_",
  761. smalltalk.method({
  762. selector: "visitJSStatementNode:",
  763. category: 'visiting',
  764. fn: function (aNode) {
  765. var self=this;
  766. smalltalk.send(self, "_visitNode_", [aNode]);
  767. return self;},
  768. args: ["aNode"],
  769. source: "visitJSStatementNode: aNode\x0a\x09self visitNode: aNode",
  770. messageSends: ["visitNode:"],
  771. referencedClasses: []
  772. }),
  773. smalltalk.NodeVisitor);
  774. smalltalk.addMethod(
  775. "_visitMethodNode_",
  776. smalltalk.method({
  777. selector: "visitMethodNode:",
  778. category: 'visiting',
  779. fn: function (aNode) {
  780. var self=this;
  781. smalltalk.send(self, "_visitNode_", [aNode]);
  782. return self;},
  783. args: ["aNode"],
  784. source: "visitMethodNode: aNode\x0a\x09self visitNode: aNode",
  785. messageSends: ["visitNode:"],
  786. referencedClasses: []
  787. }),
  788. smalltalk.NodeVisitor);
  789. smalltalk.addMethod(
  790. "_visitNode_",
  791. smalltalk.method({
  792. selector: "visitNode:",
  793. category: 'visiting',
  794. fn: function (aNode) {
  795. var self=this;
  796. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);
  797. return self;},
  798. args: ["aNode"],
  799. source: "visitNode: aNode\x0a\x09aNode nodes do: [ :each | self visit: each ]",
  800. messageSends: ["do:", "nodes", "visit:"],
  801. referencedClasses: []
  802. }),
  803. smalltalk.NodeVisitor);
  804. smalltalk.addMethod(
  805. "_visitReturnNode_",
  806. smalltalk.method({
  807. selector: "visitReturnNode:",
  808. category: 'visiting',
  809. fn: function (aNode) {
  810. var self=this;
  811. smalltalk.send(self, "_visitNode_", [aNode]);
  812. return self;},
  813. args: ["aNode"],
  814. source: "visitReturnNode: aNode\x0a\x09self visitNode: aNode",
  815. messageSends: ["visitNode:"],
  816. referencedClasses: []
  817. }),
  818. smalltalk.NodeVisitor);
  819. smalltalk.addMethod(
  820. "_visitSendNode_",
  821. smalltalk.method({
  822. selector: "visitSendNode:",
  823. category: 'visiting',
  824. fn: function (aNode) {
  825. var self=this;
  826. smalltalk.send(self, "_visitNode_", [aNode]);
  827. return self;},
  828. args: ["aNode"],
  829. source: "visitSendNode: aNode\x0a\x09self visitNode: aNode",
  830. messageSends: ["visitNode:"],
  831. referencedClasses: []
  832. }),
  833. smalltalk.NodeVisitor);
  834. smalltalk.addMethod(
  835. "_visitSequenceNode_",
  836. smalltalk.method({
  837. selector: "visitSequenceNode:",
  838. category: 'visiting',
  839. fn: function (aNode) {
  840. var self=this;
  841. smalltalk.send(self, "_visitNode_", [aNode]);
  842. return self;},
  843. args: ["aNode"],
  844. source: "visitSequenceNode: aNode\x0a\x09self visitNode: aNode",
  845. messageSends: ["visitNode:"],
  846. referencedClasses: []
  847. }),
  848. smalltalk.NodeVisitor);
  849. smalltalk.addMethod(
  850. "_visitValueNode_",
  851. smalltalk.method({
  852. selector: "visitValueNode:",
  853. category: 'visiting',
  854. fn: function (aNode) {
  855. var self=this;
  856. smalltalk.send(self, "_visitNode_", [aNode]);
  857. return self;},
  858. args: ["aNode"],
  859. source: "visitValueNode: aNode\x0a\x09self visitNode: aNode",
  860. messageSends: ["visitNode:"],
  861. referencedClasses: []
  862. }),
  863. smalltalk.NodeVisitor);
  864. smalltalk.addMethod(
  865. "_visitVariableNode_",
  866. smalltalk.method({
  867. selector: "visitVariableNode:",
  868. category: 'visiting',
  869. fn: function (aNode) {
  870. var self=this;
  871. smalltalk.send(self, "_visitNode_", [aNode]);
  872. return self;},
  873. args: ["aNode"],
  874. source: "visitVariableNode: aNode\x0a\x09self visitNode: aNode",
  875. messageSends: ["visitNode:"],
  876. referencedClasses: []
  877. }),
  878. smalltalk.NodeVisitor);