transform function calls to IIFEs (#1560)

- expose function body to call sites for potential optimisations
- suppress substitution of variable used within `AST_Defun`
This commit is contained in:
Alex Lam S.L
2017-03-07 15:37:52 +08:00
committed by GitHub
parent d787d70127
commit 8153b7bd8a
5 changed files with 284 additions and 29 deletions

View File

@@ -91,7 +91,15 @@ var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos
}, null);
var AST_Node = DEFNODE("Node", "start end", {
clone: function() {
clone: function(deep) {
if (deep) {
var self = this.clone();
return self.transform(new TreeTransformer(function(node) {
if (node !== self) {
return node.clone(true);
}
}));
}
return new this.CTOR(this);
},
$documentation: "Base class of all AST nodes",