From 842212d5d06f689aa9e725142c9bf4e3e104ce86 Mon Sep 17 00:00:00 2001 From: Kael Date: Fri, 28 Dec 2012 11:34:44 +0800 Subject: [PATCH] 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 --- lib/ast.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ast.js b/lib/ast.js index c0b263e7..03f90b69 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -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: {