properly drop mutually-referring declarations that are not otherwise

referenced and have no side effects
This commit is contained in:
Mihai Bazon
2012-09-23 12:47:34 +03:00
parent 76d88b59dc
commit a83b28503f
5 changed files with 137 additions and 67 deletions

View File

@@ -57,7 +57,9 @@ function DEFNODE(type, props, methods, base) {
var proto = base && new base;
if (proto && proto.initialize || (methods && methods.initialize))
code += "this.initialize();";
code += " } }";
code += " } ";
code += "if (!this.$self) this.$self = this;";
code += " } ";
var ctor = new Function(code)();
if (proto) {
ctor.prototype = proto;
@@ -89,7 +91,7 @@ function DEFNODE(type, props, methods, base) {
var AST_Token = DEFNODE("Token", "type value line col pos endpos nlb comments_before file", {
}, null);
var AST_Node = DEFNODE("Node", "start end", {
var AST_Node = DEFNODE("Node", "$self start end", {
clone: function() {
return new this.CTOR(this);
},
@@ -592,7 +594,7 @@ var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
$documentation: "Base class for all symbols",
});
var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", null, {
var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
$documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
}, AST_Symbol);