1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552 |
- define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Infrastructure", "amber_core/Kernel-Collections"], function($boot){
- var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
- var smalltalk=$core,_st=$recv,globals=$globals;
- $core.addPackage('Compiler-Core');
- $core.packages["Compiler-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
- $core.addClass('AbstractCodeGenerator', $globals.Object, ['currentClass', 'source'], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.AbstractCodeGenerator.comment="I am the abstract super class of all code generators and provide their common API.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "classNameFor:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$3,$4,$1;
- $2=$recv(aClass)._isMetaclass();
- if($core.assert($2)){
- $3=$recv($recv(aClass)._instanceClass())._name();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx["name"]=1;
- //>>excludeEnd("ctx");
- $1=$recv($3).__comma(".klass");
- } else {
- $4=$recv(aClass)._isNil();
- if($core.assert($4)){
- $1="nil";
- } else {
- $1=$recv(aClass)._name();
- };
- };
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},$globals.AbstractCodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aClass"],
- 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 ]]",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["ifTrue:ifFalse:", "isMetaclass", ",", "name", "instanceClass", "isNil"]
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- self._subclassResponsibility();
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode},$globals.AbstractCodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "compileNode: aNode\x0a\x09self subclassResponsibility",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["subclassResponsibility"]
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "currentClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@currentClass"];
- return $1;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "currentClass\x0a\x09^ currentClass",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "currentClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@currentClass"]=aClass;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aClass"],
- source: "currentClass: aClass\x0a\x09currentClass := aClass",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "pseudoVariables",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv($Smalltalk())._pseudoVariableNames();
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"pseudoVariables",{},$globals.AbstractCodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "pseudoVariables\x0a\x09^ Smalltalk pseudoVariableNames",
- referencedClasses: ["Smalltalk"],
- //>>excludeEnd("ide");
- messageSends: ["pseudoVariableNames"]
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$1,$receiver;
- $2=self["@source"];
- if(($receiver = $2) == null || $receiver.isNil){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"source",{},$globals.AbstractCodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "source\x0a\x09^ source ifNil: [ '' ]",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["ifNil:"]
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.AbstractCodeGenerator);
- $core.addClass('CodeGenerator', $globals.AbstractCodeGenerator, [], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $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.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- var ir,stream;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$3,$1;
- $recv(self._semanticAnalyzer())._visit_(aNode);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx["visit:"]=1;
- //>>excludeEnd("ctx");
- ir=$recv(self._translator())._visit_(aNode);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx["visit:"]=2;
- //>>excludeEnd("ctx");
- $2=self._irTranslator();
- $recv($2)._currentClass_(self._currentClass());
- $recv($2)._visit_(ir);
- $3=$recv($2)._contents();
- $1=$3;
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},$globals.CodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- 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",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visit:", "semanticAnalyzer", "translator", "currentClass:", "irTranslator", "currentClass", "contents"]
- }),
- $globals.CodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "irTranslator",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $IRJSTranslator(){return $globals.IRJSTranslator||(typeof IRJSTranslator=="undefined"?nil:IRJSTranslator)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv($IRJSTranslator())._new();
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},$globals.CodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "irTranslator\x0a\x09^ IRJSTranslator new",
- referencedClasses: ["IRJSTranslator"],
- //>>excludeEnd("ide");
- messageSends: ["new"]
- }),
- $globals.CodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "semanticAnalyzer",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $SemanticAnalyzer(){return $globals.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv($SemanticAnalyzer())._on_(self._currentClass());
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"semanticAnalyzer",{},$globals.CodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "semanticAnalyzer\x0a\x09^ SemanticAnalyzer on: self currentClass",
- referencedClasses: ["SemanticAnalyzer"],
- //>>excludeEnd("ide");
- messageSends: ["on:", "currentClass"]
- }),
- $globals.CodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "translator",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $IRASTTranslator(){return $globals.IRASTTranslator||(typeof IRASTTranslator=="undefined"?nil:IRASTTranslator)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$3,$1;
- $2=$recv($IRASTTranslator())._new();
- $recv($2)._source_(self._source());
- $recv($2)._theClass_(self._currentClass());
- $3=$recv($2)._yourself();
- $1=$3;
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"translator",{},$globals.CodeGenerator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "translator\x0a\x09^ IRASTTranslator new\x0a\x09\x09source: self source;\x0a\x09\x09theClass: self currentClass;\x0a\x09\x09yourself",
- referencedClasses: ["IRASTTranslator"],
- //>>excludeEnd("ide");
- messageSends: ["source:", "new", "source", "theClass:", "currentClass", "yourself"]
- }),
- $globals.CodeGenerator);
- $core.addClass('Compiler', $globals.Object, ['currentClass', 'source', 'unknownVariables', 'codeGeneratorClass'], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $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`";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "codeGeneratorClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- function $InliningCodeGenerator(){return $globals.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$1,$receiver;
- $2=self["@codeGeneratorClass"];
- if(($receiver = $2) == null || $receiver.isNil){
- $1=$InliningCodeGenerator();
- } else {
- $1=$2;
- };
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "codeGeneratorClass\x0a\x09^ codeGeneratorClass ifNil: [ InliningCodeGenerator ]",
- referencedClasses: ["InliningCodeGenerator"],
- //>>excludeEnd("ide");
- messageSends: ["ifNil:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "codeGeneratorClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@codeGeneratorClass"]=aClass;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aClass"],
- source: "codeGeneratorClass: aClass\x0a\x09codeGeneratorClass := aClass",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "compile:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._compileNode_(self._parse_(aString));
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compile:",{aString:aString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "compile: aString\x0a\x09^ self compileNode: (self parse: aString)",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["compileNode:", "parse:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "compile:forClass:",
- protocol: 'compiling',
- fn: function (aString,aClass){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- self._currentClass_(aClass);
- self._source_(aString);
- $1=self._compile_(aString);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compile:forClass:",{aString:aString,aClass:aClass},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "aClass"],
- source: "compile: aString forClass: aClass\x0a\x09self currentClass: aClass.\x0a\x09self source: aString.\x0a\x09^ self compile: aString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["currentClass:", "source:", "compile:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "compileExpression:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $DoIt(){return $globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1,$2;
- self._currentClass_($DoIt());
- $1=$recv("doIt ^ [ ".__comma(aString)).__comma(" ] value");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx[","]=1;
- //>>excludeEnd("ctx");
- self._source_($1);
- $2=self._compileNode_(self._parse_(self._source()));
- return $2;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compileExpression:",{aString:aString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "compileExpression: aString\x0a\x09self currentClass: DoIt.\x0a\x09self source: 'doIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
- referencedClasses: ["DoIt"],
- //>>excludeEnd("ide");
- messageSends: ["currentClass:", "source:", ",", "compileNode:", "parse:", "source"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "compileExpression:on:",
- protocol: 'compiling',
- fn: function (aString,anObject){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1,$2;
- self._currentClass_($recv(anObject)._class());
- $1=$recv("xxxDoIt ^ [ ".__comma(aString)).__comma(" ] value");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx[","]=1;
- //>>excludeEnd("ctx");
- self._source_($1);
- $2=self._compileNode_(self._parse_(self._source()));
- return $2;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compileExpression:on:",{aString:aString,anObject:anObject},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "anObject"],
- source: "compileExpression: aString on: anObject\x0a\x09self currentClass: anObject class.\x0a\x09self source: 'xxxDoIt ^ [ ', aString, ' ] value'.\x0a\x09^ self compileNode: (self parse: self source)",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["currentClass:", "class", "source:", ",", "compileNode:", "parse:", "source"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "compileNode:",
- protocol: 'compiling',
- fn: function (aNode){
- var self=this;
- var generator,result;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1,$2,$3;
- generator=$recv(self._codeGeneratorClass())._new();
- $1=generator;
- $recv($1)._source_(self._source());
- $2=$recv($1)._currentClass_(self._currentClass());
- result=$recv(generator)._compileNode_(aNode);
- self._unknownVariables_([]);
- $3=result;
- return $3;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,generator:generator,result:result},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- 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",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "compileNode:", "unknownVariables:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "currentClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@currentClass"];
- return $1;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "currentClass\x0a\x09^ currentClass",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "currentClass:",
- protocol: 'accessing',
- fn: function (aClass){
- var self=this;
- self["@currentClass"]=aClass;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aClass"],
- source: "currentClass: aClass\x0a\x09currentClass := aClass",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "eval:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return eval(aString);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "eval: aString\x0a\x09<return eval(aString)>",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "evaluateExpression:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $DoIt(){return $globals.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._evaluateExpression_on_(aString,$recv($DoIt())._new());
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:",{aString:aString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- 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",
- referencedClasses: ["DoIt"],
- //>>excludeEnd("ide");
- messageSends: ["evaluateExpression:on:", "new"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "evaluateExpression:on:",
- protocol: 'compiling',
- fn: function (aString,anObject){
- var self=this;
- var result,method;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1,$2;
- method=self._eval_(self._compileExpression_on_(aString,anObject));
- $recv(method)._protocol_("**xxxDoIt");
- $1=$recv(anObject)._class();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx["class"]=1;
- //>>excludeEnd("ctx");
- $recv($1)._addCompiledMethod_(method);
- result=$recv(anObject)._xxxDoIt();
- $recv($recv(anObject)._class())._removeCompiledMethod_(method);
- $2=result;
- return $2;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"evaluateExpression:on:",{aString:aString,anObject:anObject,result:result,method:method},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "anObject"],
- 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",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["eval:", "compileExpression:on:", "protocol:", "addCompiledMethod:", "class", "xxxDoIt", "removeCompiledMethod:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "install:forClass:protocol:",
- protocol: 'compiling',
- fn: function (aString,aBehavior,anotherString){
- var self=this;
- function $ClassBuilder(){return $globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv($recv($ClassBuilder())._new())._installMethod_forClass_protocol_(self._eval_(self._compile_forClass_(aString,aBehavior)),aBehavior,anotherString);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"install:forClass:protocol:",{aString:aString,aBehavior:aBehavior,anotherString:anotherString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "aBehavior", "anotherString"],
- 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",
- referencedClasses: ["ClassBuilder"],
- //>>excludeEnd("ide");
- messageSends: ["installMethod:forClass:protocol:", "new", "eval:", "compile:forClass:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "parse:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv($Smalltalk())._parse_(aString);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "parse: aString\x0a\x09^ Smalltalk parse: aString",
- referencedClasses: ["Smalltalk"],
- //>>excludeEnd("ide");
- messageSends: ["parse:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "parseExpression:",
- protocol: 'compiling',
- fn: function (aString){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$1;
- $2=$recv("doIt ^ [ ".__comma(aString)).__comma(" ] value");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx[","]=1;
- //>>excludeEnd("ctx");
- $1=self._parse_($2);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"parseExpression:",{aString:aString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "parseExpression: aString\x0a\x09^ self parse: 'doIt ^ [ ', aString, ' ] value'",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["parse:", ","]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "recompile:",
- protocol: 'compiling',
- fn: function (aClass){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $recv($recv($recv(aClass)._methodDictionary())._values())._do_displayingProgress_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return self._install_forClass_protocol_($recv(each)._source(),aClass,$recv(each)._protocol());
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- }),"Recompiling ".__comma($recv(aClass)._name()));
- $1=$recv(aClass)._isMetaclass();
- if(!$core.assert($1)){
- self._recompile_($recv(aClass)._class());
- };
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aClass"],
- 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 ]",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["do:displayingProgress:", "values", "methodDictionary", "install:forClass:protocol:", "source", "protocol", ",", "name", "ifFalse:", "isMetaclass", "recompile:", "class"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "recompileAll",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $recv($recv($Smalltalk())._classes())._do_displayingProgress_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return self._recompile_(each);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- }),"Compiling all classes...");
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"recompileAll",{},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "recompileAll\x0a\x09Smalltalk classes \x0a\x09\x09do: [ :each | self recompile: each ]\x0a\x09\x09displayingProgress: 'Compiling all classes...'",
- referencedClasses: ["Smalltalk"],
- //>>excludeEnd("ide");
- messageSends: ["do:displayingProgress:", "classes", "recompile:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "source",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$1,$receiver;
- $2=self["@source"];
- if(($receiver = $2) == null || $receiver.isNil){
- $1="";
- } else {
- $1=$2;
- };
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"source",{},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "source\x0a\x09^ source ifNil: [ '' ]",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["ifNil:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "source:",
- protocol: 'accessing',
- fn: function (aString){
- var self=this;
- self["@source"]=aString;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "source: aString\x0a\x09source := aString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "unknownVariables",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var $1;
- $1=self["@unknownVariables"];
- return $1;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "unknownVariables\x0a\x09^ unknownVariables",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "unknownVariables:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@unknownVariables"]=aCollection;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aCollection"],
- source: "unknownVariables: aCollection\x0a\x09unknownVariables := aCollection",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "recompile:",
- protocol: 'compiling',
- fn: function (aClass){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $recv(self._new())._recompile_(aClass);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"recompile:",{aClass:aClass},$globals.Compiler.klass)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aClass"],
- source: "recompile: aClass\x0a\x09self new recompile: aClass",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["recompile:", "new"]
- }),
- $globals.Compiler.klass);
- $core.addMethod(
- $core.method({
- selector: "recompileAll",
- protocol: 'compiling',
- fn: function (){
- var self=this;
- function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $recv($recv($Smalltalk())._classes())._do_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return self._recompile_(each);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- }));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"recompileAll",{},$globals.Compiler.klass)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "recompileAll\x0a\x09Smalltalk classes do: [ :each |\x0a\x09\x09self recompile: each ]",
- referencedClasses: ["Smalltalk"],
- //>>excludeEnd("ide");
- messageSends: ["do:", "classes", "recompile:"]
- }),
- $globals.Compiler.klass);
- $core.addClass('DoIt', $globals.Object, [], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.DoIt.comment="`DoIt` is the class used to compile and evaluate expressions. See `Compiler >> evaluateExpression:`.";
- //>>excludeEnd("ide");
- $core.addClass('Evaluator', $globals.InterfacingObject, [], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.Evaluator.comment="I evaluate code against a receiver, dispatching #evaluate:on: to the receiver.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "evaluate:context:",
- protocol: 'evaluating',
- fn: function (aString,aContext){
- var self=this;
- var compiler,ast;
- function $Compiler(){return $globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
- function $AISemanticAnalyzer(){return $globals.AISemanticAnalyzer||(typeof AISemanticAnalyzer=="undefined"?nil:AISemanticAnalyzer)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1,$2,$3,$4;
- var $early={};
- try {
- compiler=$recv($Compiler())._new();
- $recv((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- ast=$recv(compiler)._parseExpression_(aString);
- return ast;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }))._on_do_($Error(),(function(ex){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $1=self._alert_($recv(ex)._messageText());
- throw $early=[$1];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
- //>>excludeEnd("ctx");
- }));
- $2=$recv($AISemanticAnalyzer())._on_($recv($recv(aContext)._receiver())._class());
- $recv($2)._context_(aContext);
- $3=$recv($2)._visit_(ast);
- $4=$recv(aContext)._evaluateNode_(ast);
- return $4;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"evaluate:context:",{aString:aString,aContext:aContext,compiler:compiler,ast:ast},$globals.Evaluator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "aContext"],
- 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",
- referencedClasses: ["Compiler", "Error", "AISemanticAnalyzer"],
- //>>excludeEnd("ide");
- messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "context:", "on:", "class", "receiver", "visit:", "evaluateNode:"]
- }),
- $globals.Evaluator);
- $core.addMethod(
- $core.method({
- selector: "evaluate:for:",
- protocol: 'evaluating',
- fn: function (aString,anObject){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv(anObject)._evaluate_on_(aString,self);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},$globals.Evaluator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "anObject"],
- source: "evaluate: aString for: anObject\x0a\x09^ anObject evaluate: aString on: self",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["evaluate:on:"]
- }),
- $globals.Evaluator);
- $core.addMethod(
- $core.method({
- selector: "evaluate:receiver:",
- protocol: 'evaluating',
- fn: function (aString,anObject){
- var self=this;
- var compiler;
- function $Compiler(){return $globals.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1,$2;
- var $early={};
- try {
- compiler=$recv($Compiler())._new();
- $recv((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $recv(compiler)._parseExpression_(aString);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }))._on_do_($Error(),(function(ex){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $1=self._alert_($recv(ex)._messageText());
- throw $early=[$1];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
- //>>excludeEnd("ctx");
- }));
- $2=$recv(compiler)._evaluateExpression_on_(aString,anObject);
- return $2;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"evaluate:receiver:",{aString:aString,anObject:anObject,compiler:compiler},$globals.Evaluator)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "anObject"],
- 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",
- referencedClasses: ["Compiler", "Error"],
- //>>excludeEnd("ide");
- messageSends: ["new", "on:do:", "parseExpression:", "alert:", "messageText", "evaluateExpression:on:"]
- }),
- $globals.Evaluator);
- $core.addMethod(
- $core.method({
- selector: "evaluate:for:",
- protocol: 'instance creation',
- fn: function (aString,anObject){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv(self._new())._evaluate_for_(aString,anObject);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"evaluate:for:",{aString:aString,anObject:anObject},$globals.Evaluator.klass)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "anObject"],
- source: "evaluate: aString for: anObject\x0a\x09^ self new evaluate: aString for: anObject",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["evaluate:for:", "new"]
- }),
- $globals.Evaluator.klass);
- $core.addClass('NodeVisitor', $globals.Object, [], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.NodeVisitor.comment="I am the abstract super class of all AST node visitors.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "visit:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv(aNode)._accept_(self);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visit: aNode\x0a\x09^ aNode accept: self",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["accept:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitAll:",
- protocol: 'visiting',
- fn: function (aCollection){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$recv(aCollection)._collect_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return self._visit_(each);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- }));
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitAll:",{aCollection:aCollection},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aCollection"],
- source: "visitAll: aCollection\x0a\x09^ aCollection collect: [ :each | self visit: each ]",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["collect:", "visit:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitAssignmentNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitBlockNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitBlockSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitSequenceNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitBlockSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitBlockSequenceNode: aNode\x0a\x09^ self visitSequenceNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitSequenceNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitCascadeNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitCascadeNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitDynamicArrayNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitDynamicArrayNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitDynamicDictionaryNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitDynamicDictionaryNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitJSStatementNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitMethodNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitMethodNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitAll_($recv(aNode)._nodes());
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitNode: aNode\x0a\x09^ self visitAll: aNode nodes",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitAll:", "nodes"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitReturnNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitSendNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitSequenceNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitSequenceNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitValueNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitValueNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "visitVariableNode:",
- protocol: 'visiting',
- fn: function (aNode){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=self._visitNode_(aNode);
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},$globals.NodeVisitor)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09^ self visitNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["visitNode:"]
- }),
- $globals.NodeVisitor);
- $core.addMethod(
- $core.method({
- selector: "asVariableName",
- protocol: '*Compiler-Core',
- fn: function (){
- var self=this;
- function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $2,$1;
- $2=$recv($recv($Smalltalk())._reservedWords())._includes_(self);
- if($core.assert($2)){
- $1=self.__comma("_");
- } else {
- $1=self;
- };
- return $1;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"asVariableName",{},$globals.String)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "asVariableName\x0a\x09^ (Smalltalk reservedWords includes: self)\x0a\x09\x09ifTrue: [ self, '_' ]\x0a\x09\x09ifFalse: [ self ]",
- referencedClasses: ["Smalltalk"],
- //>>excludeEnd("ide");
- messageSends: ["ifTrue:ifFalse:", "includes:", "reservedWords", ","]
- }),
- $globals.String);
- });
|