Compiler-Core.js 52 KB

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