ast.js: add a property 'cloned_from' which referred to the origin ast instance to the cloned ast; otherwise we will lose connection between transformer.before and transformer.after

This commit is contained in:
Kael 2012-12-28 11:34:44 +08:00
parent 9916d0e547
commit 842212d5d0

View File

@ -89,7 +89,10 @@ var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_be
var AST_Node = DEFNODE("Node", "start end", {
clone: function() {
return new this.CTOR(this);
var cloned = new this.CTOR(this);
cloned.cloned_from = this;
return cloned;
},
$documentation: "Base class of all AST nodes",
$propdoc: {