wrote more of the compressor and added some tests

This commit is contained in:
Mihai Bazon
2012-08-22 15:21:58 +03:00
parent f53e139d3c
commit 159a6f048c
10 changed files with 497 additions and 19 deletions

View File

@@ -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)];
}
};