1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356 |
- define("amber_core/Compiler-Interpreter", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Methods", "amber_core/Kernel-Objects", "amber_core/Compiler-Core", "amber_core/Kernel-Exceptions", "amber_core/Compiler-AST"], function(smalltalk,nil,_st){
- smalltalk.addPackage('Compiler-Interpreter');
- smalltalk.packages["Compiler-Interpreter"].transport = {"type":"amd","amdNamespace":"amber_core"};
- smalltalk.addClass('AIBlockClosure', smalltalk.BlockClosure, ['node', 'outerContext'], 'Compiler-Interpreter');
- smalltalk.AIBlockClosure.comment="I am a special `BlockClosure` subclass used by an interpreter to interpret a block node.\x0a\x0aWhile I am polymorphic with `BlockClosure`, some methods such as `#new` will raise interpretation errors. Unlike a `BlockClosure`, my instance are not JavaScript functions.\x0a\x0aEvaluating an instance will result in interpreting the `node` instance variable (instance of `BlockNode`).";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "applyTo:arguments:",
- category: 'evaluating',
- fn: function (anObject,aCollection){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._interpreterError();
- return self}, function($ctx1) {$ctx1.fill(self,"applyTo:arguments:",{anObject:anObject,aCollection:aCollection},smalltalk.AIBlockClosure)})},
- args: ["anObject", "aCollection"],
- source: "applyTo: anObject arguments: aCollection\x0a\x09self interpreterError",
- messageSends: ["interpreterError"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "compiledSource",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return "[ AST Block closure ]";
- }, function($ctx1) {$ctx1.fill(self,"compiledSource",{},smalltalk.AIBlockClosure)})},
- args: [],
- source: "compiledSource\x0a\x09\x22Unlike blocks, the receiver doesn't represent a JS function\x22\x0a\x09\x0a\x09^ '[ AST Block closure ]'",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currySelf",
- category: 'converting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._interpreterError();
- return self}, function($ctx1) {$ctx1.fill(self,"currySelf",{},smalltalk.AIBlockClosure)})},
- args: [],
- source: "currySelf\x0a\x09self interpreterError",
- messageSends: ["interpreterError"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeWithContext:node:",
- category: 'initialization',
- fn: function (aContext,aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@node"]=aNode;
- self["@outerContext"]=aContext;
- return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure)})},
- args: ["aContext", "aNode"],
- source: "initializeWithContext: aContext node: aNode\x0a\x09node := aNode.\x0a\x09outerContext := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreterError",
- category: 'error handling',
- fn: function (){
- var self=this;
- function $ASTInterpreterError(){return smalltalk.ASTInterpreterError||(typeof ASTInterpreterError=="undefined"?nil:ASTInterpreterError)}
- return smalltalk.withContext(function($ctx1) {
- _st($ASTInterpreterError())._signal_("Method cannot be interpreted by the interpreter.");
- return self}, function($ctx1) {$ctx1.fill(self,"interpreterError",{},smalltalk.AIBlockClosure)})},
- args: [],
- source: "interpreterError\x0a\x09ASTInterpreterError signal: 'Method cannot be interpreted by the interpreter.'",
- messageSends: ["signal:"],
- referencedClasses: ["ASTInterpreterError"]
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "numArgs",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self["@node"])._temps())._size();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"numArgs",{},smalltalk.AIBlockClosure)})},
- args: [],
- source: "numArgs\x0a\x09^ node temps size",
- messageSends: ["size", "temps"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value",
- category: 'evaluating',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.AIBlockClosure)})},
- args: [],
- source: "value\x0a\x09^ self valueWithPossibleArguments: #()",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:",
- category: 'evaluating',
- fn: function (anArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([anArgument]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:",{anArgument:anArgument},smalltalk.AIBlockClosure)})},
- args: ["anArgument"],
- source: "value: anArgument\x0a\x09^ self valueWithPossibleArguments: {anArgument}",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:",
- category: 'evaluating',
- fn: function (firstArgument,secondArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([firstArgument,secondArgument]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:",{firstArgument:firstArgument,secondArgument:secondArgument},smalltalk.AIBlockClosure)})},
- args: ["firstArgument", "secondArgument"],
- source: "value: firstArgument value: secondArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument}",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "value:value:value:",
- category: 'evaluating',
- fn: function (firstArgument,secondArgument,thirdArgument){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._valueWithPossibleArguments_([firstArgument,secondArgument,thirdArgument]);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"value:value:value:",{firstArgument:firstArgument,secondArgument:secondArgument,thirdArgument:thirdArgument},smalltalk.AIBlockClosure)})},
- args: ["firstArgument", "secondArgument", "thirdArgument"],
- source: "value: firstArgument value: secondArgument value: thirdArgument\x0a\x09^ self valueWithPossibleArguments: {firstArgument . secondArgument . thirdArgument}",
- messageSends: ["valueWithPossibleArguments:"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "valueWithPossibleArguments:",
- category: 'evaluating',
- fn: function (aCollection){
- var self=this;
- var context,sequenceNode;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5;
- context=_st(self["@outerContext"])._newBlockContext();
- $1=_st(_st(_st(self["@node"])._nodes())._first())._copy();
- _st($1)._parent_(nil);
- $2=_st($1)._yourself();
- sequenceNode=$2;
- _st(_st(self["@node"])._parameters())._withIndexDo_((function(each,index){
- return smalltalk.withContext(function($ctx2) {
- return _st(context)._localAt_put_(each,_st(aCollection)._at_ifAbsent_(index,(function(){
- return smalltalk.withContext(function($ctx3) {
- return nil;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})));
- }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
- $3=_st(context)._interpreter();
- _st($3)._node_(_st(sequenceNode)._nextChild());
- $4=_st($3)._proceed();
- _st(_st(self["@outerContext"])._interpreter())._setNonLocalReturnFromContext_(context);
- $5=_st(_st(context)._interpreter())._pop();
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"valueWithPossibleArguments:",{aCollection:aCollection,context:context,sequenceNode:sequenceNode},smalltalk.AIBlockClosure)})},
- args: ["aCollection"],
- source: "valueWithPossibleArguments: aCollection\x0a\x09| context sequenceNode |\x0a\x09context := outerContext newBlockContext.\x0a\x0a\x09\x22Interpret a copy of the sequence node to avoid creating a new AIBlockClosure\x22\x0a\x09sequenceNode := node nodes first copy\x0a\x09\x09parent: nil;\x0a\x09\x09yourself.\x0a\x0a\x09\x22Populate the arguments into the context locals\x22\x09\x0a\x09node parameters withIndexDo: [ :each :index |\x0a\x09\x09context localAt: each put: (aCollection at: index ifAbsent: [ nil ]) ].\x0a\x0a\x09\x22Interpret the first node of the BlockSequenceNode\x22\x0a\x09context interpreter\x0a\x09\x09node: sequenceNode nextChild;\x0a\x09\x09proceed.\x0a\x09\x09\x0a\x09outerContext interpreter\x0a\x09\x09setNonLocalReturnFromContext: context.\x0a\x09\x09\x0a\x09^ context interpreter pop",
- messageSends: ["newBlockContext", "parent:", "copy", "first", "nodes", "yourself", "withIndexDo:", "parameters", "localAt:put:", "at:ifAbsent:", "node:", "interpreter", "nextChild", "proceed", "setNonLocalReturnFromContext:", "pop"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "forContext:node:",
- category: 'instance creation',
- fn: function (aContext,aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._initializeWithContext_node_(aContext,aNode);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"forContext:node:",{aContext:aContext,aNode:aNode},smalltalk.AIBlockClosure.klass)})},
- args: ["aContext", "aNode"],
- source: "forContext: aContext node: aNode\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext node: aNode;\x0a\x09\x09yourself",
- messageSends: ["initializeWithContext:node:", "new", "yourself"],
- referencedClasses: []
- }),
- smalltalk.AIBlockClosure.klass);
- smalltalk.addClass('AIContext', smalltalk.MethodContext, ['outerContext', 'innerContext', 'pc', 'locals', 'selector', 'index', 'ast', 'interpreter'], 'Compiler-Interpreter');
- smalltalk.AIContext.comment="I am like a `MethodContext`, used by the `ASTInterpreter`.\x0aUnlike a `MethodContext`, my instances are not read-only.\x0a\x0aWhen debugging, my instances are created by copying the current `MethodContext` (thisContext)";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "arguments",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(self._ast())._arguments())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._localAt_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"arguments",{},smalltalk.AIContext)})},
- args: [],
- source: "arguments\x0a\x09^ self ast arguments collect: [ :each |\x0a\x09\x09self localAt: each ]",
- messageSends: ["collect:", "arguments", "ast", "localAt:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "ast",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$3,$2,$4,$5;
- $1=self._isBlockContext();
- if(smalltalk.assert($1)){
- $3=self._outerContext();
- if(($receiver = $3) == nil || $receiver == null){
- $2=$3;
- } else {
- var context;
- context=$receiver;
- $2=_st(context)._ast();
- };
- return $2;
- };
- $4=self["@ast"];
- if(($receiver = $4) == nil || $receiver == null){
- self._initializeAST();
- } else {
- $4;
- };
- $5=self["@ast"];
- return $5;
- }, function($ctx1) {$ctx1.fill(self,"ast",{},smalltalk.AIContext)})},
- args: [],
- source: "ast\x0a\x09self isBlockContext ifTrue: [ \x0a\x09\x09^ self outerContext ifNotNil: [ :context | context ast ] ].\x0a\x0a\x09ast ifNil: [ self initializeAST ].\x0a\x09^ ast",
- messageSends: ["ifTrue:", "isBlockContext", "ifNotNil:", "outerContext", "ast", "ifNil:", "initializeAST"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@index"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=(0);
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"index",{},smalltalk.AIContext)})},
- args: [],
- source: "index\x0a\x09^ index ifNil: [ 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "index:",
- category: 'accessing',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@index"]=anInteger;
- return self}, function($ctx1) {$ctx1.fill(self,"index:",{anInteger:anInteger},smalltalk.AIContext)})},
- args: ["anInteger"],
- source: "index: anInteger\x0a\x09index := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeAST",
- category: 'initialization',
- fn: function (){
- var self=this;
- function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
- return smalltalk.withContext(function($ctx1) {
- self["@ast"]=_st(self._method())._ast();
- _st(_st($SemanticAnalyzer())._on_(_st(self._method())._methodClass()))._visit_(self["@ast"]);
- return self}, function($ctx1) {$ctx1.fill(self,"initializeAST",{},smalltalk.AIContext)})},
- args: [],
- source: "initializeAST\x0a\x09ast := self method ast.\x0a\x09(SemanticAnalyzer on: self method methodClass)\x0a\x09\x09visit: ast",
- messageSends: ["ast", "method", "visit:", "on:", "methodClass"],
- referencedClasses: ["SemanticAnalyzer"]
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeFromMethodContext:",
- category: 'initialization',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4;
- $1=self;
- _st($1)._pc_(_st(aMethodContext)._pc());
- _st($1)._index_(_st(aMethodContext)._index());
- _st($1)._receiver_(_st(aMethodContext)._receiver());
- $2=_st($1)._selector_(_st(aMethodContext)._selector());
- $3=_st(aMethodContext)._outerContext();
- if(($receiver = $3) == nil || $receiver == null){
- $3;
- } else {
- var outer;
- outer=$receiver;
- $4=_st(outer)._methodContext();
- if(($receiver = $4) == nil || $receiver == null){
- $4;
- } else {
- self._outerContext_(_st(self._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
- };
- _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._locals())._at_put_(key,value);
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)})}));
- };
- return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext)})},
- args: ["aMethodContext"],
- source: "initializeFromMethodContext: aMethodContext\x0a\x0a\x09self \x0a\x09\x09pc: aMethodContext pc;\x0a\x09\x09index: aMethodContext index;\x0a\x09\x09receiver: aMethodContext receiver;\x0a\x09\x09selector: aMethodContext selector.\x0a\x09\x09\x0a\x09aMethodContext outerContext ifNotNil: [ :outer |\x0a\x09\x09\x22If the method context is nil, the block was defined in JS, so ignore it\x22\x0a\x09\x09outer methodContext ifNotNil: [\x0a\x09\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a\x09\x09\x09aMethodContext locals keysAndValuesDo: [ :key :value |\x0a\x09\x09\x09\x09self locals at: key put: value ] ]",
- messageSends: ["pc:", "pc", "index:", "index", "receiver:", "receiver", "selector:", "selector", "ifNotNil:", "outerContext", "methodContext", "outerContext:", "fromMethodContext:", "class", "keysAndValuesDo:", "locals", "at:put:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeInterpreter",
- category: 'initialization',
- fn: function (){
- var self=this;
- function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- $1=_st($ASTInterpreter())._new();
- _st($1)._context_(self);
- _st($1)._node_(self._retrieveNode());
- $2=_st($1)._yourself();
- self["@interpreter"]=$2;
- $3=_st(_st(self._innerContext())._notNil())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(self._innerContext())._isBlockContext())._not();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($3)){
- self._setupInterpreter_(self["@interpreter"]);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{},smalltalk.AIContext)})},
- args: [],
- source: "initializeInterpreter\x0a\x09interpreter := ASTInterpreter new\x0a\x09\x09context: self;\x0a\x09\x09node: self retrieveNode;\x0a\x09\x09yourself.\x0a\x09\x0a\x09(self innerContext notNil and: [ \x0a\x09\x09self innerContext isBlockContext not ]) ifTrue: [\x0a\x09\x09\x09self setupInterpreter: interpreter ]",
- messageSends: ["context:", "new", "node:", "retrieveNode", "yourself", "ifTrue:", "and:", "notNil", "innerContext", "not", "isBlockContext", "setupInterpreter:"],
- referencedClasses: ["ASTInterpreter"]
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeLocals",
- category: 'initialization',
- fn: function (){
- var self=this;
- function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
- return smalltalk.withContext(function($ctx1) {
- self["@locals"]=_st($Dictionary())._new();
- _st(self["@locals"])._at_put_("thisContext",self);
- return self}, function($ctx1) {$ctx1.fill(self,"initializeLocals",{},smalltalk.AIContext)})},
- args: [],
- source: "initializeLocals\x0a\x09locals := Dictionary new.\x0a\x09locals at: 'thisContext' put: self.",
- messageSends: ["new", "at:put:"],
- referencedClasses: ["Dictionary"]
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "innerContext",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@innerContext"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"innerContext",{},smalltalk.AIContext)})},
- args: [],
- source: "innerContext\x0a\x09^ innerContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "innerContext:",
- category: 'accessing',
- fn: function (anAIContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@innerContext"]=anAIContext;
- return self}, function($ctx1) {$ctx1.fill(self,"innerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
- args: ["anAIContext"],
- source: "innerContext: anAIContext\x0a\x09innerContext := anAIContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@interpreter"];
- if(($receiver = $1) == nil || $receiver == null){
- self._initializeInterpreter();
- } else {
- $1;
- };
- $2=self["@interpreter"];
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AIContext)})},
- args: [],
- source: "interpreter\x0a\x09interpreter ifNil: [ self initializeInterpreter ].\x0a\x09^ interpreter",
- messageSends: ["ifNil:", "initializeInterpreter"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter:",
- category: 'interpreting',
- fn: function (anInterpreter){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@interpreter"]=anInterpreter;
- return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
- args: ["anInterpreter"],
- source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localAt:",
- category: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._outerContext();
- if(($receiver = $2) == nil || $receiver == null){
- return $2;
- } else {
- var context;
- context=$receiver;
- return _st(context)._localAt_(aString);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString},smalltalk.AIContext)})},
- args: ["aString"],
- source: "localAt: aString\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self outerContext ifNotNil: [ :context | \x0a\x09\x09\x09context localAt: aString ] ]",
- messageSends: ["at:ifAbsent:", "locals", "ifNotNil:", "outerContext", "localAt:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localAt:ifAbsent:",
- category: 'accessing',
- fn: function (aString,aBlock){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $1=_st(self._locals())._at_ifAbsent_(aString,(function(){
- return smalltalk.withContext(function($ctx2) {
- $2=self._outerContext();
- if(($receiver = $2) == nil || $receiver == null){
- return _st(aBlock)._value();
- } else {
- var context;
- context=$receiver;
- return _st(context)._localAt_ifAbsent_(aString,aBlock);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"localAt:ifAbsent:",{aString:aString,aBlock:aBlock},smalltalk.AIContext)})},
- args: ["aString", "aBlock"],
- source: "localAt: aString ifAbsent: aBlock\x0a\x09\x22Lookup the local value up to the method context\x22\x0a\x0a\x09^ self locals at: aString ifAbsent: [ \x0a\x09\x09self outerContext \x0a\x09\x09\x09ifNotNil: [ :context | context localAt: aString ifAbsent: aBlock ]\x0a\x09\x09\x09ifNil: [aBlock value] ]",
- messageSends: ["at:ifAbsent:", "locals", "ifNotNil:ifNil:", "outerContext", "localAt:ifAbsent:", "value"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "localAt:put:",
- category: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._locals())._at_put_(aString,anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"localAt:put:",{aString:aString,anObject:anObject},smalltalk.AIContext)})},
- args: ["aString", "anObject"],
- source: "localAt: aString put: anObject\x0a\x09self locals at: aString put: anObject",
- messageSends: ["at:put:", "locals"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "locals",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self["@locals"];
- if(($receiver = $1) == nil || $receiver == null){
- self._initializeLocals();
- } else {
- $1;
- };
- $2=self["@locals"];
- return $2;
- }, function($ctx1) {$ctx1.fill(self,"locals",{},smalltalk.AIContext)})},
- args: [],
- source: "locals\x0a\x09locals ifNil: [ self initializeLocals ].\x0a\x09\x0a\x09^ locals",
- messageSends: ["ifNil:", "initializeLocals"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._methodContext();
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- $1=_st(_st(_st(self._methodContext())._receiver())._class())._lookupSelector_(_st(self._methodContext())._selector());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.AIContext)})},
- args: [],
- source: "method\x0a\x09^ self methodContext ifNotNil: [\x0a\x09\x09self methodContext receiver class lookupSelector: self methodContext selector ]",
- messageSends: ["ifNotNil:", "methodContext", "lookupSelector:", "class", "receiver", "selector"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "newBlockContext",
- category: 'factory',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st(self._class())._new();
- _st($2)._outerContext_(self);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"newBlockContext",{},smalltalk.AIContext)})},
- args: [],
- source: "newBlockContext\x0a\x09^ self class new\x0a\x09\x09outerContext: self;\x0a\x09\x09yourself",
- messageSends: ["outerContext:", "new", "class", "yourself"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerContext",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@outerContext"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"outerContext",{},smalltalk.AIContext)})},
- args: [],
- source: "outerContext\x0a\x09^ outerContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "outerContext:",
- category: 'accessing',
- fn: function (anAIContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@outerContext"]=anAIContext;
- _st(self["@outerContext"])._innerContext_(self);
- return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext},smalltalk.AIContext)})},
- args: ["anAIContext"],
- source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext.\x0a\x09outerContext innerContext: self",
- messageSends: ["innerContext:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pc",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@pc"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@pc"]=(0);
- $1=self["@pc"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.AIContext)})},
- args: [],
- source: "pc\x0a\x09^ pc ifNil: [ pc := 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pc:",
- category: 'interpreting',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@pc"]=anInteger;
- return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.AIContext)})},
- args: ["anInteger"],
- source: "pc: anInteger\x0a\x09pc := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._localAt_("self");
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AIContext)})},
- args: [],
- source: "receiver\x0a\x09^ self localAt: 'self'",
- messageSends: ["localAt:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "receiver:",
- category: 'interpreting',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._localAt_put_("self",anObject);
- return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject},smalltalk.AIContext)})},
- args: ["anObject"],
- source: "receiver: anObject\x0a\x09self localAt: 'self' put: anObject",
- messageSends: ["localAt:put:"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "retrieveNode",
- category: 'interpreting',
- fn: function (){
- var self=this;
- function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$4,$1;
- $2=self._ast();
- if(($receiver = $2) == nil || $receiver == null){
- $1=$2;
- } else {
- $3=_st($ASTPCNodeVisitor())._new();
- _st($3)._context_(self);
- _st($3)._visit_(self._ast());
- $4=_st($3)._currentNode();
- $1=$4;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"retrieveNode",{},smalltalk.AIContext)})},
- args: [],
- source: "retrieveNode\x0a\x09^ self ast ifNotNil: [\x0a\x09\x09ASTPCNodeVisitor new\x0a\x09\x09\x09context: self;\x0a\x09\x09\x09visit: self ast;\x0a\x09\x09\x09currentNode ]",
- messageSends: ["ifNotNil:", "ast", "context:", "new", "visit:", "currentNode"],
- referencedClasses: ["ASTPCNodeVisitor"]
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@selector"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.AIContext)})},
- args: [],
- source: "selector\x0a\x09^ selector",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "selector:",
- category: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@selector"]=aString;
- return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.AIContext)})},
- args: ["aString"],
- source: "selector: aString\x0a\x09selector := aString",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setupInterpreter:",
- category: 'interpreting',
- fn: function (anInterpreter){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(_st(_st(self._innerContext())._arguments())._reversed())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(anInterpreter)._push_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- _st(anInterpreter)._push_(_st(self._innerContext())._receiver());
- return self}, function($ctx1) {$ctx1.fill(self,"setupInterpreter:",{anInterpreter:anInterpreter},smalltalk.AIContext)})},
- args: ["anInterpreter"],
- source: "setupInterpreter: anInterpreter\x0a\x09\x22Push the send args and receiver to the interpreter stack\x22\x0a\x09\x0a\x09self innerContext arguments reversed do: [ :each | \x0a\x09\x09anInterpreter push: each ].\x0a\x09\x09\x0a\x09anInterpreter push: (self innerContext receiver)",
- messageSends: ["do:", "reversed", "arguments", "innerContext", "push:", "receiver"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "fromMethodContext:",
- category: 'instance creation',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._initializeFromMethodContext_(aMethodContext);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"fromMethodContext:",{aMethodContext:aMethodContext},smalltalk.AIContext.klass)})},
- args: ["aMethodContext"],
- source: "fromMethodContext: aMethodContext\x0a\x09^ self new\x0a\x09\x09initializeFromMethodContext: aMethodContext;\x0a\x09\x09yourself",
- messageSends: ["initializeFromMethodContext:", "new", "yourself"],
- referencedClasses: []
- }),
- smalltalk.AIContext.klass);
- smalltalk.addClass('ASTDebugger', smalltalk.Object, ['interpreter', 'context'], 'Compiler-Interpreter');
- smalltalk.ASTDebugger.comment="I am a stepping debugger interface for Amber code.\x0aI internally use an instance of `ASTSteppingInterpreter` to actually step through node and interpret them.\x0a\x0aMy instances are created from a `MethodContext` with `ASTDebugger class >> context:`.\x0aThey hold an `AIContext` instance internally, recursive copy of the `MethodContext`.\x0a\x0a## API\x0a\x0aUse the methods of the `'stepping'` protocol to do stepping.";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atEnd",
- category: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._interpreter())._atEnd();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "atEnd\x0a\x09^ self interpreter atEnd",
- messageSends: ["atEnd", "interpreter"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "buildAST",
- category: 'initialization',
- fn: function (){
- var self=this;
- var ast;
- function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- ast=_st(_st($Smalltalk())._current())._parse_(_st(self._method())._source());
- _st(_st($SemanticAnalyzer())._on_(_st(_st(self._context())._receiver())._class()))._visit_(ast);
- $1=ast;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"buildAST",{ast:ast},smalltalk.ASTDebugger)})},
- args: [],
- source: "buildAST\x0a\x09\x22Build the AST tree from the method source code.\x0a\x09The AST is annotated with a SemanticAnalyzer,\x0a\x09to know the semantics and bindings of each node needed for later debugging\x22\x0a\x09\x0a\x09| ast |\x0a\x09\x0a\x09ast := Smalltalk current parse: self method source.\x0a\x09(SemanticAnalyzer on: self context receiver class)\x0a\x09\x09visit: ast.\x0a\x09\x0a\x09^ ast",
- messageSends: ["parse:", "current", "source", "method", "visit:", "on:", "class", "receiver", "context"],
- referencedClasses: ["Smalltalk", "SemanticAnalyzer"]
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@context"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "context\x0a\x09^ context",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- category: 'accessing',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@context"]=aContext;
- return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger)})},
- args: ["aContext"],
- source: "context: aContext\x0a\x09context := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "defaultInterpreterClass",
- category: 'defaults',
- fn: function (){
- var self=this;
- function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=$ASTInterpreter();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"defaultInterpreterClass",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "defaultInterpreterClass\x0a\x09^ ASTInterpreter",
- messageSends: [],
- referencedClasses: ["ASTInterpreter"]
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeInterpreter",
- category: 'initialization',
- fn: function (){
- var self=this;
- var ast,next;
- function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- ast=self._buildAST();
- $1=_st($ASTPCNodeVisitor())._new();
- _st($1)._context_(self._context());
- _st($1)._visit_(ast);
- $2=_st($1)._currentNode();
- next=$2;
- _st(self._interpreter())._node_(next);
- return self}, function($ctx1) {$ctx1.fill(self,"initializeInterpreter",{ast:ast,next:next},smalltalk.ASTDebugger)})},
- args: [],
- source: "initializeInterpreter\x0a\x09| ast next |\x0a\x09ast := self buildAST.\x0a\x09next := ASTPCNodeVisitor new\x0a\x09\x09context: self context;\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode.\x0a\x09self interpreter node: next",
- messageSends: ["buildAST", "context:", "new", "context", "visit:", "currentNode", "node:", "interpreter"],
- referencedClasses: ["ASTPCNodeVisitor"]
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "initializeWithContext:",
- category: 'initialization',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._context_(aContext);
- self._initializeInterpreter();
- return self}, function($ctx1) {$ctx1.fill(self,"initializeWithContext:",{aContext:aContext},smalltalk.ASTDebugger)})},
- args: ["aContext"],
- source: "initializeWithContext: aContext\x0a\x09\x22TODO: do we need to handle block contexts?\x22\x0a\x09\x0a\x09self context: aContext.\x0a\x09self initializeInterpreter",
- messageSends: ["context:", "initializeInterpreter"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@interpreter"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@interpreter"]=_st(self._defaultInterpreterClass())._new();
- $1=self["@interpreter"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := self defaultInterpreterClass new ]",
- messageSends: ["ifNil:", "new", "defaultInterpreterClass"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpreter:",
- category: 'accessing',
- fn: function (anInterpreter){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@interpreter"]=anInterpreter;
- return self}, function($ctx1) {$ctx1.fill(self,"interpreter:",{anInterpreter:anInterpreter},smalltalk.ASTDebugger)})},
- args: ["anInterpreter"],
- source: "interpreter: anInterpreter\x0a\x09interpreter := anInterpreter",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "method",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._context())._method();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "method\x0a\x09^ self context method",
- messageSends: ["method", "context"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "nextNode",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._interpreter())._nextNode();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"nextNode",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "nextNode\x0a\x09^ self interpreter nextNode",
- messageSends: ["nextNode", "interpreter"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "proceed",
- category: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldBeImplemented();
- return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "proceed\x0a\x09self shouldBeImplemented",
- messageSends: ["shouldBeImplemented"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "restart",
- category: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._interpreter())._restart();
- return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "restart\x0a\x09self interpreter restart",
- messageSends: ["restart", "interpreter"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stepInto",
- category: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._shouldBeImplemented();
- return self}, function($ctx1) {$ctx1.fill(self,"stepInto",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "stepInto\x0a\x09self shouldBeImplemented",
- messageSends: ["shouldBeImplemented"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stepOver",
- category: 'stepping',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st(self._interpreter())._stepOver();
- return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTDebugger)})},
- args: [],
- source: "stepOver\x0a\x09self interpreter stepOver",
- messageSends: ["stepOver", "interpreter"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- category: 'instance creation',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=self._new();
- _st($2)._initializeWithContext_(aContext);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTDebugger.klass)})},
- args: ["aContext"],
- source: "context: aContext\x0a\x09^ self new\x0a\x09\x09initializeWithContext: aContext;\x0a\x09\x09yourself",
- messageSends: ["initializeWithContext:", "new", "yourself"],
- referencedClasses: []
- }),
- smalltalk.ASTDebugger.klass);
- smalltalk.addClass('ASTInterpreter', smalltalk.NodeVisitor, ['node', 'context', 'stack', 'returnValue', 'returned'], 'Compiler-Interpreter');
- smalltalk.ASTInterpreter.comment="I visit an AST, interpreting (evaluating) nodes one after the other, using a small stack machine.\x0a\x0a## API\x0a\x0aWhile my instances should be used from within an `ASTDebugger`, which provides a more high level interface,\x0ayou can use methods from the `interpreting` protocol:\x0a\x0a- `#step` evaluates the current `node` only\x0a- `#stepOver` evaluates the AST from the current `node` up to the next stepping node (most likely the next send node)\x0a- `#proceed` evaluates eagerly the AST\x0a- `#restart` select the first node of the AST\x0a- `#skip` skips the current node, moving to the next one if any";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "assign:to:",
- category: 'private',
- fn: function (aNode,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(aNode)._binding())._isInstanceVar();
- if(smalltalk.assert($1)){
- _st(_st(self._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
- } else {
- _st(self._context())._localAt_put_(_st(aNode)._value(),anObject);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject},smalltalk.ASTInterpreter)})},
- args: ["aNode", "anObject"],
- source: "assign: aNode to: anObject\x0a\x09aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a\x09\x09ifFalse: [ self context localAt: aNode value put: anObject ]",
- messageSends: ["ifTrue:ifFalse:", "isInstanceVar", "binding", "instVarAt:put:", "receiver", "context", "value", "localAt:put:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "atEnd",
- category: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._hasReturned())._or_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._node())._isNil();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"atEnd",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "atEnd\x0a\x09^ self hasReturned or: [ self node isNil ]",
- messageSends: ["or:", "hasReturned", "isNil", "node"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@context"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "context\x0a\x09^ context",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- category: 'accessing',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@context"]=aContext;
- return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTInterpreter)})},
- args: ["aContext"],
- source: "context: aContext\x0a\x09context := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "eval:",
- category: 'private',
- fn: function (aString){
- var self=this;
- var source,function_;
- function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
- function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- source=_st($String())._streamContents_((function(str){
- return smalltalk.withContext(function($ctx2) {
- _st(str)._nextPutAll_("(function(");
- _st(_st(_st(self._context())._locals())._keys())._do_separatedBy_((function(each){
- return smalltalk.withContext(function($ctx3) {
- return _st(str)._nextPutAll_(each);
- }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(str)._nextPutAll_(",");
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
- $1=str;
- _st($1)._nextPutAll_("){ return (function() {");
- _st($1)._nextPutAll_(aString);
- $2=_st($1)._nextPutAll_("})() })");
- return $2;
- }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1,1)})}));
- function_=_st(_st($Compiler())._new())._eval_(source);
- $3=_st(function_)._valueWithPossibleArguments_(_st(_st(self._context())._locals())._values());
- return $3;
- }, function($ctx1) {$ctx1.fill(self,"eval:",{aString:aString,source:source,function_:function_},smalltalk.ASTInterpreter)})},
- args: ["aString"],
- source: "eval: aString\x0a\x09\x22Evaluate aString as JS source inside an JS function.\x0a\x09aString is not sandboxed.\x22\x0a\x09\x0a\x09| source function |\x0a\x09\x0a\x09source := String streamContents: [ :str |\x0a\x09\x09str nextPutAll: '(function('.\x0a\x09\x09self context locals keys\x0a\x09\x09\x09do: [ :each | str nextPutAll: each ]\x0a\x09\x09\x09separatedBy: [ str nextPutAll: ',' ].\x0a\x09\x09str\x0a\x09\x09\x09nextPutAll: '){ return (function() {';\x0a\x09\x09\x09nextPutAll: aString;\x0a\x09\x09\x09nextPutAll: '})() })' ].\x0a\x09\x09\x09\x0a\x09function := Compiler new eval: source.\x0a\x09\x0a\x09^ function valueWithPossibleArguments: self context locals values",
- messageSends: ["streamContents:", "nextPutAll:", "do:separatedBy:", "keys", "locals", "context", "eval:", "new", "valueWithPossibleArguments:", "values"],
- referencedClasses: ["String", "Compiler"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "hasReturned",
- category: 'testing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@returned"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=false;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"hasReturned",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "hasReturned\x0a\x09^ returned ifNil: [ false ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpret",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._visit_(self._node());
- return self}, function($ctx1) {$ctx1.fill(self,"interpret",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "interpret\x0a\x09\x22Interpret the next node to be evaluated\x22\x0a\x09\x0a\x09self visit: self node",
- messageSends: ["visit:", "node"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "interpret:",
- category: 'interpreting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._node_(aNode);
- self._interpret();
- return self}, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "interpret: aNode\x0a\x09self node: aNode.\x0a\x09self interpret",
- messageSends: ["node:", "interpret"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageFromSendNode:arguments:",
- category: 'private',
- fn: function (aSendNode,aCollection){
- var self=this;
- function $Message(){return smalltalk.Message||(typeof Message=="undefined"?nil:Message)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=_st($Message())._new();
- _st($2)._selector_(_st(aSendNode)._selector());
- _st($2)._arguments_(aCollection);
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:arguments:",{aSendNode:aSendNode,aCollection:aCollection},smalltalk.ASTInterpreter)})},
- args: ["aSendNode", "aCollection"],
- source: "messageFromSendNode: aSendNode arguments: aCollection\x0a\x09^ Message new\x0a\x09\x09selector: aSendNode selector;\x0a\x09\x09arguments: aCollection;\x0a\x09\x09yourself",
- messageSends: ["selector:", "new", "selector", "arguments:", "yourself"],
- referencedClasses: ["Message"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "messageNotUnderstood:receiver:",
- category: 'private',
- fn: function (aMessage,anObject){
- var self=this;
- function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st($MessageNotUnderstood())._new();
- _st($1)._meesage_(aMessage);
- _st($1)._receiver_(anObject);
- $2=_st($1)._signal();
- return self}, function($ctx1) {$ctx1.fill(self,"messageNotUnderstood:receiver:",{aMessage:aMessage,anObject:anObject},smalltalk.ASTInterpreter)})},
- args: ["aMessage", "anObject"],
- source: "messageNotUnderstood: aMessage receiver: anObject\x0a\x09MessageNotUnderstood new\x0a\x09\x09meesage: aMessage;\x0a\x09\x09receiver: anObject;\x0a\x09\x09signal",
- messageSends: ["meesage:", "new", "receiver:", "signal"],
- referencedClasses: ["MessageNotUnderstood"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "next",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._node_(_st(self._node())._nextNode());
- return self}, function($ctx1) {$ctx1.fill(self,"next",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "next\x0a\x09self node: self node nextNode",
- messageSends: ["node:", "nextNode", "node"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@node"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "node\x0a\x09\x22Answer the next node, ie the node to be evaluated in the next step\x22\x0a\x09\x0a\x09^ node",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "node:",
- category: 'accessing',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@node"]=aNode;
- return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "node: aNode\x0a\x09node := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "peek",
- category: 'stack',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- var $early={};
- try {
- _st(self._stack())._ifEmpty_((function(){
- return smalltalk.withContext(function($ctx2) {
- throw $early=[nil];
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- $1=_st(self._stack())._last();
- return $1;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"peek",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "peek\x0a\x09\x22Peek the top object of the context stack\x22\x0a\x09\x0a\x09self stack ifEmpty: [ ^ nil ].\x0a\x09\x0a\x09^ self stack last",
- messageSends: ["ifEmpty:", "stack", "last"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pop",
- category: 'stack',
- fn: function (){
- var self=this;
- var peekedValue;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- peekedValue=self._peek();
- _st(self._stack())._removeLast();
- $1=peekedValue;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"pop",{peekedValue:peekedValue},smalltalk.ASTInterpreter)})},
- args: [],
- source: "pop\x0a\x09\x22Pop an object from the context stack\x22\x0a\x09\x0a\x09| peekedValue |\x0a\x09\x0a\x09peekedValue := self peek.\x0a\x09self stack removeLast.\x0a\x09^ peekedValue",
- messageSends: ["peek", "removeLast", "stack"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "proceed",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._atEnd();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._step();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "proceed\x0a\x09\x22Eagerly evaluate the ast\x22\x0a\x09\x0a\x09[ self atEnd ] whileFalse: [ \x0a\x09\x09self step ]",
- messageSends: ["whileFalse:", "atEnd", "step"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "push:",
- category: 'stack',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(self._stack())._add_(anObject);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"push:",{anObject:anObject},smalltalk.ASTInterpreter)})},
- args: ["anObject"],
- source: "push: anObject\x0a\x09\x22Push an object to the context stack\x22\x0a\x09\x0a\x09^ self stack add: anObject",
- messageSends: ["add:", "stack"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "restart",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._node_(_st(_st(self._context())._ast())._nextChild());
- return self}, function($ctx1) {$ctx1.fill(self,"restart",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "restart\x0a\x09self node: self context ast nextChild",
- messageSends: ["node:", "nextChild", "ast", "context"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "result",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self._hasReturned();
- if(smalltalk.assert($2)){
- $1=self._returnValue();
- } else {
- $1=_st(self._context())._receiver();
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "result\x0a\x09^ self hasReturned \x0a\x09\x09ifTrue: [ self returnValue ] \x0a\x09\x09ifFalse: [ self context receiver ]",
- messageSends: ["ifTrue:ifFalse:", "hasReturned", "returnValue", "receiver", "context"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "returnValue",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@returnValue"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"returnValue",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "returnValue\x0a\x09^ returnValue",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "returnValue:",
- category: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@returnValue"]=anObject;
- return self}, function($ctx1) {$ctx1.fill(self,"returnValue:",{anObject:anObject},smalltalk.ASTInterpreter)})},
- args: ["anObject"],
- source: "returnValue: anObject\x0a\x09returnValue := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "sendMessage:to:superSend:",
- category: 'private',
- fn: function (aMessage,anObject,aBoolean){
- var self=this;
- var method;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$4,$5,$6;
- var $early={};
- try {
- $1=aBoolean;
- if(! smalltalk.assert($1)){
- $2=_st(aMessage)._sendTo_(anObject);
- return $2;
- };
- $3=_st(_st(anObject)._class())._superclass();
- if(($receiver = $3) == nil || $receiver == null){
- $4=self._messageNotUnderstood_receiver_(aMessage,anObject);
- return $4;
- } else {
- $3;
- };
- method=_st(_st(_st(_st(anObject)._class())._superclass())._methodDictionary())._at_ifAbsent_(_st(aMessage)._selector(),(function(){
- return smalltalk.withContext(function($ctx2) {
- $5=self._messageNotUnderstood_receiver_(aMessage,anObject);
- throw $early=[$5];
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
- $6=_st(method)._sendTo_arguments_(anObject,_st(aMessage)._arguments());
- return $6;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"sendMessage:to:superSend:",{aMessage:aMessage,anObject:anObject,aBoolean:aBoolean,method:method},smalltalk.ASTInterpreter)})},
- args: ["aMessage", "anObject", "aBoolean"],
- source: "sendMessage: aMessage to: anObject superSend: aBoolean\x0a\x09| method |\x0a\x09\x0a\x09aBoolean ifFalse: [ ^ aMessage sendTo: anObject ].\x0a\x09anObject class superclass ifNil: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x0a\x09method := anObject class superclass methodDictionary\x0a\x09\x09at: aMessage selector\x0a\x09\x09ifAbsent: [ ^ self messageNotUnderstood: aMessage receiver: anObject ].\x0a\x09\x09\x0a\x09^ method sendTo: anObject arguments: aMessage arguments",
- messageSends: ["ifFalse:", "sendTo:", "ifNil:", "superclass", "class", "messageNotUnderstood:receiver:", "at:ifAbsent:", "methodDictionary", "selector", "sendTo:arguments:", "arguments"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "setNonLocalReturnFromContext:",
- category: 'interpreting',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=_st(_st(aContext)._interpreter())._hasReturned();
- if(smalltalk.assert($1)){
- self["@returned"]=true;
- self["@returned"];
- self._returnValue_(_st(_st(aContext)._interpreter())._returnValue());
- };
- return self}, function($ctx1) {$ctx1.fill(self,"setNonLocalReturnFromContext:",{aContext:aContext},smalltalk.ASTInterpreter)})},
- args: ["aContext"],
- source: "setNonLocalReturnFromContext: aContext\x0a\x09aContext interpreter hasReturned ifTrue: [\x0a\x09\x09returned := true.\x0a\x09\x09self returnValue: aContext interpreter returnValue ]",
- messageSends: ["ifTrue:", "hasReturned", "interpreter", "returnValue:", "returnValue"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "skip",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._next();
- return self}, function($ctx1) {$ctx1.fill(self,"skip",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "skip\x0a\x09self next",
- messageSends: ["next"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stack",
- category: 'accessing',
- fn: function (){
- var self=this;
- function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@stack"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@stack"]=_st($OrderedCollection())._new();
- $1=self["@stack"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"stack",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "stack\x0a\x09^ stack ifNil: [ stack := OrderedCollection new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["OrderedCollection"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "step",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=self;
- _st($1)._interpret();
- $2=_st($1)._next();
- return self}, function($ctx1) {$ctx1.fill(self,"step",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "step\x0a\x09self \x0a\x09\x09interpret; \x0a\x09\x09next",
- messageSends: ["interpret", "next"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "stepOver",
- category: 'interpreting',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._step();
- _st((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(self._node())._isSteppingNode();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
- return smalltalk.withContext(function($ctx2) {
- return self._step();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"stepOver",{},smalltalk.ASTInterpreter)})},
- args: [],
- source: "stepOver\x0a\x09self step.\x0a\x09\x0a\x09[ self node isSteppingNode ] whileFalse: [ \x0a\x09\x09self step ]",
- messageSends: ["step", "whileFalse:", "isSteppingNode", "node"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visit:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self._hasReturned();
- if(! smalltalk.assert($1)){
- smalltalk.ASTInterpreter.superclass.fn.prototype._visit_.apply(_st(self), [aNode]);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visit:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visit: aNode\x0a\x09self hasReturned ifFalse: [ super visit: aNode ]",
- messageSends: ["ifFalse:", "hasReturned", "visit:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitAssignmentNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- var poppedValue;
- return smalltalk.withContext(function($ctx1) {
- poppedValue=self._pop();
- self._pop();
- self._push_(poppedValue);
- self._assign_to_(_st(aNode)._left(),poppedValue);
- return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode,poppedValue:poppedValue},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09| poppedValue |\x0a\x09\x0a\x09poppedValue := self pop.\x0a\x09\x0a\x09\x22Pop the left side of the assignment.\x0a\x09It already has been visited, and we don't need its value.\x22\x0a\x09self pop.\x0a\x09\x0a\x09self push: poppedValue.\x0a\x09self assign: aNode left to: poppedValue",
- messageSends: ["pop", "push:", "assign:to:", "left"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- var block;
- function $AIBlockClosure(){return smalltalk.AIBlockClosure||(typeof AIBlockClosure=="undefined"?nil:AIBlockClosure)}
- return smalltalk.withContext(function($ctx1) {
- block=_st($AIBlockClosure())._forContext_node_(self._context(),aNode);
- self._push_(block);
- return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode,block:block},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09\x22Do not evaluate the block node.\x0a\x09Instead, put all instructions into a block that we push to the stack for later evaluation\x22\x0a\x09\x0a\x09| block |\x0a\x09\x0a\x09block := AIBlockClosure forContext: self context node: aNode.\x0a\x09\x0a\x09self push: block",
- messageSends: ["forContext:node:", "context", "push:"],
- referencedClasses: ["AIBlockClosure"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicArrayNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- var array;
- return smalltalk.withContext(function($ctx1) {
- array=[];
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(array)._addFirst_(self._pop());
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- self._push_(array);
- return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode,array:array},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitDynamicArrayNode: aNode\x0a\x09| array |\x0a\x09\x0a\x09array := #().\x0a\x09aNode nodes do: [ :each |\x0a\x09\x09array addFirst: self pop ].\x0a\x09\x0a\x09self push: array",
- messageSends: ["do:", "nodes", "addFirst:", "pop", "push:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitDynamicDictionaryNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- var associations,hashedCollection;
- function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
- function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
- return smalltalk.withContext(function($ctx1) {
- associations=_st($OrderedCollection())._new();
- hashedCollection=_st($HashedCollection())._new();
- _st(_st(aNode)._nodes())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(associations)._add_(self._pop());
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- _st(_st(associations)._reversed())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return _st(hashedCollection)._add_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
- self._push_(hashedCollection);
- return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode,associations:associations,hashedCollection:hashedCollection},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitDynamicDictionaryNode: aNode\x0a\x09| associations hashedCollection |\x0a\x09\x0a\x09associations := OrderedCollection new.\x0a\x09hashedCollection := HashedCollection new.\x0a\x09\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09associations add: self pop ].\x0a\x09\x0a\x09associations reversed do: [ :each |\x0a\x09\x09hashedCollection add: each ].\x0a\x09\x0a\x09self push: hashedCollection",
- messageSends: ["new", "do:", "nodes", "add:", "pop", "reversed", "push:"],
- referencedClasses: ["OrderedCollection", "HashedCollection"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitJSStatementNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@returned"]=true;
- self._returnValue_(self._eval_(_st(aNode)._source()));
- return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: (self eval: aNode source)",
- messageSends: ["returnValue:", "eval:", "source"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return self}, function($ctx1) {$ctx1.fill(self,"visitNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitNode: aNode\x0a\x09\x22Do nothing by default. Especially, do not visit children recursively.\x22",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitReturnNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@returned"]=true;
- self._returnValue_(self._pop());
- return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09returned := true.\x0a\x09self returnValue: self pop",
- messageSends: ["returnValue:", "pop"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- var receiver,args,message,result;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- args=_st(_st(aNode)._arguments())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
- return self._pop();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
- receiver=self._pop();
- message=self._messageFromSendNode_arguments_(aNode,_st(args)._reversed());
- result=self._sendMessage_to_superSend_(message,receiver,_st(aNode)._superSend());
- _st(self._context())._pc_(_st(_st(self._context())._pc()).__plus((1)));
- $1=_st(_st(aNode)._isCascadeSendNode())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(aNode)._isLastChild())._not();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
- if(smalltalk.assert($1)){
- self._push_(receiver);
- } else {
- self._push_(result);
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,receiver:receiver,args:args,message:message,result:result},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09| receiver args message result |\x0a\x09\x0a\x09args := aNode arguments collect: [ :each | self pop ].\x0a\x09receiver := self pop.\x0a\x09\x0a\x09message := self\x0a\x09\x09messageFromSendNode: aNode\x0a\x09\x09arguments: args reversed.\x0a\x09\x0a\x09result := self sendMessage: message to: receiver superSend: aNode superSend.\x0a\x09\x0a\x09self context pc: self context pc + 1.\x0a\x09\x0a\x09\x22For cascade sends, push the reciever if the send is not the last one\x22\x0a\x09(aNode isCascadeSendNode and: [ aNode isLastChild not ])\x0a\x09\x09ifTrue: [ self push: receiver ]\x0a\x09\x09ifFalse: [ self push: result ]",
- messageSends: ["collect:", "arguments", "pop", "messageFromSendNode:arguments:", "reversed", "sendMessage:to:superSend:", "superSend", "pc:", "context", "+", "pc", "ifTrue:ifFalse:", "and:", "isCascadeSendNode", "not", "isLastChild", "push:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitValueNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self._push_(_st(aNode)._value());
- return self}, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitValueNode: aNode\x0a\x09self push: aNode value",
- messageSends: ["push:", "value"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitVariableNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
- function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3,$5,$6,$4;
- $1=_st(_st(aNode)._binding())._isUnknownVar();
- if(smalltalk.assert($1)){
- $2=self._push_(_st(_st($PlatformInterface())._globals())._at_ifAbsent_(_st(aNode)._value(),(function(){
- return smalltalk.withContext(function($ctx2) {
- return self._error_("Unknown variable");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})));
- return $2;
- };
- $3=self;
- $5=_st(_st(aNode)._binding())._isInstanceVar();
- if(smalltalk.assert($5)){
- $4=_st(_st(self._context())._receiver())._instVarAt_(_st(aNode)._value());
- } else {
- $4=_st(self._context())._localAt_ifAbsent_(_st(aNode)._value(),(function(){
- return smalltalk.withContext(function($ctx2) {
- $6=_st(_st(aNode)._value())._isCapitalized();
- if(smalltalk.assert($6)){
- return _st(_st($Smalltalk())._current())._at_ifAbsent_(_st(aNode)._value(),(function(){
- return smalltalk.withContext(function($ctx3) {
- return _st(_st($PlatformInterface())._globals())._at_(_st(aNode)._value());
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)})}));
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}));
- };
- _st($3)._push_($4);
- return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode},smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09aNode binding isUnknownVar ifTrue: [\x0a\x09\x09^ self push: (PlatformInterface globals at: aNode value ifAbsent: [ self error: 'Unknown variable' ]) ].\x0a\x09\x09\x0a\x09self push: (aNode binding isInstanceVar\x0a\x09\x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a\x09\x09ifFalse: [ self context \x0a\x09\x09\x09localAt: aNode value\x0a\x09\x09\x09ifAbsent: [\x0a\x09\x09\x09\x09aNode value isCapitalized\x0a\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09Smalltalk current \x0a\x09\x09\x09\x09\x09\x09\x09at: aNode value \x0a\x09\x09\x09\x09\x09\x09\x09ifAbsent: [ PlatformInterface globals at: aNode value ]]]])",
- messageSends: ["ifTrue:", "isUnknownVar", "binding", "push:", "at:ifAbsent:", "globals", "value", "error:", "ifTrue:ifFalse:", "isInstanceVar", "instVarAt:", "receiver", "context", "localAt:ifAbsent:", "isCapitalized", "current", "at:"],
- referencedClasses: ["PlatformInterface", "Smalltalk"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addClass('ASTInterpreterError', smalltalk.Error, [], 'Compiler-Interpreter');
- smalltalk.ASTInterpreterError.comment="I get signaled when an AST interpreter is unable to interpret a node.";
- smalltalk.addClass('ASTPCNodeVisitor', smalltalk.NodeVisitor, ['useInlinings', 'pc', 'context', 'blockIndex', 'currentNode'], 'Compiler-Interpreter');
- smalltalk.ASTPCNodeVisitor.comment="I visit an AST until I get to the current pc node and answer it.\x0a\x0a## API\x0a\x0aMy instances must be filled with a context object using `#context:`.\x0a\x0aAfter visiting the AST the current node corresponding to the `pc` is answered by `#currentNode`";
- smalltalk.addMethod(
- smalltalk.method({
- selector: "blockIndex",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@blockIndex"];
- if(($receiver = $2) == nil || $receiver == null){
- self["@blockIndex"]=(0);
- $1=self["@blockIndex"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"blockIndex",{},smalltalk.ASTPCNodeVisitor)})},
- args: [],
- source: "blockIndex\x0a\x09^ blockIndex ifNil: [ blockIndex := 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@context"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"context",{},smalltalk.ASTPCNodeVisitor)})},
- args: [],
- source: "context\x0a\x09^ context",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "context:",
- category: 'accessing',
- fn: function (aContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@context"]=aContext;
- return self}, function($ctx1) {$ctx1.fill(self,"context:",{aContext:aContext},smalltalk.ASTPCNodeVisitor)})},
- args: ["aContext"],
- source: "context: aContext\x0a\x09context := aContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "currentNode",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1;
- $1=self["@currentNode"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"currentNode",{},smalltalk.ASTPCNodeVisitor)})},
- args: [],
- source: "currentNode\x0a\x09^ currentNode",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "increaseBlockIndex",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@blockIndex"]=_st(self._blockIndex()).__plus((1));
- return self}, function($ctx1) {$ctx1.fill(self,"increaseBlockIndex",{},smalltalk.ASTPCNodeVisitor)})},
- args: [],
- source: "increaseBlockIndex\x0a\x09blockIndex := self blockIndex + 1",
- messageSends: ["+", "blockIndex"],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pc",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@pc"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=(0);
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"pc",{},smalltalk.ASTPCNodeVisitor)})},
- args: [],
- source: "pc\x0a\x09^ pc ifNil: [ 0 ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "pc:",
- category: 'accessing',
- fn: function (anInteger){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@pc"]=anInteger;
- return self}, function($ctx1) {$ctx1.fill(self,"pc:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitor)})},
- args: ["anInteger"],
- source: "pc: anInteger\x0a\x09pc := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "useInlinings",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $2,$1;
- $2=self["@useInlinings"];
- if(($receiver = $2) == nil || $receiver == null){
- $1=true;
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"useInlinings",{},smalltalk.ASTPCNodeVisitor)})},
- args: [],
- source: "useInlinings\x0a\x09^ useInlinings ifNil: [ true ]",
- messageSends: ["ifNil:"],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "useInlinings:",
- category: 'accessing',
- fn: function (aBoolean){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@useInlinings"]=aBoolean;
- return self}, function($ctx1) {$ctx1.fill(self,"useInlinings:",{aBoolean:aBoolean},smalltalk.ASTPCNodeVisitor)})},
- args: ["aBoolean"],
- source: "useInlinings: aBoolean\x0a\x09useInlinings := aBoolean",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitBlockNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2;
- $1=_st(_st(_st(aNode)._parent())._isSendNode())._and_((function(){
- return smalltalk.withContext(function($ctx2) {
- return _st(_st(aNode)._parent())._shouldBeInlined();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
- if(smalltalk.assert($1)){
- smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
- } else {
- $2=_st(self._blockIndex()).__gt_eq(_st(self._context())._index());
- if(! smalltalk.assert($2)){
- self._increaseBlockIndex();
- smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
- };
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a\x09\x22Inlined send node. Assume that the block is inlined\x22\x0a\x09(aNode parent isSendNode and: [ aNode parent shouldBeInlined ])\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09self blockIndex >= self context index ifFalse: [\x0a\x09\x09\x09\x09self increaseBlockIndex.\x0a\x09\x09\x09\x09super visitBlockNode: aNode ] ]\x0a\x09\x09ifTrue: [ super visitBlockNode: aNode ]",
- messageSends: ["ifFalse:ifTrue:", "and:", "isSendNode", "parent", "shouldBeInlined", "ifFalse:", ">=", "blockIndex", "index", "context", "increaseBlockIndex", "visitBlockNode:"],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitJSStatementNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- self["@currentNode"]=aNode;
- return self}, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09currentNode := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "visitSendNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- var $1,$2,$3;
- smalltalk.ASTPCNodeVisitor.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
- $1=_st(self._pc()).__eq(_st(self._context())._pc());
- if(! smalltalk.assert($1)){
- $2=_st(aNode)._shouldBeInlined();
- if(! smalltalk.assert($2)){
- $3=_st(self._blockIndex()).__eq(_st(self._context())._index());
- if(smalltalk.assert($3)){
- self._pc_(_st(self._pc()).__plus((1)));
- self["@currentNode"]=aNode;
- self["@currentNode"];
- };
- };
- };
- return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},smalltalk.ASTPCNodeVisitor)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09super visitSendNode: aNode.\x0a\x09\x0a\x09self pc = self context pc ifFalse: [\x0a\x09\x09aNode shouldBeInlined ifFalse: [\x0a\x09\x09\x09self blockIndex = self context index ifTrue: [\x0a\x09\x09\x09\x09self pc: self pc + 1.\x0a\x09\x09\x09\x09currentNode := aNode ] ] ]",
- messageSends: ["visitSendNode:", "ifFalse:", "=", "pc", "context", "shouldBeInlined", "ifTrue:", "blockIndex", "index", "pc:", "+"],
- referencedClasses: []
- }),
- smalltalk.ASTPCNodeVisitor);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return false;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.Node)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ false",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.Node);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return true;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.AssignmentNode)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AssignmentNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return true;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.BlockNode)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.BlockNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return true;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicArrayNode)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.DynamicArrayNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return true;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.DynamicDictionaryNode)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.DynamicDictionaryNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return true;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.JSStatementNode)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.JSStatementNode);
- smalltalk.addMethod(
- smalltalk.method({
- selector: "isSteppingNode",
- category: '*Compiler-Interpreter',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
- return true;
- }, function($ctx1) {$ctx1.fill(self,"isSteppingNode",{},smalltalk.SendNode)})},
- args: [],
- source: "isSteppingNode\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.SendNode);
- });
|