Compiler-Core.js 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  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-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;
  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;
  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;
  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.addMethod(
  650. smalltalk.method({
  651. selector: "xxxDoIt",
  652. protocol: 'xxxDoIt',
  653. fn: function (){
  654. var self=this;
  655. return smalltalk.withContext(function($ctx1) {
  656. var $1;
  657. $1=_st((function(){
  658. return smalltalk.withContext(function($ctx2) {
  659. return self._halt();
  660. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._value();
  661. return $1;
  662. }, function($ctx1) {$ctx1.fill(self,"xxxDoIt",{},globals.DoIt)})},
  663. args: [],
  664. source: "xxxDoIt ^ [ self halt ] value",
  665. messageSends: ["value", "halt"],
  666. referencedClasses: []
  667. }),
  668. globals.DoIt);
  669. smalltalk.addClass('Evaluator', globals.Object, [], 'Compiler-Core');
  670. globals.Evaluator.comment="I evaluate code against a receiver, dispatching #evaluate:on: to the receiver.";
  671. smalltalk.addMethod(
  672. smalltalk.method({
  673. selector: "evaluate:context:",
  674. protocol: 'evaluating',
  675. fn: function (aString,aContext){
  676. var self=this;
  677. var compiler,ast;
  678. function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  679. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  680. function $AISemanticAnalyzer(){return globals.AISemanticAnalyzer||(typeof AISemanticAnalyzer=="undefined"?nil:AISemanticAnalyzer)}
  681. return smalltalk.withContext(function($ctx1) {
  682. var $1,$2,$3,$4;
  683. var $early={};
  684. try {
  685. compiler=_st($Compiler())._new();
  686. _st((function(){
  687. return smalltalk.withContext(function($ctx2) {
  688. ast=_st(compiler)._parseExpression_(aString);
  689. return ast;
  690. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
  691. return smalltalk.withContext(function($ctx2) {
  692. $1=self._alert_(_st(ex)._messageText());
  693. throw $early=[$1];
  694. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
  695. $2=_st($AISemanticAnalyzer())._on_(_st(_st(aContext)._receiver())._class());
  696. _st($2)._context_(aContext);
  697. $3=_st($2)._visit_(ast);
  698. $4=_st(aContext)._evaluateNode_(ast);
  699. return $4;
  700. }
  701. catch(e) {if(e===$early)return e[0]; throw e}
  702. }, function($ctx1) {$ctx1.fill(self,"evaluate:context:",{aString:aString,aContext:aContext,compiler:compiler,ast:ast},globals.Evaluator)})},
  703. args: ["aString", "aContext"],
  704. 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",
  705. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "context:", "on:", "class", "receiver", "visit:", "evaluateNode:"],
  706. referencedClasses: ["Compiler", "Error", "AISemanticAnalyzer"]
  707. }),
  708. globals.Evaluator);
  709. smalltalk.addMethod(
  710. smalltalk.method({
  711. selector: "evaluate:for:",
  712. protocol: 'evaluating',
  713. fn: function (aString,anObject){
  714. var self=this;
  715. return smalltalk.withContext(function($ctx1) {
  716. var $1;
  717. $1=_st(anObject)._evaluate_on_(aString,self);
  718. return $1;
  719. }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},globals.Evaluator)})},
  720. args: ["aString", "anObject"],
  721. source: "evaluate: aString for: anObject\x0a\x09^ anObject evaluate: aString on: self",
  722. messageSends: ["evaluate:on:"],
  723. referencedClasses: []
  724. }),
  725. globals.Evaluator);
  726. smalltalk.addMethod(
  727. smalltalk.method({
  728. selector: "evaluate:receiver:",
  729. protocol: 'evaluating',
  730. fn: function (aString,anObject){
  731. var self=this;
  732. var compiler;
  733. function $Compiler(){return globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  734. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  735. return smalltalk.withContext(function($ctx1) {
  736. var $1,$2;
  737. var $early={};
  738. try {
  739. compiler=_st($Compiler())._new();
  740. _st((function(){
  741. return smalltalk.withContext(function($ctx2) {
  742. return _st(compiler)._parseExpression_(aString);
  743. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
  744. return smalltalk.withContext(function($ctx2) {
  745. $1=self._alert_(_st(ex)._messageText());
  746. throw $early=[$1];
  747. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
  748. $2=_st(compiler)._evaluateExpression_on_(aString,anObject);
  749. return $2;
  750. }
  751. catch(e) {if(e===$early)return e[0]; throw e}
  752. }, function($ctx1) {$ctx1.fill(self,"evaluate:receiver:",{aString:aString,anObject:anObject,compiler:compiler},globals.Evaluator)})},
  753. args: ["aString", "anObject"],
  754. 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",
  755. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "evaluateExpression:on:"],
  756. referencedClasses: ["Compiler", "Error"]
  757. }),
  758. globals.Evaluator);
  759. smalltalk.addMethod(
  760. smalltalk.method({
  761. selector: "evaluate:for:",
  762. protocol: 'instance creation',
  763. fn: function (aString,anObject){
  764. var self=this;
  765. return smalltalk.withContext(function($ctx1) {
  766. var $1;
  767. $1=_st(self._new())._evaluate_for_(aString,anObject);
  768. return $1;
  769. }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},globals.Evaluator.klass)})},
  770. args: ["aString", "anObject"],
  771. source: "evaluate: aString for: anObject\x0a\x09^ self new evaluate: aString for: anObject",
  772. messageSends: ["evaluate:for:", "new"],
  773. referencedClasses: []
  774. }),
  775. globals.Evaluator.klass);
  776. smalltalk.addClass('NodeVisitor', globals.Object, [], 'Compiler-Core');
  777. globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
  778. smalltalk.addMethod(
  779. smalltalk.method({
  780. selector: "visit:",
  781. protocol: 'visiting',
  782. fn: function (aNode){
  783. var self=this;
  784. return smalltalk.withContext(function($ctx1) {
  785. var $1;
  786. $1=_st(aNode)._accept_(self);
  787. return $1;
  788. }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},globals.NodeVisitor)})},
  789. args: ["aNode"],
  790. source: "visit: aNode\x0a\x09^ aNode accept: self",
  791. messageSends: ["accept:"],
  792. referencedClasses: []
  793. }),
  794. globals.NodeVisitor);
  795. smalltalk.addMethod(
  796. smalltalk.method({
  797. selector: "visitAll:",
  798. protocol: 'visiting',
  799. fn: function (aCollection){
  800. var self=this;
  801. return smalltalk.withContext(function($ctx1) {
  802. var $1;
  803. $1=_st(aCollection)._collect_((function(each){
  804. return smalltalk.withContext(function($ctx2) {
  805. return self._visit_(each);
  806. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  807. return $1;
  808. }, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},globals.NodeVisitor)})},
  809. args: ["aCollection"],
  810. source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
  811. messageSends: ["collect:", "visit:"],
  812. referencedClasses: []
  813. }),
  814. globals.NodeVisitor);
  815. smalltalk.addMethod(
  816. smalltalk.method({
  817. selector: "visitAssignmentNode:",
  818. protocol: 'visiting',
  819. fn: function (aNode){
  820. var self=this;
  821. return smalltalk.withContext(function($ctx1) {
  822. var $1;
  823. $1=self._visitNode_(aNode);
  824. return $1;
  825. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},globals.NodeVisitor)})},
  826. args: ["aNode"],
  827. source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
  828. messageSends: ["visitNode:"],
  829. referencedClasses: []
  830. }),
  831. globals.NodeVisitor);
  832. smalltalk.addMethod(
  833. smalltalk.method({
  834. selector: "visitBlockNode:",
  835. protocol: 'visiting',
  836. fn: function (aNode){
  837. var self=this;
  838. return smalltalk.withContext(function($ctx1) {
  839. var $1;
  840. $1=self._visitNode_(aNode);
  841. return $1;
  842. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},globals.NodeVisitor)})},
  843. args: ["aNode"],
  844. source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
  845. messageSends: ["visitNode:"],
  846. referencedClasses: []
  847. }),
  848. globals.NodeVisitor);
  849. smalltalk.addMethod(
  850. smalltalk.method({
  851. selector: "visitBlockSequenceNode:",
  852. protocol: 'visiting',
  853. fn: function (aNode){
  854. var self=this;
  855. return smalltalk.withContext(function($ctx1) {
  856. var $1;
  857. $1=self._visitSequenceNode_(aNode);
  858. return $1;
  859. }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},globals.NodeVisitor)})},
  860. args: ["aNode"],
  861. source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
  862. messageSends: ["visitSequenceNode:"],
  863. referencedClasses: []
  864. }),
  865. globals.NodeVisitor);
  866. smalltalk.addMethod(
  867. smalltalk.method({
  868. selector: "visitCascadeNode:",
  869. protocol: 'visiting',
  870. fn: function (aNode){
  871. var self=this;
  872. return smalltalk.withContext(function($ctx1) {
  873. var $1;
  874. $1=self._visitNode_(aNode);
  875. return $1;
  876. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},globals.NodeVisitor)})},
  877. args: ["aNode"],
  878. source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
  879. messageSends: ["visitNode:"],
  880. referencedClasses: []
  881. }),
  882. globals.NodeVisitor);
  883. smalltalk.addMethod(
  884. smalltalk.method({
  885. selector: "visitDynamicArrayNode:",
  886. protocol: 'visiting',
  887. fn: function (aNode){
  888. var self=this;
  889. return smalltalk.withContext(function($ctx1) {
  890. var $1;
  891. $1=self._visitNode_(aNode);
  892. return $1;
  893. }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},globals.NodeVisitor)})},
  894. args: ["aNode"],
  895. source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
  896. messageSends: ["visitNode:"],
  897. referencedClasses: []
  898. }),
  899. globals.NodeVisitor);
  900. smalltalk.addMethod(
  901. smalltalk.method({
  902. selector: "visitDynamicDictionaryNode:",
  903. protocol: 'visiting',
  904. fn: function (aNode){
  905. var self=this;
  906. return smalltalk.withContext(function($ctx1) {
  907. var $1;
  908. $1=self._visitNode_(aNode);
  909. return $1;
  910. }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},globals.NodeVisitor)})},
  911. args: ["aNode"],
  912. source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
  913. messageSends: ["visitNode:"],
  914. referencedClasses: []
  915. }),
  916. globals.NodeVisitor);
  917. smalltalk.addMethod(
  918. smalltalk.method({
  919. selector: "visitJSStatementNode:",
  920. protocol: 'visiting',
  921. fn: function (aNode){
  922. var self=this;
  923. return smalltalk.withContext(function($ctx1) {
  924. var $1;
  925. $1=self._visitNode_(aNode);
  926. return $1;
  927. }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},globals.NodeVisitor)})},
  928. args: ["aNode"],
  929. source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
  930. messageSends: ["visitNode:"],
  931. referencedClasses: []
  932. }),
  933. globals.NodeVisitor);
  934. smalltalk.addMethod(
  935. smalltalk.method({
  936. selector: "visitMethodNode:",
  937. protocol: 'visiting',
  938. fn: function (aNode){
  939. var self=this;
  940. return smalltalk.withContext(function($ctx1) {
  941. var $1;
  942. $1=self._visitNode_(aNode);
  943. return $1;
  944. }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},globals.NodeVisitor)})},
  945. args: ["aNode"],
  946. source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
  947. messageSends: ["visitNode:"],
  948. referencedClasses: []
  949. }),
  950. globals.NodeVisitor);
  951. smalltalk.addMethod(
  952. smalltalk.method({
  953. selector: "visitNode:",
  954. protocol: 'visiting',
  955. fn: function (aNode){
  956. var self=this;
  957. return smalltalk.withContext(function($ctx1) {
  958. var $1;
  959. $1=self._visitAll_(_st(aNode)._nodes());
  960. return $1;
  961. }, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},globals.NodeVisitor)})},
  962. args: ["aNode"],
  963. source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
  964. messageSends: ["visitAll:", "nodes"],
  965. referencedClasses: []
  966. }),
  967. globals.NodeVisitor);
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "visitReturnNode:",
  971. protocol: 'visiting',
  972. fn: function (aNode){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. var $1;
  976. $1=self._visitNode_(aNode);
  977. return $1;
  978. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},globals.NodeVisitor)})},
  979. args: ["aNode"],
  980. source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
  981. messageSends: ["visitNode:"],
  982. referencedClasses: []
  983. }),
  984. globals.NodeVisitor);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "visitSendNode:",
  988. protocol: 'visiting',
  989. fn: function (aNode){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. var $1;
  993. $1=self._visitNode_(aNode);
  994. return $1;
  995. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},globals.NodeVisitor)})},
  996. args: ["aNode"],
  997. source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
  998. messageSends: ["visitNode:"],
  999. referencedClasses: []
  1000. }),
  1001. globals.NodeVisitor);
  1002. smalltalk.addMethod(
  1003. smalltalk.method({
  1004. selector: "visitSequenceNode:",
  1005. protocol: 'visiting',
  1006. fn: function (aNode){
  1007. var self=this;
  1008. return smalltalk.withContext(function($ctx1) {
  1009. var $1;
  1010. $1=self._visitNode_(aNode);
  1011. return $1;
  1012. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},globals.NodeVisitor)})},
  1013. args: ["aNode"],
  1014. source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
  1015. messageSends: ["visitNode:"],
  1016. referencedClasses: []
  1017. }),
  1018. globals.NodeVisitor);
  1019. smalltalk.addMethod(
  1020. smalltalk.method({
  1021. selector: "visitValueNode:",
  1022. protocol: 'visiting',
  1023. fn: function (aNode){
  1024. var self=this;
  1025. return smalltalk.withContext(function($ctx1) {
  1026. var $1;
  1027. $1=self._visitNode_(aNode);
  1028. return $1;
  1029. }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},globals.NodeVisitor)})},
  1030. args: ["aNode"],
  1031. source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
  1032. messageSends: ["visitNode:"],
  1033. referencedClasses: []
  1034. }),
  1035. globals.NodeVisitor);
  1036. smalltalk.addMethod(
  1037. smalltalk.method({
  1038. selector: "visitVariableNode:",
  1039. protocol: 'visiting',
  1040. fn: function (aNode){
  1041. var self=this;
  1042. return smalltalk.withContext(function($ctx1) {
  1043. var $1;
  1044. $1=self._visitNode_(aNode);
  1045. return $1;
  1046. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},globals.NodeVisitor)})},
  1047. args: ["aNode"],
  1048. source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
  1049. messageSends: ["visitNode:"],
  1050. referencedClasses: []
  1051. }),
  1052. globals.NodeVisitor);
  1053. smalltalk.addMethod(
  1054. smalltalk.method({
  1055. selector: "asVariableName",
  1056. protocol: '*Compiler-Core',
  1057. fn: function (){
  1058. var self=this;
  1059. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1060. return smalltalk.withContext(function($ctx1) {
  1061. var $2,$1;
  1062. $2=_st(_st($Smalltalk())._reservedWords())._includes_(self);
  1063. if(smalltalk.assert($2)){
  1064. $1=self.__comma("_");
  1065. } else {
  1066. $1=self;
  1067. };
  1068. return $1;
  1069. }, function($ctx1) {$ctx1.fill(self,"asVariableName",{},globals.String)})},
  1070. args: [],
  1071. source: "asVariableName\x0a\x09^ (Smalltalk reservedWords includes: self)\x0a\x09\x09ifTrue: [ self, '_' ]\x0a\x09\x09ifFalse: [ self ]",
  1072. messageSends: ["ifTrue:ifFalse:", "includes:", "reservedWords", ","],
  1073. referencedClasses: ["Smalltalk"]
  1074. }),
  1075. globals.String);
  1076. });