aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-08-22 15:21:58 +0300
committerMihai Bazon <mihai@bazon.net>2012-08-22 15:21:58 +0300
commit159a6f048cfabc6bdee0bb1274eeb0d6ab75b79a (patch)
tree16996dd7f421281bb60ad8dbf6666a2424262e48 /lib/ast.js
parentf53e139d3cfc9b2eab0239496181a9485728e066 (diff)
downloadtracifyjs-159a6f048cfabc6bdee0bb1274eeb0d6ab75b79a.tar.gz
tracifyjs-159a6f048cfabc6bdee0bb1274eeb0d6ab75b79a.zip
wrote more of the compressor and added some tests
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 97480cc0..ff662d4a 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -2,6 +2,7 @@ function DEFNODE(type, props, methods, base) {
if (arguments.length < 4) base = AST_Node;
if (!props) props = [];
else props = props.split(/\s+/);
+ var self_props = props;
if (base && base.PROPS)
props = props.concat(base.PROPS);
var code = "return function AST_" + type + "(props){ if (props) { ";
@@ -19,6 +20,7 @@ function DEFNODE(type, props, methods, base) {
}
ctor.prototype.CTOR = ctor;
ctor.PROPS = props || null;
+ ctor.SELF_PROPS = self_props;
if (type) {
ctor.prototype.TYPE = ctor.TYPE = type;
}
@@ -563,7 +565,10 @@ TreeWalker.prototype = {
if (!ret && descend) {
descend.call(node);
}
- this.stack.pop(node);
+ this.stack.pop();
return ret;
+ },
+ parent: function(n) {
+ return this.stack[this.stack.length - 2 - (n || 0)];
}
};