123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643 |
- smalltalk.addPackage('Compiler-Interpreter', {});
- smalltalk.addClass('AIContext', smalltalk.NodeVisitor, ['outerContext', 'pc', 'locals', 'receiver', 'selector'], 'Compiler-Interpreter');
- smalltalk.addMethod(
- "_initializeFromMethodContext_",
- smalltalk.method({
- selector: "initializeFromMethodContext:",
- category: 'accessing',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- _st(self)._pc_(_st(aMethodContext)._pc());
- _st(self)._receiver_(_st(aMethodContext)._receiver());
- _st(self)._selector_(_st(aMethodContext)._selector());
- $1=_st(aMethodContext)._outerContext();
- if(($receiver = $1) == nil || $receiver == undefined){
- $1;
- } else {
- _st(self)._outerContext_(_st(_st(self)._class())._fromMethodContext_(_st(aMethodContext)._outerContext()));
- };
- _st(_st(aMethodContext)._locals())._keysAndValuesDo_((function(key,value){
- return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._locals())._at_put_(key,value);
- }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
- return self}, function($ctx1) {$ctx1.fill(self,"initializeFromMethodContext:",{aMethodContext:aMethodContext}, smalltalk.AIContext)})},
- args: ["aMethodContext"],
- source: "initializeFromMethodContext: aMethodContext\x0a\x09self pc: aMethodContext pc.\x0a self receiver: aMethodContext receiver.\x0a self selector: aMethodContext selector.\x0a aMethodContext outerContext ifNotNil: [\x0a\x09\x09self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].\x0a aMethodContext locals keysAndValuesDo: [ :key :value |\x0a \x09self locals at: key put: value ]\x0a ",
- messageSends: ["pc:", "pc", "receiver:", "receiver", "selector:", "selector", "ifNotNil:", "outerContext:", "fromMethodContext:", "outerContext", "class", "keysAndValuesDo:", "at:put:", "locals"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_localAt_",
- smalltalk.method({
- selector: "localAt:",
- category: 'accessing',
- fn: function (aString){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=_st(_st(self)._locals())._at_ifAbsent_(aString,(function(){
- return smalltalk.withContext(function($ctx2) {
return nil;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"localAt:",{aString:aString}, smalltalk.AIContext)})},
- args: ["aString"],
- source: "localAt: aString\x0a\x09^ self locals at: aString ifAbsent: [ nil ]",
- messageSends: ["at:ifAbsent:", "locals"],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_localAt_put_",
- smalltalk.method({
- selector: "localAt:put:",
- category: 'accessing',
- fn: function (aString,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
_st(_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(
- "_locals",
- smalltalk.method({
- selector: "locals",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $2,$1;
- $2=self["@locals"];
- if(($receiver = $2) == nil || $receiver == undefined){
- self["@locals"]=_st((smalltalk.Dictionary || Dictionary))._new();
- $1=self["@locals"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"locals",{}, smalltalk.AIContext)})},
- args: [],
- source: "locals\x0a\x09^ locals ifNil: [ locals := Dictionary new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["Dictionary"]
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_outerContext",
- 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(
- "_outerContext_",
- smalltalk.method({
- selector: "outerContext:",
- category: 'accessing',
- fn: function (anAIContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
self["@outerContext"]=anAIContext;
- return self}, function($ctx1) {$ctx1.fill(self,"outerContext:",{anAIContext:anAIContext}, smalltalk.AIContext)})},
- args: ["anAIContext"],
- source: "outerContext: anAIContext\x0a\x09outerContext := anAIContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_pc",
- 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 == undefined){
- 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(
- "_pc_",
- 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.AIContext)})},
- args: ["anInteger"],
- source: "pc: anInteger\x0a\x09pc := anInteger",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_receiver",
- smalltalk.method({
- selector: "receiver",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=self["@receiver"];
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"receiver",{}, smalltalk.AIContext)})},
- args: [],
- source: "receiver\x0a\x09^ receiver",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_receiver_",
- smalltalk.method({
- selector: "receiver:",
- category: 'accessing',
- fn: function (anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
self["@receiver"]=anObject;
- return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{anObject:anObject}, smalltalk.AIContext)})},
- args: ["anObject"],
- source: "receiver: anObject\x0a\x09receiver := anObject",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.AIContext);
- smalltalk.addMethod(
- "_selector",
- 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(
- "_selector_",
- 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(
- "_fromMethodContext_",
- smalltalk.method({
- selector: "fromMethodContext:",
- category: 'instance creation',
- fn: function (aMethodContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $2,$3,$1;
- $2=_st(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 \x09initializeFromMethodContext: aMethodContext;\x0a yourself",
- messageSends: ["initializeFromMethodContext:", "new", "yourself"],
- referencedClasses: []
- }),
- smalltalk.AIContext.klass);
- smalltalk.addClass('ASTInterpreter', smalltalk.NodeVisitor, ['currentNode', 'context', 'shouldReturn'], 'Compiler-Interpreter');
- smalltalk.addMethod(
- "_assign_to_",
- smalltalk.method({
- selector: "assign:to:",
- category: 'interpreting',
- fn: function (aNode,anObject){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $2,$1;
- $2=_st(_st(aNode)._binding())._isInstanceVar();
- if(smalltalk.assert($2)){
- $1=_st(_st(_st(self)._context())._receiver())._instVarAt_put_(_st(aNode)._value(),anObject);
- } else {
- $1=_st(_st(self)._context())._localAt_put_(_st(aNode)._value(),anObject);
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"assign:to:",{aNode:aNode,anObject:anObject}, smalltalk.ASTInterpreter)})},
- args: ["aNode", "anObject"],
- source: "assign: aNode to: anObject\x0a\x09^ aNode binding isInstanceVar \x0a \x09ifTrue: [ self context receiver instVarAt: aNode value put: anObject ]\x0a \x09ifFalse: [ self context localAt: aNode value put: anObject ]",
- messageSends: ["ifTrue:ifFalse:", "instVarAt:put:", "value", "receiver", "context", "localAt:put:", "isInstanceVar", "binding"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_context",
- smalltalk.method({
- selector: "context",
- category: 'accessing',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $2,$1;
- $2=self["@context"];
- if(($receiver = $2) == nil || $receiver == undefined){
- self["@context"]=_st((smalltalk.AIContext || AIContext))._new();
- $1=self["@context"];
- } else {
- $1=$2;
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"context",{}, smalltalk.ASTInterpreter)})},
- args: [],
- source: "context\x0a\x09^ context ifNil: [ context := AIContext new ]",
- messageSends: ["ifNil:", "new"],
- referencedClasses: ["AIContext"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_context_",
- smalltalk.method({
- selector: "context:",
- category: 'accessing',
- fn: function (anAIContext){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
self["@context"]=anAIContext;
- return self}, function($ctx1) {$ctx1.fill(self,"context:",{anAIContext:anAIContext}, smalltalk.ASTInterpreter)})},
- args: ["anAIContext"],
- source: "context: anAIContext\x0a\x09context := anAIContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_eval_",
- smalltalk.method({
- selector: "eval:",
- category: 'interpreting',
- fn: function (aString){
- var self=this;
- var source,function_;
- return smalltalk.withContext(function($ctx1) {
var $1,$2,$3;
- source=_st((smalltalk.String || String))._streamContents_((function(str){
- return smalltalk.withContext(function($ctx2) {
_st(str)._nextPutAll_("(function(");
- _st(_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},$ctx1)})}),(function(){
- return smalltalk.withContext(function($ctx3) {
return _st(str)._nextPutAll_(",");
- }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
- $1=str;
- _st($1)._nextPutAll_("){ return (function() {");
- _st($1)._nextPutAll_(aString);
- $2=_st($1)._nextPutAll_("})() })");
- return $2;
- }, function($ctx2) {$ctx2.fillBlock({str:str},$ctx1)})}));
- function_=_st(_st((smalltalk.Compiler || Compiler))._new())._eval_(source);
- $3=_st(function_)._valueWithPossibleArguments_(_st(_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 aString is not sandboxed.\x22\x0a \x0a | source function |\x0a \x0a source := String streamContents: [ :str |\x0a \x09str nextPutAll: '(function('.\x0a self context locals keys \x0a \x09do: [ :each | str nextPutAll: each ]\x0a \x09separatedBy: [ str nextPutAll: ',' ].\x0a str \x0a \x09nextPutAll: '){ return (function() {';\x0a \x09nextPutAll: aString;\x0a nextPutAll: '})() })' ].\x0a \x0a\x09function := Compiler new eval: source.\x0a \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(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'initialization',
- fn: function (){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
smalltalk.NodeVisitor.fn.prototype._initialize.apply(_st(self), []);
- self["@shouldReturn"]=false;
- return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.ASTInterpreter)})},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a shouldReturn := false",
- messageSends: ["initialize"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_interpret_",
- smalltalk.method({
- selector: "interpret:",
- category: 'interpreting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- self["@shouldReturn"]=false;
- $1=_st(self)._interpretNode_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"interpret:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "interpret: aNode\x0a\x09shouldReturn := false.\x0a ^ self interpretNode: aNode",
- messageSends: ["interpretNode:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_interpretNode_",
- smalltalk.method({
- selector: "interpretNode:",
- category: 'interpreting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- self["@currentNode"]=aNode;
- $1=_st(self)._visit_(aNode);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"interpretNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "interpretNode: aNode\x0a\x09currentNode := aNode.\x0a ^ self visit: aNode",
- messageSends: ["visit:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_messageFromSendNode_",
- smalltalk.method({
- selector: "messageFromSendNode:",
- category: 'interpreting',
- fn: function (aSendNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $2,$3,$1;
- $2=_st((smalltalk.Message || Message))._new();
- _st($2)._selector_(_st(aSendNode)._selector());
- _st($2)._arguments_(_st(_st(aSendNode)._arguments())._collect_((function(each){
- return smalltalk.withContext(function($ctx2) {
return _st(self)._interpretNode_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})));
- $3=_st($2)._yourself();
- $1=$3;
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"messageFromSendNode:",{aSendNode:aSendNode}, smalltalk.ASTInterpreter)})},
- args: ["aSendNode"],
- source: "messageFromSendNode: aSendNode\x0a\x09^ Message new\x0a \x09selector: aSendNode selector;\x0a arguments: (aSendNode arguments collect: [ :each |\x0a \x09self interpretNode: each ]);\x0a yourself",
- messageSends: ["selector:", "selector", "new", "arguments:", "collect:", "interpretNode:", "arguments", "yourself"],
- referencedClasses: ["Message"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitAssignmentNode_",
- smalltalk.method({
- selector: "visitAssignmentNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=_st(self)._assign_to_(_st(aNode)._left(),_st(self)._interpretNode_(_st(aNode)._right()));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitAssignmentNode: aNode\x0a\x09^ self assign: aNode left to: (self interpretNode: aNode right)",
- messageSends: ["assign:to:", "left", "interpretNode:", "right"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitBlockNode_",
- smalltalk.method({
- selector: "visitBlockNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=(function(){
- return smalltalk.withContext(function($ctx2) {
return _st(self)._interpretNode_(_st(_st(aNode)._nodes())._first());
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitBlockNode: aNode\x0a ^ [ self interpretNode: aNode nodes first ]",
- messageSends: ["interpretNode:", "first", "nodes"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitCascadeNode_",
- smalltalk.method({
- selector: "visitCascadeNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- var receiver;
- return smalltalk.withContext(function($ctx1) {
var $1;
- receiver=_st(self)._interpretNode_(_st(aNode)._receiver());
- _st(_st(_st(aNode)._nodes())._allButLast())._do_((function(each){
- return smalltalk.withContext(function($ctx2) {
return _st(_st(self)._messageFromSendNode_(each))._sendTo_(receiver);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
- $1=_st(_st(self)._messageFromSendNode_(_st(_st(aNode)._nodes())._last()))._sendTo_(receiver);
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode,receiver:receiver}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitCascadeNode: aNode\x0a\x09\x22TODO: Handle super sends\x22\x0a\x09| receiver |\x0a \x0a receiver := self interpretNode: aNode receiver.\x0a\x0a aNode nodes allButLast\x0a \x09do: [ :each | \x0a \x09(self messageFromSendNode: each)\x0a \x09sendTo: receiver ].\x0a\x0a ^ (self messageFromSendNode: aNode nodes last)\x0a \x09sendTo: receiver",
- messageSends: ["interpretNode:", "receiver", "do:", "sendTo:", "messageFromSendNode:", "allButLast", "nodes", "last"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitClassReferenceNode_",
- smalltalk.method({
- selector: "visitClassReferenceNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(_st(aNode)._value());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitClassReferenceNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitClassReferenceNode: aNode\x0a\x09^ Smalltalk current at: aNode value",
- messageSends: ["at:", "value", "current"],
- referencedClasses: ["Smalltalk"]
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitJSStatementNode_",
- smalltalk.method({
- selector: "visitJSStatementNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- self["@shouldReturn"]=true;
- $1=_st(self)._eval_(_st(aNode)._source());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitJSStatementNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitJSStatementNode: aNode\x0a\x09shouldReturn := true.\x0a\x09^ self eval: aNode source",
- messageSends: ["eval:", "source"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitReturnNode_",
- smalltalk.method({
- selector: "visitReturnNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- self["@shouldReturn"]=true;
- $1=_st(self)._interpretNode_(_st(_st(aNode)._nodes())._first());
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitReturnNode: aNode\x0a\x09shouldReturn := true.\x0a ^ self interpretNode: aNode nodes first",
- messageSends: ["interpretNode:", "first", "nodes"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitSendNode_",
- smalltalk.method({
- selector: "visitSendNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=_st(_st(self)._messageFromSendNode_(aNode))._sendTo_(_st(self)._interpretNode_(_st(aNode)._receiver()));
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitSendNode: aNode\x0a\x09\x22TODO: Handle super sends\x22\x0a \x0a ^ (self messageFromSendNode: aNode)\x0a \x09sendTo: (self interpretNode: aNode receiver)",
- messageSends: ["sendTo:", "interpretNode:", "receiver", "messageFromSendNode:"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitSequenceNode_",
- smalltalk.method({
- selector: "visitSequenceNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1,$3,$4,$2,$5;
- var $early={};
- try {
- $1=_st(_st(aNode)._nodes())._allButLast();
- $2=(function(each){
- var value;
- return smalltalk.withContext(function($ctx2) {
value=_st(self)._interpretNode_(each);
- value;
- $3=self["@shouldReturn"];
- if(smalltalk.assert($3)){
- $4=value;
- throw $early=[$4];
- };
- }, function($ctx2) {$ctx2.fillBlock({each:each,value:value},$ctx1)})});
- _st($1)._do_($2);
- $5=_st(self)._interpretNode_(_st(_st(aNode)._nodes())._last());
- return $5;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitSequenceNode: aNode\x0a\x0a\x09aNode nodes allButLast do: [ :each | | value |\x0a value := self interpretNode: each.\x0a\x09\x09shouldReturn ifTrue: [ ^ value ] ].\x0a \x0a ^ self interpretNode: aNode nodes last",
- messageSends: ["do:", "interpretNode:", "ifTrue:", "allButLast", "nodes", "last"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitValueNode_",
- smalltalk.method({
- selector: "visitValueNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $1;
- $1=_st(aNode)._value();
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitValueNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitValueNode: aNode\x0a\x09^ aNode value",
- messageSends: ["value"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
- smalltalk.addMethod(
- "_visitVariableNode_",
- smalltalk.method({
- selector: "visitVariableNode:",
- category: 'visiting',
- fn: function (aNode){
- var self=this;
- return smalltalk.withContext(function($ctx1) {
var $2,$1;
- $2=_st(_st(aNode)._binding())._isInstanceVar();
- if(smalltalk.assert($2)){
- $1=_st(_st(_st(self)._context())._receiver())._instVarAt_(_st(aNode)._value());
- } else {
- $1=_st(_st(self)._context())._localAt_(_st(aNode)._value());
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
- args: ["aNode"],
- source: "visitVariableNode: aNode\x0a\x09^ aNode binding isInstanceVar\x0a \x09ifTrue: [ self context receiver instVarAt: aNode value ]\x0a \x09ifFalse: [ self context localAt: aNode value ]",
- messageSends: ["ifTrue:ifFalse:", "instVarAt:", "value", "receiver", "context", "localAt:", "isInstanceVar", "binding"],
- referencedClasses: []
- }),
- smalltalk.ASTInterpreter);
|