aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 689e956b..177bd1d7 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -57,9 +57,7 @@ function DEFNODE(type, props, methods, base) {
var proto = base && new base;
if (proto && proto.initialize || (methods && methods.initialize))
code += "this.initialize();";
- code += " } ";
- code += "if (!this.$self) this.$self = this;";
- code += " } ";
+ code += "}}";
var ctor = new Function(code)();
if (proto) {
ctor.prototype = proto;
@@ -89,13 +87,12 @@ function DEFNODE(type, props, methods, base) {
var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", {
}, null);
-var AST_Node = DEFNODE("Node", "$self start end", {
+var AST_Node = DEFNODE("Node", "start end", {
clone: function() {
return new this.CTOR(this);
},
$documentation: "Base class of all AST nodes",
$propdoc: {
- $self: "[AST_Node] Reference to $self. Not modified by clone(). XXX: this could be removed.",
start: "[AST_Token] The first token of this node",
end: "[AST_Token] The last token of this node"
},
@@ -904,7 +901,7 @@ TreeWalker.prototype = {
},
in_boolean_context: function() {
var stack = this.stack;
- var i = stack.length, self = stack[--i].$self;
+ var i = stack.length, self = stack[--i];
while (i > 0) {
var p = stack[--i];
if ((p instanceof AST_If && p.condition === self) ||
@@ -917,7 +914,7 @@ TreeWalker.prototype = {
}
if (!(p instanceof AST_Binary && (p.operator == "&&" || p.operator == "||")))
return false;
- self = p.$self;
+ self = p;
}
},
loopcontrol_target: function(label) {
@@ -926,15 +923,15 @@ TreeWalker.prototype = {
for (var i = stack.length; --i >= 0;) {
var x = stack[i];
if (x instanceof AST_LabeledStatement && x.label.name == label.name) {
- return x.body.$self;
+ return x.body;
}
}
} else {
for (var i = stack.length; --i >= 0;) {
var x = stack[i];
- if (x instanceof AST_Switch) return x.$self;
+ if (x instanceof AST_Switch) return x;
if (x instanceof AST_For || x instanceof AST_ForIn || x instanceof AST_DWLoop) {
- return (x.body instanceof AST_BlockStatement ? x.body : x).$self;
+ return (x.body instanceof AST_BlockStatement ? x.body : x);
}
}
}