1
0

Compiler-Core.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Infrastructure", "amber_core/Kernel-Collections"], function($boot){
  2. var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
  3. smalltalk.addPackage('Compiler-Core');
  4. smalltalk.packages["Compiler-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
  5. smalltalk.addClass('AbstractCodeGenerator', globals.Object, ['currentClass', 'source'], 'Compiler-Core');
  6. globals.AbstractCodeGenerator.comment="I am the abstract super class of all code generators and provide their common API.";
  7. smalltalk.addMethod(
  8. smalltalk.method({
  9. selector: "classNameFor:",
  10. protocol: 'accessing',
  11. fn: function (aClass){
  12. var self=this;
  13. return smalltalk.withContext(function($ctx1) {
  14. var $2,$3,$4,$1;
  15. $2=_st(aClass)._isMetaclass();
  16. if(smalltalk.assert($2)){
  17. $3=_st(_st(aClass)._instanceClass())._name();
  18. $ctx1.sendIdx["name"]=1;
  19. $1=_st($3).__comma(".klass");
  20. } else {
  21. $4=_st(aClass)._isNil();
  22. if(smalltalk.assert($4)){
  23. $1="nil";
  24. } else {
  25. $1=_st(aClass)._name();
  26. };
  27. };
  28. return $1;
  29. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},globals.AbstractCodeGenerator)});
  30. },
  31. args: ["aClass"],
  32. source: "classNameFor: aClass\x0a\x09^ aClass isMetaclass\x0a\x09\x09ifTrue: [ aClass instanceClass name, '.klass' ]\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: [ 'nil' ]\x0a\x09\x09\x09ifFalse: [ aClass name ]]",
  33. messageSends: ["ifTrue:ifFalse:", "isMetaclass", ",", "name", "instanceClass", "isNil"],
  34. referencedClasses: []
  35. }),
  36. globals.AbstractCodeGenerator);
  37. smalltalk.addMethod(
  38. smalltalk.method({
  39. selector: "compileNode:",
  40. protocol: 'compiling',
  41. fn: function (aNode){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx1) {
  44. self._subclassResponsibility();
  45. return self}, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode},globals.AbstractCodeGenerator)});
  46. },
  47. args: ["aNode"],
  48. source: "compileNode: aNode\x0a\x09self subclassResponsibility",
  49. messageSends: ["subclassResponsibility"],
  50. referencedClasses: []
  51. }),
  52. globals.AbstractCodeGenerator);
  53. smalltalk.addMethod(
  54. smalltalk.method({
  55. selector: "currentClass",
  56. protocol: 'accessing',
  57. fn: function (){
  58. var self=this;
  59. var $1;
  60. $1=self["@currentClass"];
  61. return $1;
  62. },
  63. args: [],
  64. source: "currentClass\x0a\x09^ currentClass",
  65. messageSends: [],
  66. referencedClasses: []
  67. }),
  68. globals.AbstractCodeGenerator);
  69. smalltalk.addMethod(
  70. smalltalk.method({
  71. selector: "currentClass:",
  72. protocol: 'accessing',
  73. fn: function (aClass){
  74. var self=this;
  75. self["@currentClass"]=aClass;
  76. return self
  77. },
  78. args: ["aClass"],
  79. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  80. messageSends: [],
  81. referencedClasses: []
  82. }),
  83. globals.AbstractCodeGenerator);
  84. smalltalk.addMethod(
  85. smalltalk.method({
  86. selector: "pseudoVariables",
  87. protocol: 'accessing',
  88. fn: function (){
  89. var self=this;
  90. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  91. return smalltalk.withContext(function($ctx1) {
  92. var $1;
  93. $1=_st($Smalltalk())._pseudoVariableNames();
  94. return $1;
  95. }, function($ctx1) {$ctx1.fill(self,"pseudoVariables",{},globals.AbstractCodeGenerator)});
  96. },
  97. args: [],
  98. source: "pseudoVariables\x0a\x09^ Smalltalk pseudoVariableNames",
  99. messageSends: ["pseudoVariableNames"],
  100. referencedClasses: ["Smalltalk"]
  101. }),
  102. globals.AbstractCodeGenerator);
  103. smalltalk.addMethod(
  104. smalltalk.method({
  105. selector: "source",
  106. protocol: 'accessing',
  107. fn: function (){
  108. var self=this;
  109. return smalltalk.withContext(function($ctx1) {
  110. var $2,$1,$receiver;
  111. $2=self["@source"];
  112. if(($receiver = $2) == null || $receiver.isNil){
  113. $1="";
  114. } else {
  115. $1=$2;
  116. };
  117. return $1;
  118. }, function($ctx1) {$ctx1.fill(self,"source",{},globals.AbstractCodeGenerator)});
  119. },
  120. args: [],
  121. source: "source\x0a\x09^ source ifNil: [ '' ]",
  122. messageSends: ["ifNil:"],
  123. referencedClasses: []
  124. }),
  125. globals.AbstractCodeGenerator);
  126. smalltalk.addMethod(
  127. smalltalk.method({
  128. selector: "source:",
  129. protocol: 'accessing',
  130. fn: function (aString){
  131. var self=this;
  132. self["@source"]=aString;
  133. return self
  134. },
  135. args: ["aString"],
  136. source: "source: aString\x0a\x09source := aString",
  137. messageSends: [],
  138. referencedClasses: []
  139. }),
  140. globals.AbstractCodeGenerator);
  141. smalltalk.addClass('CodeGenerator', globals.AbstractCodeGenerator, [], 'Compiler-Core');
  142. globals.CodeGenerator.comment="I am a basic code generator. I generate a valid JavaScript output, but no not perform any inlining.\x0aSee `InliningCodeGenerator` for an optimized JavaScript code generation.";
  143. smalltalk.addMethod(
  144. smalltalk.method({
  145. selector: "compileNode:",
  146. protocol: 'compiling',
  147. fn: function (aNode){
  148. var self=this;
  149. var ir,stream;
  150. return smalltalk.withContext(function($ctx1) {
  151. var $2,$3,$1;
  152. _st(self._semanticAnalyzer())._visit_(aNode);
  153. $ctx1.sendIdx["visit:"]=1;
  154. ir=_st(self._translator())._visit_(aNode);
  155. $ctx1.sendIdx["visit:"]=2;
  156. $2=self._irTranslator();
  157. _st($2)._currentClass_(self._currentClass());
  158. _st($2)._visit_(ir);
  159. $3=_st($2)._contents();
  160. $1=$3;
  161. return $1;
  162. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},globals.CodeGenerator)});
  163. },
  164. args: ["aNode"],
  165. source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09^ self irTranslator\x0a\x09\x09currentClass: self currentClass;\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
  166. messageSends: ["visit:", "semanticAnalyzer", "translator", "currentClass:", "irTranslator", "currentClass", "contents"],
  167. referencedClasses: []
  168. }),
  169. globals.CodeGenerator);
  170. smalltalk.addMethod(
  171. smalltalk.method({
  172. selector: "irTranslator",
  173. protocol: 'compiling',
  174. fn: function (){
  175. var self=this;
  176. function $IRJSTranslator(){return globals.IRJSTranslator||(typeof IRJSTranslator=="undefined"?nil:IRJSTranslator)}
  177. return smalltalk.withContext(function($ctx1) {
  178. var $1;
  179. $1=_st($IRJSTranslator())._new();
  180. return $1;
  181. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},globals.CodeGenerator)});
  182. },
  183. args: [],
  184. source: "irTranslator\x0a\x09^ IRJSTranslator new",
  185. messageSends: ["new"],
  186. referencedClasses: ["IRJSTranslator"]
  187. }),
  188. globals.CodeGenerator);
  189. smalltalk.addMethod(
  190. smalltalk.method({
  191. selector: "semanticAnalyzer",
  192. protocol: 'compiling',
  193. fn: function (){
  194. var self=this;
  195. function $SemanticAnalyzer(){return globals.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  196. return smalltalk.withContext(function($ctx1) {
  197. var $1;
  198. $1=_st($SemanticAnalyzer())._on_(self._currentClass());
  199. return $1;
  200. }, function($ctx1) {$ctx1.fill(self,"semanticAnalyzer",{},globals.CodeGenerator)});
  201. },
  202. args: [],
  203. source: "semanticAnalyzer\x0a\x09^ SemanticAnalyzer on: self currentClass",
  204. messageSends: ["on:", "currentClass"],
  205. referencedClasses: ["SemanticAnalyzer"]
  206. }),
  207. globals.CodeGenerator);
  208. smalltalk.addMethod(
  209. smalltalk.method({
  210. selector: "translator",
  211. protocol: 'compiling',
  212. fn: function (){
  213. var self=this;
  214. function $IRASTTranslator(){return globals.IRASTTranslator||(typeof IRASTTranslator=="undefined"?nil:IRASTTranslator)}
  215. return smalltalk.withContext(function($ctx1) {
  216. var $2,$3,$1;
  217. $2=_st($IRASTTranslator())._new();
  218. _st($2)._source_(self._source());
  219. _st($2)._theClass_(self._currentClass());
  220. $3=_st($2)._yourself();
  221. $1=$3;
  222. return $1;
  223. }, function($ctx1) {$ctx1.fill(self,"translator",{},globals.CodeGenerator)});
  224. },
  225. args: [],
  226. source: "translator\x0a\x09^ IRASTTranslator new\x0a\x09\x09source: self source;\x0a\x09\x09theClass: self currentClass;\x0a\x09\x09yourself",
  227. messageSends: ["source:", "new", "source", "theClass:", "currentClass", "yourself"],
  228. referencedClasses: ["IRASTTranslator"]
  229. }),
  230. globals.CodeGenerator);
  231. smalltalk.addClass('Compiler', globals.Object, ['currentClass', 'source', 'unknownVariables', 'codeGeneratorClass'], 'Compiler-Core');
  232. globals.Compiler.comment="I provide the public interface for compiling Amber source code into JavaScript.\x0a\x0aThe code generator used to produce JavaScript can be plugged with `#codeGeneratorClass`.\x0aThe default code generator is an instance of `InlinedCodeGenerator`";
  233. smalltalk.addMethod(
  234. smalltalk.method({
  235. selector: "codeGeneratorClass",
  236. protocol: 'accessing',
  237. fn: function (){
  238. var self=this;
  239. function $InliningCodeGenerator(){return globals.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  240. return smalltalk.withContext(function($ctx1) {
  241. var $2,$1,$receiver;
  242. $2=self["@codeGeneratorClass"];
  243. if(($receiver = $2) == null || $receiver.isNil){
  244. $1=$InliningCodeGenerator();
  245. } else {
  246. $1=$2;
  247. };
  248. return $1;
  249. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},globals.Compiler)});
  250. },
  251. args: [],
  252. source: "codeGeneratorClass\x0a\x09^ codeGeneratorClass ifNil: [ InliningCodeGenerator ]",
  253. messageSends: ["ifNil:"],
  254. referencedClasses: ["InliningCodeGenerator"]
  255. }),
  256. globals.Compiler);
  257. smalltalk.addMethod(
  258. smalltalk.method({
  259. selector: "codeGeneratorClass:",
  260. protocol: 'accessing',
  261. fn: function (aClass){
  262. var self=this;
  263. self["@codeGeneratorClass"]=aClass;
  264. return self
  265. },
  266. args: ["aClass"],
  267. source: "codeGeneratorClass: aClass\x0a\x09codeGeneratorClass := aClass",
  268. messageSends: [],
  269. referencedClasses: []
  270. }),
  271. globals.Compiler);
  272. smalltalk.addMethod(
  273. smalltalk.method({
  274. selector: "compile:",
  275. protocol: 'compiling',
  276. fn: function (aString){
  277. var self=this;
  278. return smalltalk.withContext(function($ctx1) {
  279. var $1;
  280. $1=self._compileNode_(self._parse_(aString));
  281. return $1;
  282. }, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},globals.Compiler)});
  283. },
  284. args: ["aString"],
  285. source: "compile: aString\x0a\x09^ self compileNode: (self parse: aString)",
  286. messageSends: ["compileNode:", "parse:"],
  287. referencedClasses: []
  288. }),
  289. globals.Compiler);
  290. smalltalk.addMethod(
  291. smalltalk.method({
  292. selector: "compile:forClass:",
  293. protocol: 'compiling',
  294. fn: function (aString,aClass){
  295. var self=this;
  296. return smalltalk.withContext(function($ctx1) {
  297. var $1;
  298. self._currentClass_(aClass);
  299. self._source_(aString);
  300. $1=self._compile_(aString);
  301. return $1;
  302. }, function($ctx1) {$ctx1.fill(self,"compile:forClass:",{aString:aString,aClass:aClass},globals.Compiler)});
  303. },
  304. args: ["aString", "aClass"],
  305. source: "compile: aString forClass: aClass\x0a\x09self currentClass: aClass.\x0a\x09self source: aString.\x0a\x09^ self compile: aString",
  306. messageSends: ["currentClass:", "source:", "compile:"],
  307. referencedClasses: []
  308. }),
  309. globals.Compiler);
  310. smalltalk.addMethod(
  311. smalltalk.method({
  312. selector: "compileExpression:",
  313. protocol: 'compiling',
  314. fn: function (aString){
  315. var self=this;
  316. function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  317. return smalltalk.withContext(function($ctx1) {
  318. var $1,$2;
  319. self._currentClass_($DoIt());
  320. $1=_st("doIt ^ [ ".__comma(aString)).__comma(" ] value");
  321. $ctx1.sendIdx[","]=1;
  322. self._source_($1);
  323. $2=self._compileNode_(self._parse_(self._source()));
  324. return $2;
  325. }, function($ctx1) {$ctx1.fill(self,"compileExpression:",{aString:aString},globals.Compiler)});
  326. },
  327. args: ["aString"],
  328. source: "compileExpression: aString\x0a\x09self currentClass: DoIt.\x0a\x09self source: 'doIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
  329. messageSends: ["currentClass:", "source:", ",", "compileNode:", "parse:", "source"],
  330. referencedClasses: ["DoIt"]
  331. }),
  332. globals.Compiler);
  333. smalltalk.addMethod(
  334. smalltalk.method({
  335. selector: "compileExpression:on:",
  336. protocol: 'compiling',
  337. fn: function (aString,anObject){
  338. var self=this;
  339. return smalltalk.withContext(function($ctx1) {
  340. var $1,$2;
  341. self._currentClass_(_st(anObject)._class());
  342. $1=_st("xxxDoIt ^ [ ".__comma(aString)).__comma(" ] value");
  343. $ctx1.sendIdx[","]=1;
  344. self._source_($1);
  345. $2=self._compileNode_(self._parse_(self._source()));
  346. return $2;
  347. }, function($ctx1) {$ctx1.fill(self,"compileExpression:on:",{aString:aString,anObject:anObject},globals.Compiler)});
  348. },
  349. args: ["aString", "anObject"],
  350. source: "compileExpression: aString on: anObject\x0a\x09self currentClass: anObject class.\x0a\x09self source: 'xxxDoIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
  351. messageSends: ["currentClass:", "class", "source:", ",", "compileNode:", "parse:", "source"],
  352. referencedClasses: []
  353. }),
  354. globals.Compiler);
  355. smalltalk.addMethod(
  356. smalltalk.method({
  357. selector: "compileNode:",
  358. protocol: 'compiling',
  359. fn: function (aNode){
  360. var self=this;
  361. var generator,result;
  362. return smalltalk.withContext(function($ctx1) {
  363. var $1,$2,$3;
  364. generator=_st(self._codeGeneratorClass())._new();
  365. $1=generator;
  366. _st($1)._source_(self._source());
  367. $2=_st($1)._currentClass_(self._currentClass());
  368. result=_st(generator)._compileNode_(aNode);
  369. self._unknownVariables_([]);
  370. $3=result;
  371. return $3;
  372. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,generator:generator,result:result},globals.Compiler)});
  373. },
  374. args: ["aNode"],
  375. 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",
  376. messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "compileNode:", "unknownVariables:"],
  377. referencedClasses: []
  378. }),
  379. globals.Compiler);
  380. smalltalk.addMethod(
  381. smalltalk.method({
  382. selector: "currentClass",
  383. protocol: 'accessing',
  384. fn: function (){
  385. var self=this;
  386. var $1;
  387. $1=self["@currentClass"];
  388. return $1;
  389. },
  390. args: [],
  391. source: "currentClass\x0a\x09^ currentClass",
  392. messageSends: [],
  393. referencedClasses: []
  394. }),
  395. globals.Compiler);
  396. smalltalk.addMethod(
  397. smalltalk.method({
  398. selector: "currentClass:",
  399. protocol: 'accessing',
  400. fn: function (aClass){
  401. var self=this;
  402. self["@currentClass"]=aClass;
  403. return self
  404. },
  405. args: ["aClass"],
  406. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  407. messageSends: [],
  408. referencedClasses: []
  409. }),
  410. globals.Compiler);
  411. smalltalk.addMethod(
  412. smalltalk.method({
  413. selector: "eval:",
  414. protocol: 'compiling',
  415. fn: function (aString){
  416. var self=this;
  417. return smalltalk.withContext(function($ctx1) {
  418. return eval(aString);
  419. return self}, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString},globals.Compiler)});
  420. },
  421. args: ["aString"],
  422. source: "eval: aString\x0a\x09<return eval(aString)>",
  423. messageSends: [],
  424. referencedClasses: []
  425. }),
  426. globals.Compiler);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "evaluateExpression:",
  430. protocol: 'compiling',
  431. fn: function (aString){
  432. var self=this;
  433. function $DoIt(){return globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  434. return smalltalk.withContext(function($ctx1) {
  435. var $1;
  436. $1=self._evaluateExpression_on_(aString,_st($DoIt())._new());
  437. return $1;
  438. }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:",{aString:aString},globals.Compiler)});
  439. },
  440. args: ["aString"],
  441. source: "evaluateExpression: aString\x0a\x09\x22Unlike #eval: evaluate a Smalltalk expression and answer the returned object\x22\x0a\x09^ self evaluateExpression: aString on: DoIt new",
  442. messageSends: ["evaluateExpression:on:", "new"],
  443. referencedClasses: ["DoIt"]
  444. }),
  445. globals.Compiler);
  446. smalltalk.addMethod(
  447. smalltalk.method({
  448. selector: "evaluateExpression:on:",
  449. protocol: 'compiling',
  450. fn: function (aString,anObject){
  451. var self=this;
  452. var result,method;
  453. return smalltalk.withContext(function($ctx1) {
  454. var $1,$2;
  455. method=self._eval_(self._compileExpression_on_(aString,anObject));
  456. _st(method)._protocol_("**xxxDoIt");
  457. $1=_st(anObject)._class();
  458. $ctx1.sendIdx["class"]=1;
  459. _st($1)._addCompiledMethod_(method);
  460. result=_st(anObject)._xxxDoIt();
  461. _st(_st(anObject)._class())._removeCompiledMethod_(method);
  462. $2=result;
  463. return $2;
  464. }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:on:",{aString:aString,anObject:anObject,result:result,method:method},globals.Compiler)});
  465. },
  466. args: ["aString", "anObject"],
  467. source: "evaluateExpression: aString on: anObject\x0a\x09\x22Unlike #eval: evaluate a Smalltalk expression with anObject as the receiver and answer the returned object\x22\x0a\x09| result method |\x0a\x09method := self eval: (self compileExpression: aString on: anObject).\x0a\x09method protocol: '**xxxDoIt'.\x0a\x09anObject class addCompiledMethod: method.\x0a\x09result := anObject xxxDoIt.\x0a\x09anObject class removeCompiledMethod: method.\x0a\x09^ result",
  468. messageSends: ["eval:", "compileExpression:on:", "protocol:", "addCompiledMethod:", "class", "xxxDoIt", "removeCompiledMethod:"],
  469. referencedClasses: []
  470. }),
  471. globals.Compiler);
  472. smalltalk.addMethod(
  473. smalltalk.method({
  474. selector: "install:forClass:protocol:",
  475. protocol: 'compiling',
  476. fn: function (aString,aBehavior,anotherString){
  477. var self=this;
  478. function $ClassBuilder(){return globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  479. return smalltalk.withContext(function($ctx1) {
  480. var $1;
  481. $1=_st(_st($ClassBuilder())._new())._installMethod_forClass_protocol_(self._eval_(self._compile_forClass_(aString,aBehavior)),aBehavior,anotherString);
  482. return $1;
  483. }, function($ctx1) {$ctx1.fill(self,"install:forClass:protocol:",{aString:aString,aBehavior:aBehavior,anotherString:anotherString},globals.Compiler)});
  484. },
  485. args: ["aString", "aBehavior", "anotherString"],
  486. source: "install: aString forClass: aBehavior protocol: anotherString\x0a\x09^ ClassBuilder new\x0a\x09\x09installMethod: (self eval: (self compile: aString forClass: aBehavior))\x0a\x09\x09forClass: aBehavior\x0a\x09\x09protocol: anotherString",
  487. messageSends: ["installMethod:forClass:protocol:", "new", "eval:", "compile:forClass:"],
  488. referencedClasses: ["ClassBuilder"]
  489. }),
  490. globals.Compiler);
  491. smalltalk.addMethod(
  492. smalltalk.method({
  493. selector: "parse:",
  494. protocol: 'compiling',
  495. fn: function (aString){
  496. var self=this;
  497. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  498. return smalltalk.withContext(function($ctx1) {
  499. var $1;
  500. $1=_st($Smalltalk())._parse_(aString);
  501. return $1;
  502. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},globals.Compiler)});
  503. },
  504. args: ["aString"],
  505. source: "parse: aString\x0a\x09^ Smalltalk parse: aString",
  506. messageSends: ["parse:"],
  507. referencedClasses: ["Smalltalk"]
  508. }),
  509. globals.Compiler);
  510. smalltalk.addMethod(
  511. smalltalk.method({
  512. selector: "parseExpression:",
  513. protocol: 'compiling',
  514. fn: function (aString){
  515. var self=this;
  516. return smalltalk.withContext(function($ctx1) {
  517. var $2,$1;
  518. $2=_st("doIt ^ [ ".__comma(aString)).__comma(" ] value");
  519. $ctx1.sendIdx[","]=1;
  520. $1=self._parse_($2);
  521. return $1;
  522. }, function($ctx1) {$ctx1.fill(self,"parseExpression:",{aString:aString},globals.Compiler)});
  523. },
  524. args: ["aString"],
  525. source: "parseExpression: aString\x0a\x09^ self parse: 'doIt ^ [ ', aString, ' ] value'",
  526. messageSends: ["parse:", ","],
  527. referencedClasses: []
  528. }),
  529. globals.Compiler);
  530. smalltalk.addMethod(
  531. smalltalk.method({
  532. selector: "recompile:",
  533. protocol: 'compiling',
  534. fn: function (aClass){
  535. var self=this;
  536. return smalltalk.withContext(function($ctx1) {
  537. var $1;
  538. _st(_st(_st(aClass)._methodDictionary())._values())._do_displayingProgress_((function(each){
  539. return smalltalk.withContext(function($ctx2) {
  540. return self._install_forClass_protocol_(_st(each)._source(),aClass,_st(each)._protocol());
  541. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  542. }),"Recompiling ".__comma(_st(aClass)._name()));
  543. $1=_st(aClass)._isMetaclass();
  544. if(! smalltalk.assert($1)){
  545. self._recompile_(_st(aClass)._class());
  546. };
  547. return self}, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},globals.Compiler)});
  548. },
  549. args: ["aClass"],
  550. source: "recompile: aClass\x0a\x09aClass methodDictionary values\x0a\x09\x09do: [ :each | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09install: each source \x0a\x09\x09\x09\x09forClass: aClass \x0a\x09\x09\x09\x09protocol: each protocol ]\x0a\x09\x09displayingProgress: 'Recompiling ', aClass name.\x0a\x09aClass isMetaclass ifFalse: [ self recompile: aClass class ]",
  551. messageSends: ["do:displayingProgress:", "values", "methodDictionary", "install:forClass:protocol:", "source", "protocol", ",", "name", "ifFalse:", "isMetaclass", "recompile:", "class"],
  552. referencedClasses: []
  553. }),
  554. globals.Compiler);
  555. smalltalk.addMethod(
  556. smalltalk.method({
  557. selector: "recompileAll",
  558. protocol: 'compiling',
  559. fn: function (){
  560. var self=this;
  561. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  562. return smalltalk.withContext(function($ctx1) {
  563. _st(_st($Smalltalk())._classes())._do_displayingProgress_((function(each){
  564. return smalltalk.withContext(function($ctx2) {
  565. return self._recompile_(each);
  566. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  567. }),"Compiling all classes...");
  568. return self}, function($ctx1) {$ctx1.fill(self,"recompileAll",{},globals.Compiler)});
  569. },
  570. args: [],
  571. source: "recompileAll\x0a\x09Smalltalk classes \x0a\x09\x09do: [ :each | self recompile: each ]\x0a\x09\x09displayingProgress: 'Compiling all classes...'",
  572. messageSends: ["do:displayingProgress:", "classes", "recompile:"],
  573. referencedClasses: ["Smalltalk"]
  574. }),
  575. globals.Compiler);
  576. smalltalk.addMethod(
  577. smalltalk.method({
  578. selector: "source",
  579. protocol: 'accessing',
  580. fn: function (){
  581. var self=this;
  582. return smalltalk.withContext(function($ctx1) {
  583. var $2,$1,$receiver;
  584. $2=self["@source"];
  585. if(($receiver = $2) == null || $receiver.isNil){
  586. $1="";
  587. } else {
  588. $1=$2;
  589. };
  590. return $1;
  591. }, function($ctx1) {$ctx1.fill(self,"source",{},globals.Compiler)});
  592. },
  593. args: [],
  594. source: "source\x0a\x09^ source ifNil: [ '' ]",
  595. messageSends: ["ifNil:"],
  596. referencedClasses: []
  597. }),
  598. globals.Compiler);
  599. smalltalk.addMethod(
  600. smalltalk.method({
  601. selector: "source:",
  602. protocol: 'accessing',
  603. fn: function (aString){
  604. var self=this;
  605. self["@source"]=aString;
  606. return self
  607. },
  608. args: ["aString"],
  609. source: "source: aString\x0a\x09source := aString",
  610. messageSends: [],
  611. referencedClasses: []
  612. }),
  613. globals.Compiler);
  614. smalltalk.addMethod(
  615. smalltalk.method({
  616. selector: "unknownVariables",
  617. protocol: 'accessing',
  618. fn: function (){
  619. var self=this;
  620. var $1;
  621. $1=self["@unknownVariables"];
  622. return $1;
  623. },
  624. args: [],
  625. source: "unknownVariables\x0a\x09^ unknownVariables",
  626. messageSends: [],
  627. referencedClasses: []
  628. }),
  629. globals.Compiler);
  630. smalltalk.addMethod(
  631. smalltalk.method({
  632. selector: "unknownVariables:",
  633. protocol: 'accessing',
  634. fn: function (aCollection){
  635. var self=this;
  636. self["@unknownVariables"]=aCollection;
  637. return self
  638. },
  639. args: ["aCollection"],
  640. source: "unknownVariables: aCollection\x0a\x09unknownVariables := aCollection",
  641. messageSends: [],
  642. referencedClasses: []
  643. }),
  644. globals.Compiler);
  645. smalltalk.addMethod(
  646. smalltalk.method({
  647. selector: "recompile:",
  648. protocol: 'compiling',
  649. fn: function (aClass){
  650. var self=this;
  651. return smalltalk.withContext(function($ctx1) {
  652. _st(self._new())._recompile_(aClass);
  653. return self}, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},globals.Compiler.klass)});
  654. },
  655. args: ["aClass"],
  656. source: "recompile: aClass\x0a\x09self new recompile: aClass",
  657. messageSends: ["recompile:", "new"],
  658. referencedClasses: []
  659. }),
  660. globals.Compiler.klass);
  661. smalltalk.addMethod(
  662. smalltalk.method({
  663. selector: "recompileAll",
  664. protocol: 'compiling',
  665. fn: function (){
  666. var self=this;
  667. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  668. return smalltalk.withContext(function($ctx1) {
  669. _st(_st($Smalltalk())._classes())._do_((function(each){
  670. return smalltalk.withContext(function($ctx2) {
  671. return self._recompile_(each);
  672. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  673. }));
  674. return self}, function($ctx1) {$ctx1.fill(self,"recompileAll",{},globals.Compiler.klass)});
  675. },
  676. args: [],
  677. source: "recompileAll\x0a\x09Smalltalk classes do: [ :each |\x0a\x09\x09self recompile: each ]",
  678. messageSends: ["do:", "classes", "recompile:"],
  679. referencedClasses: ["Smalltalk"]
  680. }),
  681. globals.Compiler.klass);
  682. smalltalk.addClass('DoIt', globals.Object, [], 'Compiler-Core');
  683. globals.DoIt.comment="`DoIt` is the class used to compile and evaluate expressions. See `Compiler >> evaluateExpression:`.";
  684. smalltalk.addClass('Evaluator', globals.InterfacingObject, [], 'Compiler-Core');
  685. globals.Evaluator.comment="I evaluate code against a receiver, dispatching #evaluate:on: to the receiver.";
  686. smalltalk.addMethod(
  687. smalltalk.method({
  688. selector: "evaluate:context:",
  689. protocol: 'evaluating',
  690. fn: function (aString,aContext){
  691. var self=this;
  692. var compiler,ast;
  693. function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  694. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  695. function $AISemanticAnalyzer(){return globals.AISemanticAnalyzer||(typeof AISemanticAnalyzer=="undefined"?nil:AISemanticAnalyzer)}
  696. return smalltalk.withContext(function($ctx1) {
  697. var $1,$2,$3,$4;
  698. var $early={};
  699. try {
  700. compiler=_st($Compiler())._new();
  701. _st((function(){
  702. return smalltalk.withContext(function($ctx2) {
  703. ast=_st(compiler)._parseExpression_(aString);
  704. return ast;
  705. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  706. }))._on_do_($Error(),(function(ex){
  707. return smalltalk.withContext(function($ctx2) {
  708. $1=self._alert_(_st(ex)._messageText());
  709. throw $early=[$1];
  710. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
  711. }));
  712. $2=_st($AISemanticAnalyzer())._on_(_st(_st(aContext)._receiver())._class());
  713. _st($2)._context_(aContext);
  714. $3=_st($2)._visit_(ast);
  715. $4=_st(aContext)._evaluateNode_(ast);
  716. return $4;
  717. }
  718. catch(e) {if(e===$early)return e[0]; throw e}
  719. }, function($ctx1) {$ctx1.fill(self,"evaluate:context:",{aString:aString,aContext:aContext,compiler:compiler,ast:ast},globals.Evaluator)});
  720. },
  721. args: ["aString", "aContext"],
  722. source: "evaluate: aString context: aContext\x0a\x09\x22Similar to #evaluate:for:, with the following differences:\x0a\x09- instead of compiling and running `aString`, `aString` is interpreted using an `ASTInterpreter`\x0a\x09- instead of evaluating against a receiver, evaluate in the context of `aContext`\x22\x0a\x0a\x09| compiler ast |\x0a\x09\x0a\x09compiler := Compiler new.\x0a\x09[ ast := compiler parseExpression: aString ] \x0a\x09\x09on: Error \x0a\x09\x09do: [ :ex | ^ self alert: ex messageText ].\x0a\x09\x09\x0a\x09(AISemanticAnalyzer on: aContext receiver class)\x0a\x09\x09context: aContext;\x0a\x09\x09visit: ast.\x0a\x0a\x09^ aContext evaluateNode: ast",
  723. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "context:", "on:", "class", "receiver", "visit:", "evaluateNode:"],
  724. referencedClasses: ["Compiler", "Error", "AISemanticAnalyzer"]
  725. }),
  726. globals.Evaluator);
  727. smalltalk.addMethod(
  728. smalltalk.method({
  729. selector: "evaluate:for:",
  730. protocol: 'evaluating',
  731. fn: function (aString,anObject){
  732. var self=this;
  733. return smalltalk.withContext(function($ctx1) {
  734. var $1;
  735. $1=_st(anObject)._evaluate_on_(aString,self);
  736. return $1;
  737. }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},globals.Evaluator)});
  738. },
  739. args: ["aString", "anObject"],
  740. source: "evaluate: aString for: anObject\x0a\x09^ anObject evaluate: aString on: self",
  741. messageSends: ["evaluate:on:"],
  742. referencedClasses: []
  743. }),
  744. globals.Evaluator);
  745. smalltalk.addMethod(
  746. smalltalk.method({
  747. selector: "evaluate:receiver:",
  748. protocol: 'evaluating',
  749. fn: function (aString,anObject){
  750. var self=this;
  751. var compiler;
  752. function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  753. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  754. return smalltalk.withContext(function($ctx1) {
  755. var $1,$2;
  756. var $early={};
  757. try {
  758. compiler=_st($Compiler())._new();
  759. _st((function(){
  760. return smalltalk.withContext(function($ctx2) {
  761. return _st(compiler)._parseExpression_(aString);
  762. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  763. }))._on_do_($Error(),(function(ex){
  764. return smalltalk.withContext(function($ctx2) {
  765. $1=self._alert_(_st(ex)._messageText());
  766. throw $early=[$1];
  767. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
  768. }));
  769. $2=_st(compiler)._evaluateExpression_on_(aString,anObject);
  770. return $2;
  771. }
  772. catch(e) {if(e===$early)return e[0]; throw e}
  773. }, function($ctx1) {$ctx1.fill(self,"evaluate:receiver:",{aString:aString,anObject:anObject,compiler:compiler},globals.Evaluator)});
  774. },
  775. args: ["aString", "anObject"],
  776. source: "evaluate: aString receiver: anObject\x0a\x09| compiler |\x0a\x09\x0a\x09compiler := Compiler new.\x0a\x09[ compiler parseExpression: aString ] \x0a\x09\x09on: Error \x0a\x09\x09do: [ :ex | ^ self alert: ex messageText ].\x0a\x0a\x09^ compiler evaluateExpression: aString on: anObject",
  777. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "evaluateExpression:on:"],
  778. referencedClasses: ["Compiler", "Error"]
  779. }),
  780. globals.Evaluator);
  781. smalltalk.addMethod(
  782. smalltalk.method({
  783. selector: "evaluate:for:",
  784. protocol: 'instance creation',
  785. fn: function (aString,anObject){
  786. var self=this;
  787. return smalltalk.withContext(function($ctx1) {
  788. var $1;
  789. $1=_st(self._new())._evaluate_for_(aString,anObject);
  790. return $1;
  791. }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},globals.Evaluator.klass)});
  792. },
  793. args: ["aString", "anObject"],
  794. source: "evaluate: aString for: anObject\x0a\x09^ self new evaluate: aString for: anObject",
  795. messageSends: ["evaluate:for:", "new"],
  796. referencedClasses: []
  797. }),
  798. globals.Evaluator.klass);
  799. smalltalk.addClass('NodeVisitor', globals.Object, [], 'Compiler-Core');
  800. globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
  801. smalltalk.addMethod(
  802. smalltalk.method({
  803. selector: "visit:",
  804. protocol: 'visiting',
  805. fn: function (aNode){
  806. var self=this;
  807. return smalltalk.withContext(function($ctx1) {
  808. var $1;
  809. $1=_st(aNode)._accept_(self);
  810. return $1;
  811. }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},globals.NodeVisitor)});
  812. },
  813. args: ["aNode"],
  814. source: "visit: aNode\x0a\x09^ aNode accept: self",
  815. messageSends: ["accept:"],
  816. referencedClasses: []
  817. }),
  818. globals.NodeVisitor);
  819. smalltalk.addMethod(
  820. smalltalk.method({
  821. selector: "visitAll:",
  822. protocol: 'visiting',
  823. fn: function (aCollection){
  824. var self=this;
  825. return smalltalk.withContext(function($ctx1) {
  826. var $1;
  827. $1=_st(aCollection)._collect_((function(each){
  828. return smalltalk.withContext(function($ctx2) {
  829. return self._visit_(each);
  830. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  831. }));
  832. return $1;
  833. }, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},globals.NodeVisitor)});
  834. },
  835. args: ["aCollection"],
  836. source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
  837. messageSends: ["collect:", "visit:"],
  838. referencedClasses: []
  839. }),
  840. globals.NodeVisitor);
  841. smalltalk.addMethod(
  842. smalltalk.method({
  843. selector: "visitAssignmentNode:",
  844. protocol: 'visiting',
  845. fn: function (aNode){
  846. var self=this;
  847. return smalltalk.withContext(function($ctx1) {
  848. var $1;
  849. $1=self._visitNode_(aNode);
  850. return $1;
  851. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},globals.NodeVisitor)});
  852. },
  853. args: ["aNode"],
  854. source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
  855. messageSends: ["visitNode:"],
  856. referencedClasses: []
  857. }),
  858. globals.NodeVisitor);
  859. smalltalk.addMethod(
  860. smalltalk.method({
  861. selector: "visitBlockNode:",
  862. protocol: 'visiting',
  863. fn: function (aNode){
  864. var self=this;
  865. return smalltalk.withContext(function($ctx1) {
  866. var $1;
  867. $1=self._visitNode_(aNode);
  868. return $1;
  869. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},globals.NodeVisitor)});
  870. },
  871. args: ["aNode"],
  872. source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
  873. messageSends: ["visitNode:"],
  874. referencedClasses: []
  875. }),
  876. globals.NodeVisitor);
  877. smalltalk.addMethod(
  878. smalltalk.method({
  879. selector: "visitBlockSequenceNode:",
  880. protocol: 'visiting',
  881. fn: function (aNode){
  882. var self=this;
  883. return smalltalk.withContext(function($ctx1) {
  884. var $1;
  885. $1=self._visitSequenceNode_(aNode);
  886. return $1;
  887. }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},globals.NodeVisitor)});
  888. },
  889. args: ["aNode"],
  890. source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
  891. messageSends: ["visitSequenceNode:"],
  892. referencedClasses: []
  893. }),
  894. globals.NodeVisitor);
  895. smalltalk.addMethod(
  896. smalltalk.method({
  897. selector: "visitCascadeNode:",
  898. protocol: 'visiting',
  899. fn: function (aNode){
  900. var self=this;
  901. return smalltalk.withContext(function($ctx1) {
  902. var $1;
  903. $1=self._visitNode_(aNode);
  904. return $1;
  905. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},globals.NodeVisitor)});
  906. },
  907. args: ["aNode"],
  908. source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
  909. messageSends: ["visitNode:"],
  910. referencedClasses: []
  911. }),
  912. globals.NodeVisitor);
  913. smalltalk.addMethod(
  914. smalltalk.method({
  915. selector: "visitDynamicArrayNode:",
  916. protocol: 'visiting',
  917. fn: function (aNode){
  918. var self=this;
  919. return smalltalk.withContext(function($ctx1) {
  920. var $1;
  921. $1=self._visitNode_(aNode);
  922. return $1;
  923. }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},globals.NodeVisitor)});
  924. },
  925. args: ["aNode"],
  926. source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
  927. messageSends: ["visitNode:"],
  928. referencedClasses: []
  929. }),
  930. globals.NodeVisitor);
  931. smalltalk.addMethod(
  932. smalltalk.method({
  933. selector: "visitDynamicDictionaryNode:",
  934. protocol: 'visiting',
  935. fn: function (aNode){
  936. var self=this;
  937. return smalltalk.withContext(function($ctx1) {
  938. var $1;
  939. $1=self._visitNode_(aNode);
  940. return $1;
  941. }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},globals.NodeVisitor)});
  942. },
  943. args: ["aNode"],
  944. source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
  945. messageSends: ["visitNode:"],
  946. referencedClasses: []
  947. }),
  948. globals.NodeVisitor);
  949. smalltalk.addMethod(
  950. smalltalk.method({
  951. selector: "visitJSStatementNode:",
  952. protocol: 'visiting',
  953. fn: function (aNode){
  954. var self=this;
  955. return smalltalk.withContext(function($ctx1) {
  956. var $1;
  957. $1=self._visitNode_(aNode);
  958. return $1;
  959. }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},globals.NodeVisitor)});
  960. },
  961. args: ["aNode"],
  962. source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
  963. messageSends: ["visitNode:"],
  964. referencedClasses: []
  965. }),
  966. globals.NodeVisitor);
  967. smalltalk.addMethod(
  968. smalltalk.method({
  969. selector: "visitMethodNode:",
  970. protocol: 'visiting',
  971. fn: function (aNode){
  972. var self=this;
  973. return smalltalk.withContext(function($ctx1) {
  974. var $1;
  975. $1=self._visitNode_(aNode);
  976. return $1;
  977. }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},globals.NodeVisitor)});
  978. },
  979. args: ["aNode"],
  980. source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
  981. messageSends: ["visitNode:"],
  982. referencedClasses: []
  983. }),
  984. globals.NodeVisitor);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "visitNode:",
  988. protocol: 'visiting',
  989. fn: function (aNode){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. var $1;
  993. $1=self._visitAll_(_st(aNode)._nodes());
  994. return $1;
  995. }, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},globals.NodeVisitor)});
  996. },
  997. args: ["aNode"],
  998. source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
  999. messageSends: ["visitAll:", "nodes"],
  1000. referencedClasses: []
  1001. }),
  1002. globals.NodeVisitor);
  1003. smalltalk.addMethod(
  1004. smalltalk.method({
  1005. selector: "visitReturnNode:",
  1006. protocol: 'visiting',
  1007. fn: function (aNode){
  1008. var self=this;
  1009. return smalltalk.withContext(function($ctx1) {
  1010. var $1;
  1011. $1=self._visitNode_(aNode);
  1012. return $1;
  1013. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},globals.NodeVisitor)});
  1014. },
  1015. args: ["aNode"],
  1016. source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
  1017. messageSends: ["visitNode:"],
  1018. referencedClasses: []
  1019. }),
  1020. globals.NodeVisitor);
  1021. smalltalk.addMethod(
  1022. smalltalk.method({
  1023. selector: "visitSendNode:",
  1024. protocol: 'visiting',
  1025. fn: function (aNode){
  1026. var self=this;
  1027. return smalltalk.withContext(function($ctx1) {
  1028. var $1;
  1029. $1=self._visitNode_(aNode);
  1030. return $1;
  1031. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},globals.NodeVisitor)});
  1032. },
  1033. args: ["aNode"],
  1034. source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
  1035. messageSends: ["visitNode:"],
  1036. referencedClasses: []
  1037. }),
  1038. globals.NodeVisitor);
  1039. smalltalk.addMethod(
  1040. smalltalk.method({
  1041. selector: "visitSequenceNode:",
  1042. protocol: 'visiting',
  1043. fn: function (aNode){
  1044. var self=this;
  1045. return smalltalk.withContext(function($ctx1) {
  1046. var $1;
  1047. $1=self._visitNode_(aNode);
  1048. return $1;
  1049. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},globals.NodeVisitor)});
  1050. },
  1051. args: ["aNode"],
  1052. source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
  1053. messageSends: ["visitNode:"],
  1054. referencedClasses: []
  1055. }),
  1056. globals.NodeVisitor);
  1057. smalltalk.addMethod(
  1058. smalltalk.method({
  1059. selector: "visitValueNode:",
  1060. protocol: 'visiting',
  1061. fn: function (aNode){
  1062. var self=this;
  1063. return smalltalk.withContext(function($ctx1) {
  1064. var $1;
  1065. $1=self._visitNode_(aNode);
  1066. return $1;
  1067. }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},globals.NodeVisitor)});
  1068. },
  1069. args: ["aNode"],
  1070. source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
  1071. messageSends: ["visitNode:"],
  1072. referencedClasses: []
  1073. }),
  1074. globals.NodeVisitor);
  1075. smalltalk.addMethod(
  1076. smalltalk.method({
  1077. selector: "visitVariableNode:",
  1078. protocol: 'visiting',
  1079. fn: function (aNode){
  1080. var self=this;
  1081. return smalltalk.withContext(function($ctx1) {
  1082. var $1;
  1083. $1=self._visitNode_(aNode);
  1084. return $1;
  1085. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},globals.NodeVisitor)});
  1086. },
  1087. args: ["aNode"],
  1088. source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
  1089. messageSends: ["visitNode:"],
  1090. referencedClasses: []
  1091. }),
  1092. globals.NodeVisitor);
  1093. smalltalk.addMethod(
  1094. smalltalk.method({
  1095. selector: "asVariableName",
  1096. protocol: '*Compiler-Core',
  1097. fn: function (){
  1098. var self=this;
  1099. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1100. return smalltalk.withContext(function($ctx1) {
  1101. var $2,$1;
  1102. $2=_st(_st($Smalltalk())._reservedWords())._includes_(self);
  1103. if(smalltalk.assert($2)){
  1104. $1=self.__comma("_");
  1105. } else {
  1106. $1=self;
  1107. };
  1108. return $1;
  1109. }, function($ctx1) {$ctx1.fill(self,"asVariableName",{},globals.String)});
  1110. },
  1111. args: [],
  1112. source: "asVariableName\x0a\x09^ (Smalltalk reservedWords includes: self)\x0a\x09\x09ifTrue: [ self, '_' ]\x0a\x09\x09ifFalse: [ self ]",
  1113. messageSends: ["ifTrue:ifFalse:", "includes:", "reservedWords", ","],
  1114. referencedClasses: ["Smalltalk"]
  1115. }),
  1116. globals.String);
  1117. });