Compiler-Core.deploy.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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. fn: function (){
  8. var self=this;
  9. return smalltalk.withContext(function($ctx1) { var $2,$1;
  10. $2=self["@codeGeneratorClass"];
  11. if(($receiver = $2) == nil || $receiver == undefined){
  12. $1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
  13. } else {
  14. $1=$2;
  15. };
  16. return $1;
  17. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.Compiler)})}
  18. }),
  19. smalltalk.Compiler);
  20. smalltalk.addMethod(
  21. "_codeGeneratorClass_",
  22. smalltalk.method({
  23. selector: "codeGeneratorClass:",
  24. fn: function (aClass){
  25. var self=this;
  26. return smalltalk.withContext(function($ctx1) { self["@codeGeneratorClass"]=aClass;
  27. return self}, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass:",{aClass:aClass}, smalltalk.Compiler)})}
  28. }),
  29. smalltalk.Compiler);
  30. smalltalk.addMethod(
  31. "_compile_",
  32. smalltalk.method({
  33. selector: "compile:",
  34. fn: function (aString){
  35. var self=this;
  36. return smalltalk.withContext(function($ctx1) { var $1;
  37. $1=_st(self)._compileNode_(_st(self)._parse_(aString));
  38. return $1;
  39. }, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString}, smalltalk.Compiler)})}
  40. }),
  41. smalltalk.Compiler);
  42. smalltalk.addMethod(
  43. "_compile_forClass_",
  44. smalltalk.method({
  45. selector: "compile:forClass:",
  46. fn: function (aString,aClass){
  47. var self=this;
  48. return smalltalk.withContext(function($ctx1) { var $1;
  49. _st(self)._currentClass_(aClass);
  50. _st(self)._source_(aString);
  51. $1=_st(self)._compile_(aString);
  52. return $1;
  53. }, function($ctx1) {$ctx1.fill(self,"compile:forClass:",{aString:aString,aClass:aClass}, smalltalk.Compiler)})}
  54. }),
  55. smalltalk.Compiler);
  56. smalltalk.addMethod(
  57. "_compileExpression_",
  58. smalltalk.method({
  59. selector: "compileExpression:",
  60. fn: function (aString){
  61. var self=this;
  62. return smalltalk.withContext(function($ctx1) { var $1;
  63. _st(self)._currentClass_((smalltalk.DoIt || DoIt));
  64. _st(self)._source_(_st(_st("doIt ^[").__comma(aString)).__comma("] value"));
  65. $1=_st(self)._compileNode_(_st(self)._parse_(_st(self)._source()));
  66. return $1;
  67. }, function($ctx1) {$ctx1.fill(self,"compileExpression:",{aString:aString}, smalltalk.Compiler)})}
  68. }),
  69. smalltalk.Compiler);
  70. smalltalk.addMethod(
  71. "_compileNode_",
  72. smalltalk.method({
  73. selector: "compileNode:",
  74. fn: function (aNode){
  75. var self=this;
  76. var generator,result;
  77. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  78. generator=_st(_st(self)._codeGeneratorClass())._new();
  79. $1=generator;
  80. _st($1)._source_(_st(self)._source());
  81. $2=_st($1)._currentClass_(_st(self)._currentClass());
  82. result=_st(generator)._compileNode_(aNode);
  83. _st(self)._unknownVariables_([]);
  84. $3=result;
  85. return $3;
  86. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,generator:generator,result:result}, smalltalk.Compiler)})}
  87. }),
  88. smalltalk.Compiler);
  89. smalltalk.addMethod(
  90. "_currentClass",
  91. smalltalk.method({
  92. selector: "currentClass",
  93. fn: function (){
  94. var self=this;
  95. return smalltalk.withContext(function($ctx1) { var $1;
  96. $1=self["@currentClass"];
  97. return $1;
  98. }, function($ctx1) {$ctx1.fill(self,"currentClass",{}, smalltalk.Compiler)})}
  99. }),
  100. smalltalk.Compiler);
  101. smalltalk.addMethod(
  102. "_currentClass_",
  103. smalltalk.method({
  104. selector: "currentClass:",
  105. fn: function (aClass){
  106. var self=this;
  107. return smalltalk.withContext(function($ctx1) { self["@currentClass"]=aClass;
  108. return self}, function($ctx1) {$ctx1.fill(self,"currentClass:",{aClass:aClass}, smalltalk.Compiler)})}
  109. }),
  110. smalltalk.Compiler);
  111. smalltalk.addMethod(
  112. "_eval_",
  113. smalltalk.method({
  114. selector: "eval:",
  115. fn: function (aString){
  116. var self=this;
  117. return smalltalk.withContext(function($ctx1) { return eval(aString);
  118. return self}, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString}, smalltalk.Compiler)})}
  119. }),
  120. smalltalk.Compiler);
  121. smalltalk.addMethod(
  122. "_evaluateExpression_",
  123. smalltalk.method({
  124. selector: "evaluateExpression:",
  125. fn: function (aString){
  126. var self=this;
  127. var result;
  128. return smalltalk.withContext(function($ctx1) { var $1;
  129. _st((smalltalk.DoIt || DoIt))._addCompiledMethod_(_st(self)._eval_(_st(self)._compileExpression_(aString)));
  130. result=_st(_st((smalltalk.DoIt || DoIt))._new())._doIt();
  131. _st((smalltalk.DoIt || DoIt))._removeCompiledMethod_(_st(_st((smalltalk.DoIt || DoIt))._methodDictionary())._at_("doIt"));
  132. $1=result;
  133. return $1;
  134. }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:",{aString:aString,result:result}, smalltalk.Compiler)})}
  135. }),
  136. smalltalk.Compiler);
  137. smalltalk.addMethod(
  138. "_install_forClass_category_",
  139. smalltalk.method({
  140. selector: "install:forClass:category:",
  141. fn: function (aString,aBehavior,anotherString){
  142. var self=this;
  143. var compiled;
  144. return smalltalk.withContext(function($ctx1) { var $1;
  145. compiled=_st(self)._eval_(_st(self)._compile_forClass_(aString,aBehavior));
  146. _st(compiled)._category_(anotherString);
  147. _st(aBehavior)._addCompiledMethod_(compiled);
  148. _st(self)._setupClass_(aBehavior);
  149. $1=compiled;
  150. return $1;
  151. }, function($ctx1) {$ctx1.fill(self,"install:forClass:category:",{aString:aString,aBehavior:aBehavior,anotherString:anotherString,compiled:compiled}, smalltalk.Compiler)})}
  152. }),
  153. smalltalk.Compiler);
  154. smalltalk.addMethod(
  155. "_parse_",
  156. smalltalk.method({
  157. selector: "parse:",
  158. fn: function (aString){
  159. var self=this;
  160. return smalltalk.withContext(function($ctx1) { var $1;
  161. $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._parse_(aString);
  162. return $1;
  163. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString}, smalltalk.Compiler)})}
  164. }),
  165. smalltalk.Compiler);
  166. smalltalk.addMethod(
  167. "_parseExpression_",
  168. smalltalk.method({
  169. selector: "parseExpression:",
  170. fn: function (aString){
  171. var self=this;
  172. return smalltalk.withContext(function($ctx1) { var $1;
  173. $1=_st(self)._parse_(_st(_st("doIt ^[").__comma(aString)).__comma("] value"));
  174. return $1;
  175. }, function($ctx1) {$ctx1.fill(self,"parseExpression:",{aString:aString}, smalltalk.Compiler)})}
  176. }),
  177. smalltalk.Compiler);
  178. smalltalk.addMethod(
  179. "_recompile_",
  180. smalltalk.method({
  181. selector: "recompile:",
  182. fn: function (aClass){
  183. var self=this;
  184. return smalltalk.withContext(function($ctx1) { var $1;
  185. _st(_st(aClass)._methodDictionary())._do_((function(each){
  186. return smalltalk.withContext(function($ctx2) { _st(console)._log_(_st(_st(_st(aClass)._name()).__comma(" >> ")).__comma(_st(each)._selector()));
  187. return _st(self)._install_forClass_category_(_st(each)._source(),aClass,_st(each)._category());
  188. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  189. _st(self)._setupClass_(aClass);
  190. $1=_st(aClass)._isMetaclass();
  191. if(! smalltalk.assert($1)){
  192. _st(self)._recompile_(_st(aClass)._class());
  193. };
  194. return self}, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass}, smalltalk.Compiler)})}
  195. }),
  196. smalltalk.Compiler);
  197. smalltalk.addMethod(
  198. "_recompileAll",
  199. smalltalk.method({
  200. selector: "recompileAll",
  201. fn: function (){
  202. var self=this;
  203. return smalltalk.withContext(function($ctx1) { var $1,$2;
  204. _st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._classes())._do_((function(each){
  205. return smalltalk.withContext(function($ctx2) { $1=(smalltalk.Transcript || Transcript);
  206. _st($1)._show_(each);
  207. $2=_st($1)._cr();
  208. $2;
  209. return _st((function(){
  210. return smalltalk.withContext(function($ctx3) { return _st(self)._recompile_(each);
  211. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._valueWithTimeout_((100));
  212. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  213. return self}, function($ctx1) {$ctx1.fill(self,"recompileAll",{}, smalltalk.Compiler)})}
  214. }),
  215. smalltalk.Compiler);
  216. smalltalk.addMethod(
  217. "_setupClass_",
  218. smalltalk.method({
  219. selector: "setupClass:",
  220. fn: function (aClass){
  221. var self=this;
  222. return smalltalk.withContext(function($ctx1) { smalltalk.init(aClass);
  223. return self}, function($ctx1) {$ctx1.fill(self,"setupClass:",{aClass:aClass}, smalltalk.Compiler)})}
  224. }),
  225. smalltalk.Compiler);
  226. smalltalk.addMethod(
  227. "_source",
  228. smalltalk.method({
  229. selector: "source",
  230. fn: function (){
  231. var self=this;
  232. return smalltalk.withContext(function($ctx1) { var $2,$1;
  233. $2=self["@source"];
  234. if(($receiver = $2) == nil || $receiver == undefined){
  235. $1="";
  236. } else {
  237. $1=$2;
  238. };
  239. return $1;
  240. }, function($ctx1) {$ctx1.fill(self,"source",{}, smalltalk.Compiler)})}
  241. }),
  242. smalltalk.Compiler);
  243. smalltalk.addMethod(
  244. "_source_",
  245. smalltalk.method({
  246. selector: "source:",
  247. fn: function (aString){
  248. var self=this;
  249. return smalltalk.withContext(function($ctx1) { self["@source"]=aString;
  250. return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString}, smalltalk.Compiler)})}
  251. }),
  252. smalltalk.Compiler);
  253. smalltalk.addMethod(
  254. "_unknownVariables",
  255. smalltalk.method({
  256. selector: "unknownVariables",
  257. fn: function (){
  258. var self=this;
  259. return smalltalk.withContext(function($ctx1) { var $1;
  260. $1=self["@unknownVariables"];
  261. return $1;
  262. }, function($ctx1) {$ctx1.fill(self,"unknownVariables",{}, smalltalk.Compiler)})}
  263. }),
  264. smalltalk.Compiler);
  265. smalltalk.addMethod(
  266. "_unknownVariables_",
  267. smalltalk.method({
  268. selector: "unknownVariables:",
  269. fn: function (aCollection){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx1) { self["@unknownVariables"]=aCollection;
  272. return self}, function($ctx1) {$ctx1.fill(self,"unknownVariables:",{aCollection:aCollection}, smalltalk.Compiler)})}
  273. }),
  274. smalltalk.Compiler);
  275. smalltalk.addMethod(
  276. "_recompile_",
  277. smalltalk.method({
  278. selector: "recompile:",
  279. fn: function (aClass){
  280. var self=this;
  281. return smalltalk.withContext(function($ctx1) { _st(_st(self)._new())._recompile_(aClass);
  282. return self}, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass}, smalltalk.Compiler.klass)})}
  283. }),
  284. smalltalk.Compiler.klass);
  285. smalltalk.addMethod(
  286. "_recompileAll",
  287. smalltalk.method({
  288. selector: "recompileAll",
  289. fn: function (){
  290. var self=this;
  291. return smalltalk.withContext(function($ctx1) { _st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._classes())._do_((function(each){
  292. return smalltalk.withContext(function($ctx2) { return _st(self)._recompile_(each);
  293. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  294. return self}, function($ctx1) {$ctx1.fill(self,"recompileAll",{}, smalltalk.Compiler.klass)})}
  295. }),
  296. smalltalk.Compiler.klass);
  297. smalltalk.addClass('DoIt', smalltalk.Object, [], 'Compiler-Core');
  298. smalltalk.addClass('NodeVisitor', smalltalk.Object, [], 'Compiler-Core');
  299. smalltalk.addMethod(
  300. "_visit_",
  301. smalltalk.method({
  302. selector: "visit:",
  303. fn: function (aNode){
  304. var self=this;
  305. return smalltalk.withContext(function($ctx1) { var $1;
  306. $1=_st(aNode)._accept_(self);
  307. return $1;
  308. }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  309. }),
  310. smalltalk.NodeVisitor);
  311. smalltalk.addMethod(
  312. "_visitAll_",
  313. smalltalk.method({
  314. selector: "visitAll:",
  315. fn: function (aCollection){
  316. var self=this;
  317. return smalltalk.withContext(function($ctx1) { var $1;
  318. $1=_st(aCollection)._collect_((function(each){
  319. return smalltalk.withContext(function($ctx2) { return _st(self)._visit_(each);
  320. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  321. return $1;
  322. }, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection}, smalltalk.NodeVisitor)})}
  323. }),
  324. smalltalk.NodeVisitor);
  325. smalltalk.addMethod(
  326. "_visitAssignmentNode_",
  327. smalltalk.method({
  328. selector: "visitAssignmentNode:",
  329. fn: function (aNode){
  330. var self=this;
  331. return smalltalk.withContext(function($ctx1) { var $1;
  332. $1=_st(self)._visitNode_(aNode);
  333. return $1;
  334. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  335. }),
  336. smalltalk.NodeVisitor);
  337. smalltalk.addMethod(
  338. "_visitBlockNode_",
  339. smalltalk.method({
  340. selector: "visitBlockNode:",
  341. fn: function (aNode){
  342. var self=this;
  343. return smalltalk.withContext(function($ctx1) { var $1;
  344. $1=_st(self)._visitNode_(aNode);
  345. return $1;
  346. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  347. }),
  348. smalltalk.NodeVisitor);
  349. smalltalk.addMethod(
  350. "_visitBlockSequenceNode_",
  351. smalltalk.method({
  352. selector: "visitBlockSequenceNode:",
  353. fn: function (aNode){
  354. var self=this;
  355. return smalltalk.withContext(function($ctx1) { var $1;
  356. $1=_st(self)._visitSequenceNode_(aNode);
  357. return $1;
  358. }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  359. }),
  360. smalltalk.NodeVisitor);
  361. smalltalk.addMethod(
  362. "_visitCascadeNode_",
  363. smalltalk.method({
  364. selector: "visitCascadeNode:",
  365. fn: function (aNode){
  366. var self=this;
  367. return smalltalk.withContext(function($ctx1) { var $1;
  368. $1=_st(self)._visitNode_(aNode);
  369. return $1;
  370. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  371. }),
  372. smalltalk.NodeVisitor);
  373. smalltalk.addMethod(
  374. "_visitClassReferenceNode_",
  375. smalltalk.method({
  376. selector: "visitClassReferenceNode:",
  377. fn: function (aNode){
  378. var self=this;
  379. return smalltalk.withContext(function($ctx1) { var $1;
  380. $1=_st(self)._visitVariableNode_(aNode);
  381. return $1;
  382. }, function($ctx1) {$ctx1.fill(self,"visitClassReferenceNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  383. }),
  384. smalltalk.NodeVisitor);
  385. smalltalk.addMethod(
  386. "_visitDynamicArrayNode_",
  387. smalltalk.method({
  388. selector: "visitDynamicArrayNode:",
  389. fn: function (aNode){
  390. var self=this;
  391. return smalltalk.withContext(function($ctx1) { var $1;
  392. $1=_st(self)._visitNode_(aNode);
  393. return $1;
  394. }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  395. }),
  396. smalltalk.NodeVisitor);
  397. smalltalk.addMethod(
  398. "_visitDynamicDictionaryNode_",
  399. smalltalk.method({
  400. selector: "visitDynamicDictionaryNode:",
  401. fn: function (aNode){
  402. var self=this;
  403. return smalltalk.withContext(function($ctx1) { var $1;
  404. $1=_st(self)._visitNode_(aNode);
  405. return $1;
  406. }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  407. }),
  408. smalltalk.NodeVisitor);
  409. smalltalk.addMethod(
  410. "_visitJSStatementNode_",
  411. smalltalk.method({
  412. selector: "visitJSStatementNode:",
  413. fn: function (aNode){
  414. var self=this;
  415. return smalltalk.withContext(function($ctx1) { var $1;
  416. $1=_st(self)._visitNode_(aNode);
  417. return $1;
  418. }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  419. }),
  420. smalltalk.NodeVisitor);
  421. smalltalk.addMethod(
  422. "_visitMethodNode_",
  423. smalltalk.method({
  424. selector: "visitMethodNode:",
  425. fn: function (aNode){
  426. var self=this;
  427. return smalltalk.withContext(function($ctx1) { var $1;
  428. $1=_st(self)._visitNode_(aNode);
  429. return $1;
  430. }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  431. }),
  432. smalltalk.NodeVisitor);
  433. smalltalk.addMethod(
  434. "_visitNode_",
  435. smalltalk.method({
  436. selector: "visitNode:",
  437. fn: function (aNode){
  438. var self=this;
  439. return smalltalk.withContext(function($ctx1) { var $1;
  440. $1=_st(self)._visitAll_(_st(aNode)._nodes());
  441. return $1;
  442. }, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  443. }),
  444. smalltalk.NodeVisitor);
  445. smalltalk.addMethod(
  446. "_visitReturnNode_",
  447. smalltalk.method({
  448. selector: "visitReturnNode:",
  449. fn: function (aNode){
  450. var self=this;
  451. return smalltalk.withContext(function($ctx1) { var $1;
  452. $1=_st(self)._visitNode_(aNode);
  453. return $1;
  454. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  455. }),
  456. smalltalk.NodeVisitor);
  457. smalltalk.addMethod(
  458. "_visitSendNode_",
  459. smalltalk.method({
  460. selector: "visitSendNode:",
  461. fn: function (aNode){
  462. var self=this;
  463. return smalltalk.withContext(function($ctx1) { var $1;
  464. $1=_st(self)._visitNode_(aNode);
  465. return $1;
  466. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  467. }),
  468. smalltalk.NodeVisitor);
  469. smalltalk.addMethod(
  470. "_visitSequenceNode_",
  471. smalltalk.method({
  472. selector: "visitSequenceNode:",
  473. fn: function (aNode){
  474. var self=this;
  475. return smalltalk.withContext(function($ctx1) { var $1;
  476. $1=_st(self)._visitNode_(aNode);
  477. return $1;
  478. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  479. }),
  480. smalltalk.NodeVisitor);
  481. smalltalk.addMethod(
  482. "_visitValueNode_",
  483. smalltalk.method({
  484. selector: "visitValueNode:",
  485. fn: function (aNode){
  486. var self=this;
  487. return smalltalk.withContext(function($ctx1) { var $1;
  488. $1=_st(self)._visitNode_(aNode);
  489. return $1;
  490. }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  491. }),
  492. smalltalk.NodeVisitor);
  493. smalltalk.addMethod(
  494. "_visitVariableNode_",
  495. smalltalk.method({
  496. selector: "visitVariableNode:",
  497. fn: function (aNode){
  498. var self=this;
  499. return smalltalk.withContext(function($ctx1) { var $1;
  500. $1=_st(self)._visitNode_(aNode);
  501. return $1;
  502. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode}, smalltalk.NodeVisitor)})}
  503. }),
  504. smalltalk.NodeVisitor);
  505. smalltalk.addClass('AbstractCodeGenerator', smalltalk.NodeVisitor, ['currentClass', 'source'], 'Compiler-Core');
  506. smalltalk.addMethod(
  507. "_classNameFor_",
  508. smalltalk.method({
  509. selector: "classNameFor:",
  510. fn: function (aClass){
  511. var self=this;
  512. return smalltalk.withContext(function($ctx1) { var $2,$3,$5,$4,$1;
  513. $2=_st(aClass)._isMetaclass();
  514. $3=(function(){
  515. return smalltalk.withContext(function($ctx2) { return _st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
  516. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  517. $4=(function(){
  518. return smalltalk.withContext(function($ctx2) { $5=_st(aClass)._isNil();
  519. if(smalltalk.assert($5)){
  520. return "nil";
  521. } else {
  522. return _st(aClass)._name();
  523. };
  524. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  525. $1=_st($2)._ifTrue_ifFalse_($3,$4);
  526. return $1;
  527. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass}, smalltalk.AbstractCodeGenerator)})}
  528. }),
  529. smalltalk.AbstractCodeGenerator);
  530. smalltalk.addMethod(
  531. "_compileNode_",
  532. smalltalk.method({
  533. selector: "compileNode:",
  534. fn: function (aNode){
  535. var self=this;
  536. return smalltalk.withContext(function($ctx1) { _st(self)._subclassResponsibility();
  537. return self}, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode}, smalltalk.AbstractCodeGenerator)})}
  538. }),
  539. smalltalk.AbstractCodeGenerator);
  540. smalltalk.addMethod(
  541. "_currentClass",
  542. smalltalk.method({
  543. selector: "currentClass",
  544. fn: function (){
  545. var self=this;
  546. return smalltalk.withContext(function($ctx1) { var $1;
  547. $1=self["@currentClass"];
  548. return $1;
  549. }, function($ctx1) {$ctx1.fill(self,"currentClass",{}, smalltalk.AbstractCodeGenerator)})}
  550. }),
  551. smalltalk.AbstractCodeGenerator);
  552. smalltalk.addMethod(
  553. "_currentClass_",
  554. smalltalk.method({
  555. selector: "currentClass:",
  556. fn: function (aClass){
  557. var self=this;
  558. return smalltalk.withContext(function($ctx1) { self["@currentClass"]=aClass;
  559. return self}, function($ctx1) {$ctx1.fill(self,"currentClass:",{aClass:aClass}, smalltalk.AbstractCodeGenerator)})}
  560. }),
  561. smalltalk.AbstractCodeGenerator);
  562. smalltalk.addMethod(
  563. "_pseudoVariables",
  564. smalltalk.method({
  565. selector: "pseudoVariables",
  566. fn: function (){
  567. var self=this;
  568. return smalltalk.withContext(function($ctx1) { return ["self", "super", "true", "false", "nil", "thisContext"];
  569. }, function($ctx1) {$ctx1.fill(self,"pseudoVariables",{}, smalltalk.AbstractCodeGenerator)})}
  570. }),
  571. smalltalk.AbstractCodeGenerator);
  572. smalltalk.addMethod(
  573. "_safeVariableNameFor_",
  574. smalltalk.method({
  575. selector: "safeVariableNameFor:",
  576. fn: function (aString){
  577. var self=this;
  578. return smalltalk.withContext(function($ctx1) { var $2,$1;
  579. $2=_st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._reservedWords())._includes_(aString);
  580. if(smalltalk.assert($2)){
  581. $1=_st(aString).__comma("_");
  582. } else {
  583. $1=aString;
  584. };
  585. return $1;
  586. }, function($ctx1) {$ctx1.fill(self,"safeVariableNameFor:",{aString:aString}, smalltalk.AbstractCodeGenerator)})}
  587. }),
  588. smalltalk.AbstractCodeGenerator);
  589. smalltalk.addMethod(
  590. "_source",
  591. smalltalk.method({
  592. selector: "source",
  593. fn: function (){
  594. var self=this;
  595. return smalltalk.withContext(function($ctx1) { var $2,$1;
  596. $2=self["@source"];
  597. if(($receiver = $2) == nil || $receiver == undefined){
  598. $1="";
  599. } else {
  600. $1=$2;
  601. };
  602. return $1;
  603. }, function($ctx1) {$ctx1.fill(self,"source",{}, smalltalk.AbstractCodeGenerator)})}
  604. }),
  605. smalltalk.AbstractCodeGenerator);
  606. smalltalk.addMethod(
  607. "_source_",
  608. smalltalk.method({
  609. selector: "source:",
  610. fn: function (aString){
  611. var self=this;
  612. return smalltalk.withContext(function($ctx1) { self["@source"]=aString;
  613. return self}, function($ctx1) {$ctx1.fill(self,"source:",{aString:aString}, smalltalk.AbstractCodeGenerator)})}
  614. }),
  615. smalltalk.AbstractCodeGenerator);
  616. smalltalk.addClass('CodeGenerator', smalltalk.AbstractCodeGenerator, [], 'Compiler-Core');
  617. smalltalk.addMethod(
  618. "_compileNode_",
  619. smalltalk.method({
  620. selector: "compileNode:",
  621. fn: function (aNode){
  622. var self=this;
  623. var ir,stream;
  624. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  625. _st(_st(self)._semanticAnalyzer())._visit_(aNode);
  626. ir=_st(_st(self)._translator())._visit_(aNode);
  627. $2=_st(self)._irTranslator();
  628. _st($2)._visit_(ir);
  629. $3=_st($2)._contents();
  630. $1=$3;
  631. return $1;
  632. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream}, smalltalk.CodeGenerator)})}
  633. }),
  634. smalltalk.CodeGenerator);
  635. smalltalk.addMethod(
  636. "_irTranslator",
  637. smalltalk.method({
  638. selector: "irTranslator",
  639. fn: function (){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) { var $1;
  642. $1=_st((smalltalk.IRJSTranslator || IRJSTranslator))._new();
  643. return $1;
  644. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{}, smalltalk.CodeGenerator)})}
  645. }),
  646. smalltalk.CodeGenerator);
  647. smalltalk.addMethod(
  648. "_semanticAnalyzer",
  649. smalltalk.method({
  650. selector: "semanticAnalyzer",
  651. fn: function (){
  652. var self=this;
  653. return smalltalk.withContext(function($ctx1) { var $1;
  654. $1=_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_(_st(self)._currentClass());
  655. return $1;
  656. }, function($ctx1) {$ctx1.fill(self,"semanticAnalyzer",{}, smalltalk.CodeGenerator)})}
  657. }),
  658. smalltalk.CodeGenerator);
  659. smalltalk.addMethod(
  660. "_translator",
  661. smalltalk.method({
  662. selector: "translator",
  663. fn: function (){
  664. var self=this;
  665. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  666. $2=_st((smalltalk.IRASTTranslator || IRASTTranslator))._new();
  667. _st($2)._source_(_st(self)._source());
  668. _st($2)._theClass_(_st(self)._currentClass());
  669. $3=_st($2)._yourself();
  670. $1=$3;
  671. return $1;
  672. }, function($ctx1) {$ctx1.fill(self,"translator",{}, smalltalk.CodeGenerator)})}
  673. }),
  674. smalltalk.CodeGenerator);