Compiler-Core.js 37 KB

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