|
@@ -6,7 +6,7 @@ $core.addPackage('Compiler-AST');
|
|
|
$core.packages["Compiler-AST"].innerEval = function (expr) { return eval(expr); };
|
|
|
$core.packages["Compiler-AST"].transport = {"type":"amd","amdNamespace":"amber_core"};
|
|
|
|
|
|
-$core.addClass('Node', $globals.Object, ['parent', 'position', 'source', 'nodes', 'shouldBeInlined', 'shouldBeAliased'], 'Compiler-AST');
|
|
|
+$core.addClass('Node', $globals.Object, ['parent', 'position', 'source', 'nodes', 'shouldBeAliased'], 'Compiler-AST');
|
|
|
|
|
|
$globals.Node.comment="I am the abstract root class of the abstract syntax tree.\x0a\x0aConcrete classes should implement `#accept:` to allow visiting.\x0a\x0a`position` holds a point containing line and column number of the symbol location in the original source file.";
|
|
|
|
|
@@ -236,29 +236,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.Node);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "isLastChild",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-return $recv($recv($recv(self._parent())._nodes())._last()).__eq(self);
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"isLastChild",{},$globals.Node)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "isLastChild\x0a\x09^ self parent nodes last = self",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["=", "last", "nodes", "parent"]
|
|
|
-}),
|
|
|
-$globals.Node);
|
|
|
-
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "isNavigationNode",
|
|
@@ -295,44 +272,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.Node);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "isReferenced",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-var $3,$2,$1;
|
|
|
-$3=self._parent();
|
|
|
-
|
|
|
-$ctx1.sendIdx["parent"]=1;
|
|
|
-
|
|
|
-$2=$recv($3)._isSequenceNode();
|
|
|
-$1=$recv($2)._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx2) {
|
|
|
-
|
|
|
-return $recv(self._parent())._isAssignmentNode();
|
|
|
-
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
-
|
|
|
-}));
|
|
|
-return $recv($1)._not();
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"isReferenced",{},$globals.Node)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "isReferenced\x0a\x09\x22Answer true if the receiver is referenced by other nodes.\x0a\x09Do not take sequences or assignments into account\x22\x0a\x09\x0a\x09^ (self parent isSequenceNode or: [\x0a\x09\x09self parent isAssignmentNode ]) not",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["not", "or:", "isSequenceNode", "parent", "isAssignmentNode"]
|
|
|
-}),
|
|
|
-$globals.Node);
|
|
|
-
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "isReturnNode",
|
|
@@ -916,54 +855,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.Node);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "shouldBeInlined",
|
|
|
-protocol: 'accessing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-var $1,$receiver;
|
|
|
-$1=self["@shouldBeInlined"];
|
|
|
-if(($receiver = $1) == null || $receiver.isNil){
|
|
|
-return false;
|
|
|
-} else {
|
|
|
-return $1;
|
|
|
-};
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"shouldBeInlined",{},$globals.Node)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "shouldBeInlined\x0a\x09^ shouldBeInlined ifNil: [ false ]",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["ifNil:"]
|
|
|
-}),
|
|
|
-$globals.Node);
|
|
|
-
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "shouldBeInlined:",
|
|
|
-protocol: 'accessing',
|
|
|
-fn: function (aBoolean){
|
|
|
-var self=this;
|
|
|
-self["@shouldBeInlined"]=aBoolean;
|
|
|
-return self;
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: ["aBoolean"],
|
|
|
-source: "shouldBeInlined: aBoolean\x0a\x09shouldBeInlined := aBoolean",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: []
|
|
|
-}),
|
|
|
-$globals.Node);
|
|
|
-
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "size",
|
|
@@ -1035,58 +926,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.Node);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "subtreeNeedsAliasing",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-var $1;
|
|
|
-$1=$recv($recv(self._shouldBeAliased())._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx2) {
|
|
|
-
|
|
|
-return self._shouldBeInlined();
|
|
|
-
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
-
|
|
|
-})))._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx2) {
|
|
|
-
|
|
|
-return $recv(self._nodes())._anySatisfy_((function(each){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx3) {
|
|
|
-
|
|
|
-return $recv(each)._subtreeNeedsAliasing();
|
|
|
-
|
|
|
-}, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-$ctx1.sendIdx["or:"]=1;
|
|
|
-
|
|
|
-return $1;
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},$globals.Node)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "subtreeNeedsAliasing\x0a\x09^ (self shouldBeAliased or: [ self shouldBeInlined ]) or: [\x0a\x09\x09self nodes anySatisfy: [ :each | each subtreeNeedsAliasing ] ]",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["or:", "shouldBeAliased", "shouldBeInlined", "anySatisfy:", "nodes", "subtreeNeedsAliasing"]
|
|
|
-}),
|
|
|
-$globals.Node);
|
|
|
-
|
|
|
|
|
|
|
|
|
$core.addClass('AssignmentNode', $globals.Node, ['left', 'right'], 'Compiler-AST');
|
|
@@ -1243,46 +1082,6 @@ messageSends: ["parent:"]
|
|
|
}),
|
|
|
$globals.AssignmentNode);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "shouldBeAliased",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-var $1;
|
|
|
-$1=(
|
|
|
-
|
|
|
-$ctx1.supercall = true,
|
|
|
-
|
|
|
-($globals.AssignmentNode.superclass||$boot.nilAsClass).fn.prototype._shouldBeAliased.apply($recv(self), []));
|
|
|
-
|
|
|
-$ctx1.supercall = false;
|
|
|
-
|
|
|
-return $recv($1)._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx2) {
|
|
|
-
|
|
|
-return self._isReferenced();
|
|
|
-
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{},$globals.AssignmentNode)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "shouldBeAliased\x0a\x09^ super shouldBeAliased or: [ self isReferenced ]",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["or:", "shouldBeAliased", "isReferenced"]
|
|
|
-}),
|
|
|
-$globals.AssignmentNode);
|
|
|
-
|
|
|
|
|
|
|
|
|
$core.addClass('BlockNode', $globals.Node, ['parameters', 'scope'], 'Compiler-AST');
|
|
@@ -1416,37 +1215,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.BlockNode);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "subtreeNeedsAliasing",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-return $recv(self._shouldBeAliased())._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx2) {
|
|
|
-
|
|
|
-return self._shouldBeInlined();
|
|
|
-
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},$globals.BlockNode)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "subtreeNeedsAliasing\x0a\x09^ self shouldBeAliased or: [ self shouldBeInlined ]",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["or:", "shouldBeAliased", "shouldBeInlined"]
|
|
|
-}),
|
|
|
-$globals.BlockNode);
|
|
|
-
|
|
|
|
|
|
|
|
|
$core.addClass('CascadeNode', $globals.Node, ['receiver'], 'Compiler-AST');
|
|
@@ -1531,29 +1299,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.CascadeNode);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "subtreeNeedsAliasing",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-return $recv($recv(self._parent())._isSequenceNode())._not();
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},$globals.CascadeNode)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "subtreeNeedsAliasing\x0a\x09^ self parent isSequenceNode not",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["not", "isSequenceNode", "parent"]
|
|
|
-}),
|
|
|
-$globals.CascadeNode);
|
|
|
-
|
|
|
|
|
|
|
|
|
$core.addClass('DynamicArrayNode', $globals.Node, [], 'Compiler-AST');
|
|
@@ -2129,7 +1874,7 @@ $globals.ReturnNode);
|
|
|
|
|
|
|
|
|
|
|
|
-$core.addClass('SendNode', $globals.Node, ['selector', 'arguments', 'receiver', 'index'], 'Compiler-AST');
|
|
|
+$core.addClass('SendNode', $globals.Node, ['selector', 'arguments', 'receiver', 'index', 'shouldBeInlined'], 'Compiler-AST');
|
|
|
|
|
|
$globals.SendNode.comment="I represent an message send node.";
|
|
|
|
|
@@ -2295,29 +2040,6 @@ messageSends: []
|
|
|
}),
|
|
|
$globals.SendNode);
|
|
|
|
|
|
-$core.addMethod(
|
|
|
-$core.method({
|
|
|
-selector: "isCascadeSendNode",
|
|
|
-protocol: 'testing',
|
|
|
-fn: function (){
|
|
|
-var self=this;
|
|
|
-
|
|
|
-return $core.withContext(function($ctx1) {
|
|
|
-
|
|
|
-return $recv(self._parent())._isCascadeNode();
|
|
|
-
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"isCascadeSendNode",{},$globals.SendNode)});
|
|
|
-
|
|
|
-},
|
|
|
-
|
|
|
-args: [],
|
|
|
-source: "isCascadeSendNode\x0a\x09^ self parent isCascadeNode",
|
|
|
-referencedClasses: [],
|
|
|
-
|
|
|
-messageSends: ["isCascadeNode", "parent"]
|
|
|
-}),
|
|
|
-$globals.SendNode);
|
|
|
-
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "isNavigationNode",
|
|
@@ -2520,63 +2242,49 @@ $globals.SendNode);
|
|
|
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
-selector: "shouldBeAliased",
|
|
|
-protocol: 'testing',
|
|
|
+selector: "shouldBeInlined",
|
|
|
+protocol: 'accessing',
|
|
|
fn: function (){
|
|
|
var self=this;
|
|
|
-var sends;
|
|
|
|
|
|
return $core.withContext(function($ctx1) {
|
|
|
|
|
|
-var $2,$1;
|
|
|
-sends=$recv($recv($recv(self._method())._sendIndexes())._at_(self._selector()))._size();
|
|
|
-$2=(
|
|
|
-
|
|
|
-$ctx1.supercall = true,
|
|
|
-
|
|
|
-($globals.SendNode.superclass||$boot.nilAsClass).fn.prototype._shouldBeAliased.apply($recv(self), []));
|
|
|
-
|
|
|
-$ctx1.supercall = false;
|
|
|
-
|
|
|
-$1=$recv($2)._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx2) {
|
|
|
-
|
|
|
-return $recv(self._isReferenced())._and_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx3) {
|
|
|
-
|
|
|
-return $recv($recv(self._index()).__lt(sends))._or_((function(){
|
|
|
-
|
|
|
-return $core.withContext(function($ctx4) {
|
|
|
-
|
|
|
-return self._superSend();
|
|
|
-
|
|
|
-}, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
-
|
|
|
-}));
|
|
|
-
|
|
|
-$ctx1.sendIdx["or:"]=1;
|
|
|
-
|
|
|
+var $1,$receiver;
|
|
|
+$1=self["@shouldBeInlined"];
|
|
|
+if(($receiver = $1) == null || $receiver.isNil){
|
|
|
+return false;
|
|
|
+} else {
|
|
|
return $1;
|
|
|
+};
|
|
|
|
|
|
-}, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{sends:sends},$globals.SendNode)});
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"shouldBeInlined",{},$globals.SendNode)});
|
|
|
|
|
|
},
|
|
|
|
|
|
args: [],
|
|
|
-source: "shouldBeAliased\x0a\x09\x22Because we keep track of send indexes, some send nodes need additional care for aliasing. \x0a\x09See IRJSVisitor >> visitIRSend:\x22\x0a\x09\x0a\x09| sends |\x0a\x09\x0a\x09sends := (self method sendIndexes at: self selector) size.\x0a\x09\x0a\x09^ (super shouldBeAliased or: [\x0a\x09\x09self isReferenced and: [\x0a\x09\x09\x09self index < sends or: [\x0a\x09\x09\x09\x09self superSend ] ] ])",
|
|
|
+source: "shouldBeInlined\x0a\x09^ shouldBeInlined ifNil: [ false ]",
|
|
|
referencedClasses: [],
|
|
|
|
|
|
-messageSends: ["size", "at:", "sendIndexes", "method", "selector", "or:", "shouldBeAliased", "and:", "isReferenced", "<", "index", "superSend"]
|
|
|
+messageSends: ["ifNil:"]
|
|
|
+}),
|
|
|
+$globals.SendNode);
|
|
|
+
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "shouldBeInlined:",
|
|
|
+protocol: 'accessing',
|
|
|
+fn: function (aBoolean){
|
|
|
+var self=this;
|
|
|
+self["@shouldBeInlined"]=aBoolean;
|
|
|
+return self;
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+args: ["aBoolean"],
|
|
|
+source: "shouldBeInlined: aBoolean\x0a\x09shouldBeInlined := aBoolean",
|
|
|
+referencedClasses: [],
|
|
|
+
|
|
|
+messageSends: []
|
|
|
}),
|
|
|
$globals.SendNode);
|
|
|
|