use
This commit is contained in:
parent
caf102463a
commit
7dc9866681
31
lib/ast.js
31
lib/ast.js
|
|
@ -47,21 +47,22 @@ function DEFNODE(type, props, methods, base) {
|
|||
if (arguments.length < 4) base = AST_Node;
|
||||
if (!props) props = [];
|
||||
else props = props.split(/\s+/);
|
||||
var ctor = function (props) {
|
||||
if (props) {
|
||||
var ctor = this.CTOR;
|
||||
do {
|
||||
var self_props = ctor.SELF_PROPS;
|
||||
for (var i = self_props.length; i;) {
|
||||
var k = self_props[--i];
|
||||
this[k] = props[k];
|
||||
}
|
||||
} while (ctor = ctor.BASE)
|
||||
if (this.initialize) {
|
||||
this.initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
var code = "return function AST_" + type + "(props) {\
|
||||
if (props) {\
|
||||
var ctor = this.CTOR;\
|
||||
do {\
|
||||
var self_props = ctor.SELF_PROPS;\
|
||||
for (var i = self_props.length; i;) {\
|
||||
var k = self_props[--i];\
|
||||
this[k] = props[k];\
|
||||
}\
|
||||
} while (ctor = ctor.BASE);\
|
||||
if (this.initialize) {\
|
||||
this.initialize();\
|
||||
}\
|
||||
}\
|
||||
}";
|
||||
var ctor = new Function(code)();
|
||||
var proto = base && new base;
|
||||
if (proto) {
|
||||
ctor.prototype = proto;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user