1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174 |
- define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Exceptions", "amber_core/Platform-Services", "amber_core/Kernel-Collections"], function($boot){"use strict";
- var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
- $core.addPackage('Compiler-Core');
- $core.packages["Compiler-Core"].innerEval = function (expr) { return eval(expr); };
- $core.packages["Compiler-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
- $core.addClass('AbstractCodeGenerator', $globals.Object, ['currentClass', 'currentPackage', '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;
- return self["@currentClass"];
- },
- //>>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: "currentPackage",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@currentPackage"];
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "currentPackage\x0a\x09^ currentPackage",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.AbstractCodeGenerator);
- $core.addMethod(
- $core.method({
- selector: "currentPackage:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@currentPackage"]=anObject;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["anObject"],
- source: "currentPackage: anObject\x0a\x09currentPackage := anObject",
- 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");
- return $recv($Smalltalk())._pseudoVariableNames();
- //>>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 $1,$receiver;
- $1=self["@source"];
- if(($receiver = $1) == null || $receiver.isNil){
- return "";
- } else {
- 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 $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");
- $1=self._irTranslator();
- $recv($1)._currentClass_(self._currentClass());
- $recv($1)._visit_(ir);
- return $recv($1)._contents();
- //>>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");
- return $recv($IRJSTranslator())._new();
- //>>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());
- $recv($1)._thePackage_(self._currentPackage());
- return $recv($1)._yourself();
- //>>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)\x0a\x09\x09thePackage: self currentPackage;\x0a\x09\x09yourself",
- referencedClasses: ["SemanticAnalyzer"],
- //>>excludeEnd("ide");
- messageSends: ["thePackage:", "on:", "currentClass", "currentPackage", "yourself"]
- }),
- $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 $1;
- $1=$recv($IRASTTranslator())._new();
- $recv($1)._source_(self._source());
- $recv($1)._theClass_(self._currentClass());
- return $recv($1)._yourself();
- //>>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', 'currentPackage', '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 $1,$receiver;
- $1=self["@codeGeneratorClass"];
- if(($receiver = $1) == null || $receiver.isNil){
- return $InliningCodeGenerator();
- } else {
- 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:forClass:protocol:",
- protocol: 'compiling',
- fn: function (aString,aClass,anotherString){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- self._source_(aString);
- return self._compileNode_forClass_package_(self._parse_(aString),aClass,$recv(aClass)._packageOfProtocol_(anotherString));
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compile:forClass:protocol:",{aString:aString,aClass:aClass,anotherString:anotherString},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "aClass", "anotherString"],
- source: "compile: aString forClass: aClass protocol: anotherString\x0a\x09^ self\x0a\x09\x09source: aString;\x0a\x09\x09compileNode: (self parse: aString)\x0a\x09\x09forClass: aClass\x0a\x09\x09package: (aClass packageOfProtocol: anotherString)",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["source:", "compileNode:forClass:package:", "parse:", "packageOfProtocol:"]
- }),
- $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;
- $1=$recv("xxxDoIt ^ [ ".__comma(aString)).__comma(" ] value");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx[","]=1;
- //>>excludeEnd("ctx");
- return self._compile_forClass_protocol_($1,$recv(anObject)._class(),"**xxxDoIt");
- //>>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\x09^ self\x0a\x09\x09compile: 'xxxDoIt ^ [ ', aString, ' ] value'\x0a\x09\x09forClass: anObject class\x0a\x09\x09protocol: '**xxxDoIt'",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["compile:forClass:protocol:", ",", "class"]
- }),
- $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;
- generator=$recv(self._codeGeneratorClass())._new();
- $1=generator;
- $recv($1)._source_(self._source());
- $recv($1)._currentClass_(self._currentClass());
- $recv($1)._currentPackage_(self._currentPackage());
- result=$recv(generator)._compileNode_(aNode);
- self._unknownVariables_([]);
- return result;
- //>>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\x09\x09currentPackage: self currentPackage.\x0a\x09result := generator compileNode: aNode.\x0a\x09self unknownVariables: #().\x0a\x09^ result",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "currentPackage:", "currentPackage", "compileNode:", "unknownVariables:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "compileNode:forClass:package:",
- protocol: 'compiling',
- fn: function (aNode,aClass,aPackage){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- self._currentClass_(aClass);
- self._currentPackage_(aPackage);
- return self._compileNode_(aNode);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"compileNode:forClass:package:",{aNode:aNode,aClass:aClass,aPackage:aPackage},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aNode", "aClass", "aPackage"],
- source: "compileNode: aNode forClass: aClass package: aPackage\x0a\x09^ self\x0a\x09\x09currentClass: aClass;\x0a\x09\x09currentPackage: aPackage;\x0a\x09\x09compileNode: aNode",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["currentClass:", "currentPackage:", "compileNode:"]
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "currentClass",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@currentClass"];
- },
- //>>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: "currentPackage",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@currentPackage"];
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "currentPackage\x0a\x09^ currentPackage",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Compiler);
- $core.addMethod(
- $core.method({
- selector: "currentPackage:",
- protocol: 'accessing',
- fn: function (anObject){
- var self=this;
- self["@currentPackage"]=anObject;
- return self;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["anObject"],
- source: "currentPackage: anObject\x0a\x09currentPackage := anObject",
- 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: "eval:forPackage:",
- protocol: 'compiling',
- fn: function (aString,aPackage){
- var self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return aPackage && aPackage.innerEval
- ? aPackage.innerEval(aString)
- : eval(aString);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"eval:forPackage:",{aString:aString,aPackage:aPackage},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "aPackage"],
- source: "eval: aString forPackage: aPackage\x0a\x09<return aPackage && aPackage.innerEval\x0a\x09\x09? aPackage.innerEval(aString)\x0a\x09\x09: 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");
- return self._evaluateExpression_on_(aString,$recv($DoIt())._new());
- //>>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;
- 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);
- return result;
- //>>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;
- var compiledMethod;
- function $ClassBuilder(){return $globals.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- compiledMethod=self._eval_forPackage_(self._compile_forClass_protocol_(aString,aBehavior,anotherString),$recv(aBehavior)._packageOfProtocol_(anotherString));
- return $recv($recv($ClassBuilder())._new())._installMethod_forClass_protocol_(compiledMethod,aBehavior,anotherString);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"install:forClass:protocol:",{aString:aString,aBehavior:aBehavior,anotherString:anotherString,compiledMethod:compiledMethod},$globals.Compiler)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "aBehavior", "anotherString"],
- 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",
- referencedClasses: ["ClassBuilder"],
- //>>excludeEnd("ide");
- messageSends: ["eval:forPackage:", "compile:forClass:protocol:", "packageOfProtocol:", "installMethod:forClass:protocol:", "new"]
- }),
- $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");
- return $recv($Smalltalk())._parse_(aString);
- //>>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 $1;
- $1=$recv("doIt ^ [ ".__comma(aString)).__comma(" ] value");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- $ctx1.sendIdx[","]=1;
- //>>excludeEnd("ctx");
- return self._parse_($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 $1,$receiver;
- $1=self["@source"];
- if(($receiver = $1) == null || $receiver.isNil){
- return "";
- } else {
- 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;
- return self["@unknownVariables"];
- },
- //>>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('CompilerError', $globals.Error, [], 'Compiler-Core');
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.CompilerError.comment="I am the common superclass of all compiling errors.";
- //>>excludeEnd("ide");
- $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;
- 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");
- throw $early=[self._alert_($recv(ex)._messageText())];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
- //>>excludeEnd("ctx");
- }));
- $1=$recv($AISemanticAnalyzer())._on_($recv($recv(aContext)._receiver())._class());
- $recv($1)._context_(aContext);
- $recv($1)._visit_(ast);
- return $recv(aContext)._evaluateNode_(ast);
- }
- 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");
- return $recv(anObject)._evaluate_on_(aString,self);
- //>>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 $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");
- throw $early=[self._alert_($recv(ex)._messageText())];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)});
- //>>excludeEnd("ctx");
- }));
- return $recv(compiler)._evaluateExpression_on_(aString,anObject);
- }
- 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");
- return $recv(self._new())._evaluate_for_(aString,anObject);
- //>>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.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 $1;
- $1=$recv($recv($Smalltalk())._reservedWords())._includes_(self);
- if($core.assert($1)){
- return self.__comma("_");
- } else {
- return self;
- };
- //>>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);
- });
|