Compiler-Core.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  1. define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Infrastructure", "amber_core/Kernel-Collections"], function($boot){
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var smalltalk=$core,_st=$recv,globals=$globals;
  4. $core.addPackage('Compiler-Core');
  5. $core.packages["Compiler-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
  6. $core.addClass('AbstractCodeGenerator', $globals.Object, ['currentClass', 'source'], 'Compiler-Core');
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $globals.AbstractCodeGenerator.comment="I am the abstract super class of all code generators and provide their common API.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "classNameFor:",
  13. protocol: 'accessing',
  14. fn: function (aClass){
  15. var self=this;
  16. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  17. return $core.withContext(function($ctx1) {
  18. //>>excludeEnd("ctx");
  19. var $2,$3,$4,$1;
  20. $2=$recv(aClass)._isMetaclass();
  21. if($core.assert($2)){
  22. $3=$recv($recv(aClass)._instanceClass())._name();
  23. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  24. $ctx1.sendIdx["name"]=1;
  25. //>>excludeEnd("ctx");
  26. $1=$recv($3).__comma(".klass");
  27. } else {
  28. $4=$recv(aClass)._isNil();
  29. if($core.assert($4)){
  30. $1="nil";
  31. } else {
  32. $1=$recv(aClass)._name();
  33. };
  34. };
  35. return $1;
  36. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  37. }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},$globals.AbstractCodeGenerator)});
  38. //>>excludeEnd("ctx");
  39. },
  40. //>>excludeStart("ide", pragmas.excludeIdeData);
  41. args: ["aClass"],
  42. 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 ]]",
  43. referencedClasses: [],
  44. //>>excludeEnd("ide");
  45. messageSends: ["ifTrue:ifFalse:", "isMetaclass", ",", "name", "instanceClass", "isNil"]
  46. }),
  47. $globals.AbstractCodeGenerator);
  48. $core.addMethod(
  49. $core.method({
  50. selector: "compileNode:",
  51. protocol: 'compiling',
  52. fn: function (aNode){
  53. var self=this;
  54. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  55. return $core.withContext(function($ctx1) {
  56. //>>excludeEnd("ctx");
  57. self._subclassResponsibility();
  58. return self;
  59. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  60. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode},$globals.AbstractCodeGenerator)});
  61. //>>excludeEnd("ctx");
  62. },
  63. //>>excludeStart("ide", pragmas.excludeIdeData);
  64. args: ["aNode"],
  65. source: "compileNode: aNode\x0a\x09self subclassResponsibility",
  66. referencedClasses: [],
  67. //>>excludeEnd("ide");
  68. messageSends: ["subclassResponsibility"]
  69. }),
  70. $globals.AbstractCodeGenerator);
  71. $core.addMethod(
  72. $core.method({
  73. selector: "currentClass",
  74. protocol: 'accessing',
  75. fn: function (){
  76. var self=this;
  77. var $1;
  78. $1=self["@currentClass"];
  79. return $1;
  80. },
  81. //>>excludeStart("ide", pragmas.excludeIdeData);
  82. args: [],
  83. source: "currentClass\x0a\x09^ currentClass",
  84. referencedClasses: [],
  85. //>>excludeEnd("ide");
  86. messageSends: []
  87. }),
  88. $globals.AbstractCodeGenerator);
  89. $core.addMethod(
  90. $core.method({
  91. selector: "currentClass:",
  92. protocol: 'accessing',
  93. fn: function (aClass){
  94. var self=this;
  95. self["@currentClass"]=aClass;
  96. return self;
  97. },
  98. //>>excludeStart("ide", pragmas.excludeIdeData);
  99. args: ["aClass"],
  100. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  101. referencedClasses: [],
  102. //>>excludeEnd("ide");
  103. messageSends: []
  104. }),
  105. $globals.AbstractCodeGenerator);
  106. $core.addMethod(
  107. $core.method({
  108. selector: "pseudoVariables",
  109. protocol: 'accessing',
  110. fn: function (){
  111. var self=this;
  112. function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  114. return $core.withContext(function($ctx1) {
  115. //>>excludeEnd("ctx");
  116. var $1;
  117. $1=$recv($Smalltalk())._pseudoVariableNames();
  118. return $1;
  119. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  120. }, function($ctx1) {$ctx1.fill(self,"pseudoVariables",{},$globals.AbstractCodeGenerator)});
  121. //>>excludeEnd("ctx");
  122. },
  123. //>>excludeStart("ide", pragmas.excludeIdeData);
  124. args: [],
  125. source: "pseudoVariables\x0a\x09^ Smalltalk pseudoVariableNames",
  126. referencedClasses: ["Smalltalk"],
  127. //>>excludeEnd("ide");
  128. messageSends: ["pseudoVariableNames"]
  129. }),
  130. $globals.AbstractCodeGenerator);
  131. $core.addMethod(
  132. $core.method({
  133. selector: "source",
  134. protocol: 'accessing',
  135. fn: function (){
  136. var self=this;
  137. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  138. return $core.withContext(function($ctx1) {
  139. //>>excludeEnd("ctx");
  140. var $2,$1,$receiver;
  141. $2=self["@source"];
  142. if(($receiver = $2) == null || $receiver.isNil){
  143. $1="";
  144. } else {
  145. $1=$2;
  146. };
  147. return $1;
  148. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  149. }, function($ctx1) {$ctx1.fill(self,"source",{},$globals.AbstractCodeGenerator)});
  150. //>>excludeEnd("ctx");
  151. },
  152. //>>excludeStart("ide", pragmas.excludeIdeData);
  153. args: [],
  154. source: "source\x0a\x09^ source ifNil: [ '' ]",
  155. referencedClasses: [],
  156. //>>excludeEnd("ide");
  157. messageSends: ["ifNil:"]
  158. }),
  159. $globals.AbstractCodeGenerator);
  160. $core.addMethod(
  161. $core.method({
  162. selector: "source:",
  163. protocol: 'accessing',
  164. fn: function (aString){
  165. var self=this;
  166. self["@source"]=aString;
  167. return self;
  168. },
  169. //>>excludeStart("ide", pragmas.excludeIdeData);
  170. args: ["aString"],
  171. source: "source: aString\x0a\x09source := aString",
  172. referencedClasses: [],
  173. //>>excludeEnd("ide");
  174. messageSends: []
  175. }),
  176. $globals.AbstractCodeGenerator);
  177. $core.addClass('CodeGenerator', $globals.AbstractCodeGenerator, [], 'Compiler-Core');
  178. //>>excludeStart("ide", pragmas.excludeIdeData);
  179. $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.";
  180. //>>excludeEnd("ide");
  181. $core.addMethod(
  182. $core.method({
  183. selector: "compileNode:",
  184. protocol: 'compiling',
  185. fn: function (aNode){
  186. var self=this;
  187. var ir,stream;
  188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  189. return $core.withContext(function($ctx1) {
  190. //>>excludeEnd("ctx");
  191. var $2,$3,$1;
  192. $recv(self._semanticAnalyzer())._visit_(aNode);
  193. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  194. $ctx1.sendIdx["visit:"]=1;
  195. //>>excludeEnd("ctx");
  196. ir=$recv(self._translator())._visit_(aNode);
  197. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  198. $ctx1.sendIdx["visit:"]=2;
  199. //>>excludeEnd("ctx");
  200. $2=self._irTranslator();
  201. $recv($2)._currentClass_(self._currentClass());
  202. $recv($2)._visit_(ir);
  203. $3=$recv($2)._contents();
  204. $1=$3;
  205. return $1;
  206. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  207. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},$globals.CodeGenerator)});
  208. //>>excludeEnd("ctx");
  209. },
  210. //>>excludeStart("ide", pragmas.excludeIdeData);
  211. args: ["aNode"],
  212. 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",
  213. referencedClasses: [],
  214. //>>excludeEnd("ide");
  215. messageSends: ["visit:", "semanticAnalyzer", "translator", "currentClass:", "irTranslator", "currentClass", "contents"]
  216. }),
  217. $globals.CodeGenerator);
  218. $core.addMethod(
  219. $core.method({
  220. selector: "irTranslator",
  221. protocol: 'compiling',
  222. fn: function (){
  223. var self=this;
  224. function $IRJSTranslator(){return $globals.IRJSTranslator||(typeof IRJSTranslator=="undefined"?nil:IRJSTranslator)}
  225. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  226. return $core.withContext(function($ctx1) {
  227. //>>excludeEnd("ctx");
  228. var $1;
  229. $1=$recv($IRJSTranslator())._new();
  230. return $1;
  231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  232. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},$globals.CodeGenerator)});
  233. //>>excludeEnd("ctx");
  234. },
  235. //>>excludeStart("ide", pragmas.excludeIdeData);
  236. args: [],
  237. source: "irTranslator\x0a\x09^ IRJSTranslator new",
  238. referencedClasses: ["IRJSTranslator"],
  239. //>>excludeEnd("ide");
  240. messageSends: ["new"]
  241. }),
  242. $globals.CodeGenerator);
  243. $core.addMethod(
  244. $core.method({
  245. selector: "semanticAnalyzer",
  246. protocol: 'compiling',
  247. fn: function (){
  248. var self=this;
  249. function $SemanticAnalyzer(){return $globals.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  250. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  251. return $core.withContext(function($ctx1) {
  252. //>>excludeEnd("ctx");
  253. var $1;
  254. $1=$recv($SemanticAnalyzer())._on_(self._currentClass());
  255. return $1;
  256. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  257. }, function($ctx1) {$ctx1.fill(self,"semanticAnalyzer",{},$globals.CodeGenerator)});
  258. //>>excludeEnd("ctx");
  259. },
  260. //>>excludeStart("ide", pragmas.excludeIdeData);
  261. args: [],
  262. source: "semanticAnalyzer\x0a\x09^ SemanticAnalyzer on: self currentClass",
  263. referencedClasses: ["SemanticAnalyzer"],
  264. //>>excludeEnd("ide");
  265. messageSends: ["on:", "currentClass"]
  266. }),
  267. $globals.CodeGenerator);
  268. $core.addMethod(
  269. $core.method({
  270. selector: "translator",
  271. protocol: 'compiling',
  272. fn: function (){
  273. var self=this;
  274. function $IRASTTranslator(){return $globals.IRASTTranslator||(typeof IRASTTranslator=="undefined"?nil:IRASTTranslator)}
  275. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  276. return $core.withContext(function($ctx1) {
  277. //>>excludeEnd("ctx");
  278. var $2,$3,$1;
  279. $2=$recv($IRASTTranslator())._new();
  280. $recv($2)._source_(self._source());
  281. $recv($2)._theClass_(self._currentClass());
  282. $3=$recv($2)._yourself();
  283. $1=$3;
  284. return $1;
  285. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  286. }, function($ctx1) {$ctx1.fill(self,"translator",{},$globals.CodeGenerator)});
  287. //>>excludeEnd("ctx");
  288. },
  289. //>>excludeStart("ide", pragmas.excludeIdeData);
  290. args: [],
  291. source: "translator\x0a\x09^ IRASTTranslator new\x0a\x09\x09source: self source;\x0a\x09\x09theClass: self currentClass;\x0a\x09\x09yourself",
  292. referencedClasses: ["IRASTTranslator"],
  293. //>>excludeEnd("ide");
  294. messageSends: ["source:", "new", "source", "theClass:", "currentClass", "yourself"]
  295. }),
  296. $globals.CodeGenerator);
  297. $core.addClass('Compiler', $globals.Object, ['currentClass', 'source', 'unknownVariables', 'codeGeneratorClass'], 'Compiler-Core');
  298. //>>excludeStart("ide", pragmas.excludeIdeData);
  299. $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`";
  300. //>>excludeEnd("ide");
  301. $core.addMethod(
  302. $core.method({
  303. selector: "codeGeneratorClass",
  304. protocol: 'accessing',
  305. fn: function (){
  306. var self=this;
  307. function $InliningCodeGenerator(){return $globals.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  309. return $core.withContext(function($ctx1) {
  310. //>>excludeEnd("ctx");
  311. var $2,$1,$receiver;
  312. $2=self["@codeGeneratorClass"];
  313. if(($receiver = $2) == null || $receiver.isNil){
  314. $1=$InliningCodeGenerator();
  315. } else {
  316. $1=$2;
  317. };
  318. return $1;
  319. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  320. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},$globals.Compiler)});
  321. //>>excludeEnd("ctx");
  322. },
  323. //>>excludeStart("ide", pragmas.excludeIdeData);
  324. args: [],
  325. source: "codeGeneratorClass\x0a\x09^ codeGeneratorClass ifNil: [ InliningCodeGenerator ]",
  326. referencedClasses: ["InliningCodeGenerator"],
  327. //>>excludeEnd("ide");
  328. messageSends: ["ifNil:"]
  329. }),
  330. $globals.Compiler);
  331. $core.addMethod(
  332. $core.method({
  333. selector: "codeGeneratorClass:",
  334. protocol: 'accessing',
  335. fn: function (aClass){
  336. var self=this;
  337. self["@codeGeneratorClass"]=aClass;
  338. return self;
  339. },
  340. //>>excludeStart("ide", pragmas.excludeIdeData);
  341. args: ["aClass"],
  342. source: "codeGeneratorClass: aClass\x0a\x09codeGeneratorClass := aClass",
  343. referencedClasses: [],
  344. //>>excludeEnd("ide");
  345. messageSends: []
  346. }),
  347. $globals.Compiler);
  348. $core.addMethod(
  349. $core.method({
  350. selector: "compile:",
  351. protocol: 'compiling',
  352. fn: function (aString){
  353. var self=this;
  354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  355. return $core.withContext(function($ctx1) {
  356. //>>excludeEnd("ctx");
  357. var $1;
  358. $1=self._compileNode_(self._parse_(aString));
  359. return $1;
  360. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  361. }, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},$globals.Compiler)});
  362. //>>excludeEnd("ctx");
  363. },
  364. //>>excludeStart("ide", pragmas.excludeIdeData);
  365. args: ["aString"],
  366. source: "compile: aString\x0a\x09^ self compileNode: (self parse: aString)",
  367. referencedClasses: [],
  368. //>>excludeEnd("ide");
  369. messageSends: ["compileNode:", "parse:"]
  370. }),
  371. $globals.Compiler);
  372. $core.addMethod(
  373. $core.method({
  374. selector: "compile:forClass:",
  375. protocol: 'compiling',
  376. fn: function (aString,aClass){
  377. var self=this;
  378. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  379. return $core.withContext(function($ctx1) {
  380. //>>excludeEnd("ctx");
  381. var $1;
  382. self._currentClass_(aClass);
  383. self._source_(aString);
  384. $1=self._compile_(aString);
  385. return $1;
  386. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  387. }, function($ctx1) {$ctx1.fill(self,"compile:forClass:",{aString:aString,aClass:aClass},$globals.Compiler)});
  388. //>>excludeEnd("ctx");
  389. },
  390. //>>excludeStart("ide", pragmas.excludeIdeData);
  391. args: ["aString", "aClass"],
  392. source: "compile: aString forClass: aClass\x0a\x09self currentClass: aClass.\x0a\x09self source: aString.\x0a\x09^ self compile: aString",
  393. referencedClasses: [],
  394. //>>excludeEnd("ide");
  395. messageSends: ["currentClass:", "source:", "compile:"]
  396. }),
  397. $globals.Compiler);
  398. $core.addMethod(
  399. $core.method({
  400. selector: "compileExpression:",
  401. protocol: 'compiling',
  402. fn: function (aString){
  403. var self=this;
  404. function $DoIt(){return $globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  405. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  406. return $core.withContext(function($ctx1) {
  407. //>>excludeEnd("ctx");
  408. var $1,$2;
  409. self._currentClass_($DoIt());
  410. $1=$recv("doIt ^ [ ".__comma(aString)).__comma(" ] value");
  411. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  412. $ctx1.sendIdx[","]=1;
  413. //>>excludeEnd("ctx");
  414. self._source_($1);
  415. $2=self._compileNode_(self._parse_(self._source()));
  416. return $2;
  417. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  418. }, function($ctx1) {$ctx1.fill(self,"compileExpression:",{aString:aString},$globals.Compiler)});
  419. //>>excludeEnd("ctx");
  420. },
  421. //>>excludeStart("ide", pragmas.excludeIdeData);
  422. args: ["aString"],
  423. source: "compileExpression: aString\x0a\x09self currentClass: DoIt.\x0a\x09self source: 'doIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
  424. referencedClasses: ["DoIt"],
  425. //>>excludeEnd("ide");
  426. messageSends: ["currentClass:", "source:", ",", "compileNode:", "parse:", "source"]
  427. }),
  428. $globals.Compiler);
  429. $core.addMethod(
  430. $core.method({
  431. selector: "compileExpression:on:",
  432. protocol: 'compiling',
  433. fn: function (aString,anObject){
  434. var self=this;
  435. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  436. return $core.withContext(function($ctx1) {
  437. //>>excludeEnd("ctx");
  438. var $1,$2;
  439. self._currentClass_($recv(anObject)._class());
  440. $1=$recv("xxxDoIt ^ [ ".__comma(aString)).__comma(" ] value");
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. $ctx1.sendIdx[","]=1;
  443. //>>excludeEnd("ctx");
  444. self._source_($1);
  445. $2=self._compileNode_(self._parse_(self._source()));
  446. return $2;
  447. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  448. }, function($ctx1) {$ctx1.fill(self,"compileExpression:on:",{aString:aString,anObject:anObject},$globals.Compiler)});
  449. //>>excludeEnd("ctx");
  450. },
  451. //>>excludeStart("ide", pragmas.excludeIdeData);
  452. args: ["aString", "anObject"],
  453. source: "compileExpression: aString on: anObject\x0a\x09self currentClass: anObject class.\x0a\x09self source: 'xxxDoIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
  454. referencedClasses: [],
  455. //>>excludeEnd("ide");
  456. messageSends: ["currentClass:", "class", "source:", ",", "compileNode:", "parse:", "source"]
  457. }),
  458. $globals.Compiler);
  459. $core.addMethod(
  460. $core.method({
  461. selector: "compileNode:",
  462. protocol: 'compiling',
  463. fn: function (aNode){
  464. var self=this;
  465. var generator,result;
  466. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  467. return $core.withContext(function($ctx1) {
  468. //>>excludeEnd("ctx");
  469. var $1,$2,$3;
  470. generator=$recv(self._codeGeneratorClass())._new();
  471. $1=generator;
  472. $recv($1)._source_(self._source());
  473. $2=$recv($1)._currentClass_(self._currentClass());
  474. result=$recv(generator)._compileNode_(aNode);
  475. self._unknownVariables_([]);
  476. $3=result;
  477. return $3;
  478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  479. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,generator:generator,result:result},$globals.Compiler)});
  480. //>>excludeEnd("ctx");
  481. },
  482. //>>excludeStart("ide", pragmas.excludeIdeData);
  483. args: ["aNode"],
  484. 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",
  485. referencedClasses: [],
  486. //>>excludeEnd("ide");
  487. messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "compileNode:", "unknownVariables:"]
  488. }),
  489. $globals.Compiler);
  490. $core.addMethod(
  491. $core.method({
  492. selector: "currentClass",
  493. protocol: 'accessing',
  494. fn: function (){
  495. var self=this;
  496. var $1;
  497. $1=self["@currentClass"];
  498. return $1;
  499. },
  500. //>>excludeStart("ide", pragmas.excludeIdeData);
  501. args: [],
  502. source: "currentClass\x0a\x09^ currentClass",
  503. referencedClasses: [],
  504. //>>excludeEnd("ide");
  505. messageSends: []
  506. }),
  507. $globals.Compiler);
  508. $core.addMethod(
  509. $core.method({
  510. selector: "currentClass:",
  511. protocol: 'accessing',
  512. fn: function (aClass){
  513. var self=this;
  514. self["@currentClass"]=aClass;
  515. return self;
  516. },
  517. //>>excludeStart("ide", pragmas.excludeIdeData);
  518. args: ["aClass"],
  519. source: "currentClass: aClass\x0a\x09currentClass := aClass",
  520. referencedClasses: [],
  521. //>>excludeEnd("ide");
  522. messageSends: []
  523. }),
  524. $globals.Compiler);
  525. $core.addMethod(
  526. $core.method({
  527. selector: "eval:",
  528. protocol: 'compiling',
  529. fn: function (aString){
  530. var self=this;
  531. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  532. return $core.withContext(function($ctx1) {
  533. //>>excludeEnd("ctx");
  534. return eval(aString);
  535. return self;
  536. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  537. }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString},$globals.Compiler)});
  538. //>>excludeEnd("ctx");
  539. },
  540. //>>excludeStart("ide", pragmas.excludeIdeData);
  541. args: ["aString"],
  542. source: "eval: aString\x0a\x09<return eval(aString)>",
  543. referencedClasses: [],
  544. //>>excludeEnd("ide");
  545. messageSends: []
  546. }),
  547. $globals.Compiler);
  548. $core.addMethod(
  549. $core.method({
  550. selector: "evaluateExpression:",
  551. protocol: 'compiling',
  552. fn: function (aString){
  553. var self=this;
  554. function $DoIt(){return $globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  556. return $core.withContext(function($ctx1) {
  557. //>>excludeEnd("ctx");
  558. var $1;
  559. $1=self._evaluateExpression_on_(aString,$recv($DoIt())._new());
  560. return $1;
  561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  562. }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:",{aString:aString},$globals.Compiler)});
  563. //>>excludeEnd("ctx");
  564. },
  565. //>>excludeStart("ide", pragmas.excludeIdeData);
  566. args: ["aString"],
  567. 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",
  568. referencedClasses: ["DoIt"],
  569. //>>excludeEnd("ide");
  570. messageSends: ["evaluateExpression:on:", "new"]
  571. }),
  572. $globals.Compiler);
  573. $core.addMethod(
  574. $core.method({
  575. selector: "evaluateExpression:on:",
  576. protocol: 'compiling',
  577. fn: function (aString,anObject){
  578. var self=this;
  579. var result,method;
  580. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  581. return $core.withContext(function($ctx1) {
  582. //>>excludeEnd("ctx");
  583. var $1,$2;
  584. method=self._eval_(self._compileExpression_on_(aString,anObject));
  585. $recv(method)._protocol_("**xxxDoIt");
  586. $1=$recv(anObject)._class();
  587. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  588. $ctx1.sendIdx["class"]=1;
  589. //>>excludeEnd("ctx");
  590. $recv($1)._addCompiledMethod_(method);
  591. result=$recv(anObject)._xxxDoIt();
  592. $recv($recv(anObject)._class())._removeCompiledMethod_(method);
  593. $2=result;
  594. return $2;
  595. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  596. }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:on:",{aString:aString,anObject:anObject,result:result,method:method},$globals.Compiler)});
  597. //>>excludeEnd("ctx");
  598. },
  599. //>>excludeStart("ide", pragmas.excludeIdeData);
  600. args: ["aString", "anObject"],
  601. 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",
  602. referencedClasses: [],
  603. //>>excludeEnd("ide");
  604. messageSends: ["eval:", "compileExpression:on:", "protocol:", "addCompiledMethod:", "class", "xxxDoIt", "removeCompiledMethod:"]
  605. }),
  606. $globals.Compiler);
  607. $core.addMethod(
  608. $core.method({
  609. selector: "install:forClass:protocol:",
  610. protocol: 'compiling',
  611. fn: function (aString,aBehavior,anotherString){
  612. var self=this;
  613. function $ClassBuilder(){return $globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  614. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  615. return $core.withContext(function($ctx1) {
  616. //>>excludeEnd("ctx");
  617. var $1;
  618. $1=$recv($recv($ClassBuilder())._new())._installMethod_forClass_protocol_(self._eval_(self._compile_forClass_(aString,aBehavior)),aBehavior,anotherString);
  619. return $1;
  620. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  621. }, function($ctx1) {$ctx1.fill(self,"install:forClass:protocol:",{aString:aString,aBehavior:aBehavior,anotherString:anotherString},$globals.Compiler)});
  622. //>>excludeEnd("ctx");
  623. },
  624. //>>excludeStart("ide", pragmas.excludeIdeData);
  625. args: ["aString", "aBehavior", "anotherString"],
  626. 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",
  627. referencedClasses: ["ClassBuilder"],
  628. //>>excludeEnd("ide");
  629. messageSends: ["installMethod:forClass:protocol:", "new", "eval:", "compile:forClass:"]
  630. }),
  631. $globals.Compiler);
  632. $core.addMethod(
  633. $core.method({
  634. selector: "parse:",
  635. protocol: 'compiling',
  636. fn: function (aString){
  637. var self=this;
  638. function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  639. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  640. return $core.withContext(function($ctx1) {
  641. //>>excludeEnd("ctx");
  642. var $1;
  643. $1=$recv($Smalltalk())._parse_(aString);
  644. return $1;
  645. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  646. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},$globals.Compiler)});
  647. //>>excludeEnd("ctx");
  648. },
  649. //>>excludeStart("ide", pragmas.excludeIdeData);
  650. args: ["aString"],
  651. source: "parse: aString\x0a\x09^ Smalltalk parse: aString",
  652. referencedClasses: ["Smalltalk"],
  653. //>>excludeEnd("ide");
  654. messageSends: ["parse:"]
  655. }),
  656. $globals.Compiler);
  657. $core.addMethod(
  658. $core.method({
  659. selector: "parseExpression:",
  660. protocol: 'compiling',
  661. fn: function (aString){
  662. var self=this;
  663. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  664. return $core.withContext(function($ctx1) {
  665. //>>excludeEnd("ctx");
  666. var $2,$1;
  667. $2=$recv("doIt ^ [ ".__comma(aString)).__comma(" ] value");
  668. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  669. $ctx1.sendIdx[","]=1;
  670. //>>excludeEnd("ctx");
  671. $1=self._parse_($2);
  672. return $1;
  673. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  674. }, function($ctx1) {$ctx1.fill(self,"parseExpression:",{aString:aString},$globals.Compiler)});
  675. //>>excludeEnd("ctx");
  676. },
  677. //>>excludeStart("ide", pragmas.excludeIdeData);
  678. args: ["aString"],
  679. source: "parseExpression: aString\x0a\x09^ self parse: 'doIt ^ [ ', aString, ' ] value'",
  680. referencedClasses: [],
  681. //>>excludeEnd("ide");
  682. messageSends: ["parse:", ","]
  683. }),
  684. $globals.Compiler);
  685. $core.addMethod(
  686. $core.method({
  687. selector: "recompile:",
  688. protocol: 'compiling',
  689. fn: function (aClass){
  690. var self=this;
  691. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  692. return $core.withContext(function($ctx1) {
  693. //>>excludeEnd("ctx");
  694. var $1;
  695. $recv($recv($recv(aClass)._methodDictionary())._values())._do_displayingProgress_((function(each){
  696. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  697. return $core.withContext(function($ctx2) {
  698. //>>excludeEnd("ctx");
  699. return self._install_forClass_protocol_($recv(each)._source(),aClass,$recv(each)._protocol());
  700. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  701. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  702. //>>excludeEnd("ctx");
  703. }),"Recompiling ".__comma($recv(aClass)._name()));
  704. $1=$recv(aClass)._isMetaclass();
  705. if(!$core.assert($1)){
  706. self._recompile_($recv(aClass)._class());
  707. };
  708. return self;
  709. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  710. }, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},$globals.Compiler)});
  711. //>>excludeEnd("ctx");
  712. },
  713. //>>excludeStart("ide", pragmas.excludeIdeData);
  714. args: ["aClass"],
  715. 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 ]",
  716. referencedClasses: [],
  717. //>>excludeEnd("ide");
  718. messageSends: ["do:displayingProgress:", "values", "methodDictionary", "install:forClass:protocol:", "source", "protocol", ",", "name", "ifFalse:", "isMetaclass", "recompile:", "class"]
  719. }),
  720. $globals.Compiler);
  721. $core.addMethod(
  722. $core.method({
  723. selector: "recompileAll",
  724. protocol: 'compiling',
  725. fn: function (){
  726. var self=this;
  727. function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  728. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  729. return $core.withContext(function($ctx1) {
  730. //>>excludeEnd("ctx");
  731. $recv($recv($Smalltalk())._classes())._do_displayingProgress_((function(each){
  732. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  733. return $core.withContext(function($ctx2) {
  734. //>>excludeEnd("ctx");
  735. return self._recompile_(each);
  736. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  737. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  738. //>>excludeEnd("ctx");
  739. }),"Compiling all classes...");
  740. return self;
  741. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  742. }, function($ctx1) {$ctx1.fill(self,"recompileAll",{},$globals.Compiler)});
  743. //>>excludeEnd("ctx");
  744. },
  745. //>>excludeStart("ide", pragmas.excludeIdeData);
  746. args: [],
  747. source: "recompileAll\x0a\x09Smalltalk classes \x0a\x09\x09do: [ :each | self recompile: each ]\x0a\x09\x09displayingProgress: 'Compiling all classes...'",
  748. referencedClasses: ["Smalltalk"],
  749. //>>excludeEnd("ide");
  750. messageSends: ["do:displayingProgress:", "classes", "recompile:"]
  751. }),
  752. $globals.Compiler);
  753. $core.addMethod(
  754. $core.method({
  755. selector: "source",
  756. protocol: 'accessing',
  757. fn: function (){
  758. var self=this;
  759. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  760. return $core.withContext(function($ctx1) {
  761. //>>excludeEnd("ctx");
  762. var $2,$1,$receiver;
  763. $2=self["@source"];
  764. if(($receiver = $2) == null || $receiver.isNil){
  765. $1="";
  766. } else {
  767. $1=$2;
  768. };
  769. return $1;
  770. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  771. }, function($ctx1) {$ctx1.fill(self,"source",{},$globals.Compiler)});
  772. //>>excludeEnd("ctx");
  773. },
  774. //>>excludeStart("ide", pragmas.excludeIdeData);
  775. args: [],
  776. source: "source\x0a\x09^ source ifNil: [ '' ]",
  777. referencedClasses: [],
  778. //>>excludeEnd("ide");
  779. messageSends: ["ifNil:"]
  780. }),
  781. $globals.Compiler);
  782. $core.addMethod(
  783. $core.method({
  784. selector: "source:",
  785. protocol: 'accessing',
  786. fn: function (aString){
  787. var self=this;
  788. self["@source"]=aString;
  789. return self;
  790. },
  791. //>>excludeStart("ide", pragmas.excludeIdeData);
  792. args: ["aString"],
  793. source: "source: aString\x0a\x09source := aString",
  794. referencedClasses: [],
  795. //>>excludeEnd("ide");
  796. messageSends: []
  797. }),
  798. $globals.Compiler);
  799. $core.addMethod(
  800. $core.method({
  801. selector: "unknownVariables",
  802. protocol: 'accessing',
  803. fn: function (){
  804. var self=this;
  805. var $1;
  806. $1=self["@unknownVariables"];
  807. return $1;
  808. },
  809. //>>excludeStart("ide", pragmas.excludeIdeData);
  810. args: [],
  811. source: "unknownVariables\x0a\x09^ unknownVariables",
  812. referencedClasses: [],
  813. //>>excludeEnd("ide");
  814. messageSends: []
  815. }),
  816. $globals.Compiler);
  817. $core.addMethod(
  818. $core.method({
  819. selector: "unknownVariables:",
  820. protocol: 'accessing',
  821. fn: function (aCollection){
  822. var self=this;
  823. self["@unknownVariables"]=aCollection;
  824. return self;
  825. },
  826. //>>excludeStart("ide", pragmas.excludeIdeData);
  827. args: ["aCollection"],
  828. source: "unknownVariables: aCollection\x0a\x09unknownVariables := aCollection",
  829. referencedClasses: [],
  830. //>>excludeEnd("ide");
  831. messageSends: []
  832. }),
  833. $globals.Compiler);
  834. $core.addMethod(
  835. $core.method({
  836. selector: "recompile:",
  837. protocol: 'compiling',
  838. fn: function (aClass){
  839. var self=this;
  840. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  841. return $core.withContext(function($ctx1) {
  842. //>>excludeEnd("ctx");
  843. $recv(self._new())._recompile_(aClass);
  844. return self;
  845. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  846. }, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},$globals.Compiler.klass)});
  847. //>>excludeEnd("ctx");
  848. },
  849. //>>excludeStart("ide", pragmas.excludeIdeData);
  850. args: ["aClass"],
  851. source: "recompile: aClass\x0a\x09self new recompile: aClass",
  852. referencedClasses: [],
  853. //>>excludeEnd("ide");
  854. messageSends: ["recompile:", "new"]
  855. }),
  856. $globals.Compiler.klass);
  857. $core.addMethod(
  858. $core.method({
  859. selector: "recompileAll",
  860. protocol: 'compiling',
  861. fn: function (){
  862. var self=this;
  863. function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  864. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  865. return $core.withContext(function($ctx1) {
  866. //>>excludeEnd("ctx");
  867. $recv($recv($Smalltalk())._classes())._do_((function(each){
  868. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  869. return $core.withContext(function($ctx2) {
  870. //>>excludeEnd("ctx");
  871. return self._recompile_(each);
  872. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  873. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  874. //>>excludeEnd("ctx");
  875. }));
  876. return self;
  877. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  878. }, function($ctx1) {$ctx1.fill(self,"recompileAll",{},$globals.Compiler.klass)});
  879. //>>excludeEnd("ctx");
  880. },
  881. //>>excludeStart("ide", pragmas.excludeIdeData);
  882. args: [],
  883. source: "recompileAll\x0a\x09Smalltalk classes do: [ :each |\x0a\x09\x09self recompile: each ]",
  884. referencedClasses: ["Smalltalk"],
  885. //>>excludeEnd("ide");
  886. messageSends: ["do:", "classes", "recompile:"]
  887. }),
  888. $globals.Compiler.klass);
  889. $core.addClass('DoIt', $globals.Object, [], 'Compiler-Core');
  890. //>>excludeStart("ide", pragmas.excludeIdeData);
  891. $globals.DoIt.comment="`DoIt` is the class used to compile and evaluate expressions. See `Compiler >> evaluateExpression:`.";
  892. //>>excludeEnd("ide");
  893. $core.addClass('Evaluator', $globals.InterfacingObject, [], 'Compiler-Core');
  894. //>>excludeStart("ide", pragmas.excludeIdeData);
  895. $globals.Evaluator.comment="I evaluate code against a receiver, dispatching #evaluate:on: to the receiver.";
  896. //>>excludeEnd("ide");
  897. $core.addMethod(
  898. $core.method({
  899. selector: "evaluate:context:",
  900. protocol: 'evaluating',
  901. fn: function (aString,aContext){
  902. var self=this;
  903. var compiler,ast;
  904. function $Compiler(){return $globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  905. function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
  906. function $AISemanticAnalyzer(){return $globals.AISemanticAnalyzer||(typeof AISemanticAnalyzer=="undefined"?nil:AISemanticAnalyzer)}
  907. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  908. return $core.withContext(function($ctx1) {
  909. //>>excludeEnd("ctx");
  910. var $1,$2,$3,$4;
  911. var $early={};
  912. try {
  913. compiler=$recv($Compiler())._new();
  914. $recv((function(){
  915. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  916. return $core.withContext(function($ctx2) {
  917. //>>excludeEnd("ctx");
  918. ast=$recv(compiler)._parseExpression_(aString);
  919. return ast;
  920. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  921. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  922. //>>excludeEnd("ctx");
  923. }))._on_do_($Error(),(function(ex){
  924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  925. return $core.withContext(function($ctx2) {
  926. //>>excludeEnd("ctx");
  927. $1=self._alert_($recv(ex)._messageText());
  928. throw $early=[$1];
  929. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  930. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
  931. //>>excludeEnd("ctx");
  932. }));
  933. $2=$recv($AISemanticAnalyzer())._on_($recv($recv(aContext)._receiver())._class());
  934. $recv($2)._context_(aContext);
  935. $3=$recv($2)._visit_(ast);
  936. $4=$recv(aContext)._evaluateNode_(ast);
  937. return $4;
  938. }
  939. catch(e) {if(e===$early)return e[0]; throw e}
  940. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  941. }, function($ctx1) {$ctx1.fill(self,"evaluate:context:",{aString:aString,aContext:aContext,compiler:compiler,ast:ast},$globals.Evaluator)});
  942. //>>excludeEnd("ctx");
  943. },
  944. //>>excludeStart("ide", pragmas.excludeIdeData);
  945. args: ["aString", "aContext"],
  946. 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",
  947. referencedClasses: ["Compiler", "Error", "AISemanticAnalyzer"],
  948. //>>excludeEnd("ide");
  949. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "context:", "on:", "class", "receiver", "visit:", "evaluateNode:"]
  950. }),
  951. $globals.Evaluator);
  952. $core.addMethod(
  953. $core.method({
  954. selector: "evaluate:for:",
  955. protocol: 'evaluating',
  956. fn: function (aString,anObject){
  957. var self=this;
  958. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  959. return $core.withContext(function($ctx1) {
  960. //>>excludeEnd("ctx");
  961. var $1;
  962. $1=$recv(anObject)._evaluate_on_(aString,self);
  963. return $1;
  964. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  965. }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},$globals.Evaluator)});
  966. //>>excludeEnd("ctx");
  967. },
  968. //>>excludeStart("ide", pragmas.excludeIdeData);
  969. args: ["aString", "anObject"],
  970. source: "evaluate: aString for: anObject\x0a\x09^ anObject evaluate: aString on: self",
  971. referencedClasses: [],
  972. //>>excludeEnd("ide");
  973. messageSends: ["evaluate:on:"]
  974. }),
  975. $globals.Evaluator);
  976. $core.addMethod(
  977. $core.method({
  978. selector: "evaluate:receiver:",
  979. protocol: 'evaluating',
  980. fn: function (aString,anObject){
  981. var self=this;
  982. var compiler;
  983. function $Compiler(){return $globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  984. function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
  985. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  986. return $core.withContext(function($ctx1) {
  987. //>>excludeEnd("ctx");
  988. var $1,$2;
  989. var $early={};
  990. try {
  991. compiler=$recv($Compiler())._new();
  992. $recv((function(){
  993. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  994. return $core.withContext(function($ctx2) {
  995. //>>excludeEnd("ctx");
  996. return $recv(compiler)._parseExpression_(aString);
  997. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  998. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  999. //>>excludeEnd("ctx");
  1000. }))._on_do_($Error(),(function(ex){
  1001. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1002. return $core.withContext(function($ctx2) {
  1003. //>>excludeEnd("ctx");
  1004. $1=self._alert_($recv(ex)._messageText());
  1005. throw $early=[$1];
  1006. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1007. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
  1008. //>>excludeEnd("ctx");
  1009. }));
  1010. $2=$recv(compiler)._evaluateExpression_on_(aString,anObject);
  1011. return $2;
  1012. }
  1013. catch(e) {if(e===$early)return e[0]; throw e}
  1014. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1015. }, function($ctx1) {$ctx1.fill(self,"evaluate:receiver:",{aString:aString,anObject:anObject,compiler:compiler},$globals.Evaluator)});
  1016. //>>excludeEnd("ctx");
  1017. },
  1018. //>>excludeStart("ide", pragmas.excludeIdeData);
  1019. args: ["aString", "anObject"],
  1020. 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",
  1021. referencedClasses: ["Compiler", "Error"],
  1022. //>>excludeEnd("ide");
  1023. messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "evaluateExpression:on:"]
  1024. }),
  1025. $globals.Evaluator);
  1026. $core.addMethod(
  1027. $core.method({
  1028. selector: "evaluate:for:",
  1029. protocol: 'instance creation',
  1030. fn: function (aString,anObject){
  1031. var self=this;
  1032. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1033. return $core.withContext(function($ctx1) {
  1034. //>>excludeEnd("ctx");
  1035. var $1;
  1036. $1=$recv(self._new())._evaluate_for_(aString,anObject);
  1037. return $1;
  1038. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1039. }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},$globals.Evaluator.klass)});
  1040. //>>excludeEnd("ctx");
  1041. },
  1042. //>>excludeStart("ide", pragmas.excludeIdeData);
  1043. args: ["aString", "anObject"],
  1044. source: "evaluate: aString for: anObject\x0a\x09^ self new evaluate: aString for: anObject",
  1045. referencedClasses: [],
  1046. //>>excludeEnd("ide");
  1047. messageSends: ["evaluate:for:", "new"]
  1048. }),
  1049. $globals.Evaluator.klass);
  1050. $core.addClass('NodeVisitor', $globals.Object, [], 'Compiler-Core');
  1051. //>>excludeStart("ide", pragmas.excludeIdeData);
  1052. $globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
  1053. //>>excludeEnd("ide");
  1054. $core.addMethod(
  1055. $core.method({
  1056. selector: "visit:",
  1057. protocol: 'visiting',
  1058. fn: function (aNode){
  1059. var self=this;
  1060. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1061. return $core.withContext(function($ctx1) {
  1062. //>>excludeEnd("ctx");
  1063. var $1;
  1064. $1=$recv(aNode)._accept_(self);
  1065. return $1;
  1066. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1067. }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},$globals.NodeVisitor)});
  1068. //>>excludeEnd("ctx");
  1069. },
  1070. //>>excludeStart("ide", pragmas.excludeIdeData);
  1071. args: ["aNode"],
  1072. source: "visit: aNode\x0a\x09^ aNode accept: self",
  1073. referencedClasses: [],
  1074. //>>excludeEnd("ide");
  1075. messageSends: ["accept:"]
  1076. }),
  1077. $globals.NodeVisitor);
  1078. $core.addMethod(
  1079. $core.method({
  1080. selector: "visitAll:",
  1081. protocol: 'visiting',
  1082. fn: function (aCollection){
  1083. var self=this;
  1084. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1085. return $core.withContext(function($ctx1) {
  1086. //>>excludeEnd("ctx");
  1087. var $1;
  1088. $1=$recv(aCollection)._collect_((function(each){
  1089. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1090. return $core.withContext(function($ctx2) {
  1091. //>>excludeEnd("ctx");
  1092. return self._visit_(each);
  1093. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1094. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1095. //>>excludeEnd("ctx");
  1096. }));
  1097. return $1;
  1098. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1099. }, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},$globals.NodeVisitor)});
  1100. //>>excludeEnd("ctx");
  1101. },
  1102. //>>excludeStart("ide", pragmas.excludeIdeData);
  1103. args: ["aCollection"],
  1104. source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
  1105. referencedClasses: [],
  1106. //>>excludeEnd("ide");
  1107. messageSends: ["collect:", "visit:"]
  1108. }),
  1109. $globals.NodeVisitor);
  1110. $core.addMethod(
  1111. $core.method({
  1112. selector: "visitAssignmentNode:",
  1113. protocol: 'visiting',
  1114. fn: function (aNode){
  1115. var self=this;
  1116. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1117. return $core.withContext(function($ctx1) {
  1118. //>>excludeEnd("ctx");
  1119. var $1;
  1120. $1=self._visitNode_(aNode);
  1121. return $1;
  1122. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1123. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},$globals.NodeVisitor)});
  1124. //>>excludeEnd("ctx");
  1125. },
  1126. //>>excludeStart("ide", pragmas.excludeIdeData);
  1127. args: ["aNode"],
  1128. source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
  1129. referencedClasses: [],
  1130. //>>excludeEnd("ide");
  1131. messageSends: ["visitNode:"]
  1132. }),
  1133. $globals.NodeVisitor);
  1134. $core.addMethod(
  1135. $core.method({
  1136. selector: "visitBlockNode:",
  1137. protocol: 'visiting',
  1138. fn: function (aNode){
  1139. var self=this;
  1140. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1141. return $core.withContext(function($ctx1) {
  1142. //>>excludeEnd("ctx");
  1143. var $1;
  1144. $1=self._visitNode_(aNode);
  1145. return $1;
  1146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1147. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},$globals.NodeVisitor)});
  1148. //>>excludeEnd("ctx");
  1149. },
  1150. //>>excludeStart("ide", pragmas.excludeIdeData);
  1151. args: ["aNode"],
  1152. source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
  1153. referencedClasses: [],
  1154. //>>excludeEnd("ide");
  1155. messageSends: ["visitNode:"]
  1156. }),
  1157. $globals.NodeVisitor);
  1158. $core.addMethod(
  1159. $core.method({
  1160. selector: "visitBlockSequenceNode:",
  1161. protocol: 'visiting',
  1162. fn: function (aNode){
  1163. var self=this;
  1164. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1165. return $core.withContext(function($ctx1) {
  1166. //>>excludeEnd("ctx");
  1167. var $1;
  1168. $1=self._visitSequenceNode_(aNode);
  1169. return $1;
  1170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1171. }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
  1172. //>>excludeEnd("ctx");
  1173. },
  1174. //>>excludeStart("ide", pragmas.excludeIdeData);
  1175. args: ["aNode"],
  1176. source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
  1177. referencedClasses: [],
  1178. //>>excludeEnd("ide");
  1179. messageSends: ["visitSequenceNode:"]
  1180. }),
  1181. $globals.NodeVisitor);
  1182. $core.addMethod(
  1183. $core.method({
  1184. selector: "visitCascadeNode:",
  1185. protocol: 'visiting',
  1186. fn: function (aNode){
  1187. var self=this;
  1188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1189. return $core.withContext(function($ctx1) {
  1190. //>>excludeEnd("ctx");
  1191. var $1;
  1192. $1=self._visitNode_(aNode);
  1193. return $1;
  1194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1195. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},$globals.NodeVisitor)});
  1196. //>>excludeEnd("ctx");
  1197. },
  1198. //>>excludeStart("ide", pragmas.excludeIdeData);
  1199. args: ["aNode"],
  1200. source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
  1201. referencedClasses: [],
  1202. //>>excludeEnd("ide");
  1203. messageSends: ["visitNode:"]
  1204. }),
  1205. $globals.NodeVisitor);
  1206. $core.addMethod(
  1207. $core.method({
  1208. selector: "visitDynamicArrayNode:",
  1209. protocol: 'visiting',
  1210. fn: function (aNode){
  1211. var self=this;
  1212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1213. return $core.withContext(function($ctx1) {
  1214. //>>excludeEnd("ctx");
  1215. var $1;
  1216. $1=self._visitNode_(aNode);
  1217. return $1;
  1218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1219. }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},$globals.NodeVisitor)});
  1220. //>>excludeEnd("ctx");
  1221. },
  1222. //>>excludeStart("ide", pragmas.excludeIdeData);
  1223. args: ["aNode"],
  1224. source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
  1225. referencedClasses: [],
  1226. //>>excludeEnd("ide");
  1227. messageSends: ["visitNode:"]
  1228. }),
  1229. $globals.NodeVisitor);
  1230. $core.addMethod(
  1231. $core.method({
  1232. selector: "visitDynamicDictionaryNode:",
  1233. protocol: 'visiting',
  1234. fn: function (aNode){
  1235. var self=this;
  1236. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1237. return $core.withContext(function($ctx1) {
  1238. //>>excludeEnd("ctx");
  1239. var $1;
  1240. $1=self._visitNode_(aNode);
  1241. return $1;
  1242. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1243. }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},$globals.NodeVisitor)});
  1244. //>>excludeEnd("ctx");
  1245. },
  1246. //>>excludeStart("ide", pragmas.excludeIdeData);
  1247. args: ["aNode"],
  1248. source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
  1249. referencedClasses: [],
  1250. //>>excludeEnd("ide");
  1251. messageSends: ["visitNode:"]
  1252. }),
  1253. $globals.NodeVisitor);
  1254. $core.addMethod(
  1255. $core.method({
  1256. selector: "visitJSStatementNode:",
  1257. protocol: 'visiting',
  1258. fn: function (aNode){
  1259. var self=this;
  1260. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1261. return $core.withContext(function($ctx1) {
  1262. //>>excludeEnd("ctx");
  1263. var $1;
  1264. $1=self._visitNode_(aNode);
  1265. return $1;
  1266. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1267. }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},$globals.NodeVisitor)});
  1268. //>>excludeEnd("ctx");
  1269. },
  1270. //>>excludeStart("ide", pragmas.excludeIdeData);
  1271. args: ["aNode"],
  1272. source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
  1273. referencedClasses: [],
  1274. //>>excludeEnd("ide");
  1275. messageSends: ["visitNode:"]
  1276. }),
  1277. $globals.NodeVisitor);
  1278. $core.addMethod(
  1279. $core.method({
  1280. selector: "visitMethodNode:",
  1281. protocol: 'visiting',
  1282. fn: function (aNode){
  1283. var self=this;
  1284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1285. return $core.withContext(function($ctx1) {
  1286. //>>excludeEnd("ctx");
  1287. var $1;
  1288. $1=self._visitNode_(aNode);
  1289. return $1;
  1290. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1291. }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},$globals.NodeVisitor)});
  1292. //>>excludeEnd("ctx");
  1293. },
  1294. //>>excludeStart("ide", pragmas.excludeIdeData);
  1295. args: ["aNode"],
  1296. source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
  1297. referencedClasses: [],
  1298. //>>excludeEnd("ide");
  1299. messageSends: ["visitNode:"]
  1300. }),
  1301. $globals.NodeVisitor);
  1302. $core.addMethod(
  1303. $core.method({
  1304. selector: "visitNode:",
  1305. protocol: 'visiting',
  1306. fn: function (aNode){
  1307. var self=this;
  1308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1309. return $core.withContext(function($ctx1) {
  1310. //>>excludeEnd("ctx");
  1311. var $1;
  1312. $1=self._visitAll_($recv(aNode)._nodes());
  1313. return $1;
  1314. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1315. }, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},$globals.NodeVisitor)});
  1316. //>>excludeEnd("ctx");
  1317. },
  1318. //>>excludeStart("ide", pragmas.excludeIdeData);
  1319. args: ["aNode"],
  1320. source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
  1321. referencedClasses: [],
  1322. //>>excludeEnd("ide");
  1323. messageSends: ["visitAll:", "nodes"]
  1324. }),
  1325. $globals.NodeVisitor);
  1326. $core.addMethod(
  1327. $core.method({
  1328. selector: "visitReturnNode:",
  1329. protocol: 'visiting',
  1330. fn: function (aNode){
  1331. var self=this;
  1332. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1333. return $core.withContext(function($ctx1) {
  1334. //>>excludeEnd("ctx");
  1335. var $1;
  1336. $1=self._visitNode_(aNode);
  1337. return $1;
  1338. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1339. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},$globals.NodeVisitor)});
  1340. //>>excludeEnd("ctx");
  1341. },
  1342. //>>excludeStart("ide", pragmas.excludeIdeData);
  1343. args: ["aNode"],
  1344. source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
  1345. referencedClasses: [],
  1346. //>>excludeEnd("ide");
  1347. messageSends: ["visitNode:"]
  1348. }),
  1349. $globals.NodeVisitor);
  1350. $core.addMethod(
  1351. $core.method({
  1352. selector: "visitSendNode:",
  1353. protocol: 'visiting',
  1354. fn: function (aNode){
  1355. var self=this;
  1356. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1357. return $core.withContext(function($ctx1) {
  1358. //>>excludeEnd("ctx");
  1359. var $1;
  1360. $1=self._visitNode_(aNode);
  1361. return $1;
  1362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1363. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.NodeVisitor)});
  1364. //>>excludeEnd("ctx");
  1365. },
  1366. //>>excludeStart("ide", pragmas.excludeIdeData);
  1367. args: ["aNode"],
  1368. source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
  1369. referencedClasses: [],
  1370. //>>excludeEnd("ide");
  1371. messageSends: ["visitNode:"]
  1372. }),
  1373. $globals.NodeVisitor);
  1374. $core.addMethod(
  1375. $core.method({
  1376. selector: "visitSequenceNode:",
  1377. protocol: 'visiting',
  1378. fn: function (aNode){
  1379. var self=this;
  1380. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1381. return $core.withContext(function($ctx1) {
  1382. //>>excludeEnd("ctx");
  1383. var $1;
  1384. $1=self._visitNode_(aNode);
  1385. return $1;
  1386. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1387. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
  1388. //>>excludeEnd("ctx");
  1389. },
  1390. //>>excludeStart("ide", pragmas.excludeIdeData);
  1391. args: ["aNode"],
  1392. source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
  1393. referencedClasses: [],
  1394. //>>excludeEnd("ide");
  1395. messageSends: ["visitNode:"]
  1396. }),
  1397. $globals.NodeVisitor);
  1398. $core.addMethod(
  1399. $core.method({
  1400. selector: "visitValueNode:",
  1401. protocol: 'visiting',
  1402. fn: function (aNode){
  1403. var self=this;
  1404. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1405. return $core.withContext(function($ctx1) {
  1406. //>>excludeEnd("ctx");
  1407. var $1;
  1408. $1=self._visitNode_(aNode);
  1409. return $1;
  1410. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1411. }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},$globals.NodeVisitor)});
  1412. //>>excludeEnd("ctx");
  1413. },
  1414. //>>excludeStart("ide", pragmas.excludeIdeData);
  1415. args: ["aNode"],
  1416. source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
  1417. referencedClasses: [],
  1418. //>>excludeEnd("ide");
  1419. messageSends: ["visitNode:"]
  1420. }),
  1421. $globals.NodeVisitor);
  1422. $core.addMethod(
  1423. $core.method({
  1424. selector: "visitVariableNode:",
  1425. protocol: 'visiting',
  1426. fn: function (aNode){
  1427. var self=this;
  1428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1429. return $core.withContext(function($ctx1) {
  1430. //>>excludeEnd("ctx");
  1431. var $1;
  1432. $1=self._visitNode_(aNode);
  1433. return $1;
  1434. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1435. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},$globals.NodeVisitor)});
  1436. //>>excludeEnd("ctx");
  1437. },
  1438. //>>excludeStart("ide", pragmas.excludeIdeData);
  1439. args: ["aNode"],
  1440. source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
  1441. referencedClasses: [],
  1442. //>>excludeEnd("ide");
  1443. messageSends: ["visitNode:"]
  1444. }),
  1445. $globals.NodeVisitor);
  1446. $core.addMethod(
  1447. $core.method({
  1448. selector: "asVariableName",
  1449. protocol: '*Compiler-Core',
  1450. fn: function (){
  1451. var self=this;
  1452. function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1454. return $core.withContext(function($ctx1) {
  1455. //>>excludeEnd("ctx");
  1456. var $2,$1;
  1457. $2=$recv($recv($Smalltalk())._reservedWords())._includes_(self);
  1458. if($core.assert($2)){
  1459. $1=self.__comma("_");
  1460. } else {
  1461. $1=self;
  1462. };
  1463. return $1;
  1464. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1465. }, function($ctx1) {$ctx1.fill(self,"asVariableName",{},$globals.String)});
  1466. //>>excludeEnd("ctx");
  1467. },
  1468. //>>excludeStart("ide", pragmas.excludeIdeData);
  1469. args: [],
  1470. source: "asVariableName\x0a\x09^ (Smalltalk reservedWords includes: self)\x0a\x09\x09ifTrue: [ self, '_' ]\x0a\x09\x09ifFalse: [ self ]",
  1471. referencedClasses: ["Smalltalk"],
  1472. //>>excludeEnd("ide");
  1473. messageSends: ["ifTrue:ifFalse:", "includes:", "reservedWords", ","]
  1474. }),
  1475. $globals.String);
  1476. });