Compiler-Core.deploy.js 19 KB

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