Compiler-Core.deploy.js 21 KB

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