Compiler-Core.js 37 KB

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