return node;
}
}
- var scope, in_loop, level = -1;
+ var child, in_loop, scope;
if (replacing && can_inject_symbols()) {
fn._squeezed = true;
if (exp !== fn) fn.parent_scope = exp.scope;
function can_inject_symbols() {
var defined = Object.create(null);
- var child;
+ var level = 0;
scope = compressor.self();
- do {
- child = scope;
- scope = compressor.parent(++level);
+ while (!(scope instanceof AST_Scope)) {
if (scope.variables) scope.variables.each(function(def) {
defined[def.name] = true;
});
+ child = scope;
+ scope = compressor.parent(level++);
if (scope instanceof AST_DWLoop) {
in_loop = [];
} else if (scope instanceof AST_For) {
} else if (scope instanceof AST_SymbolRef) {
if (scope.fixed_value() instanceof AST_Scope) return false;
}
- } while (!(scope instanceof AST_Scope));
+ }
var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars)
&& (exp !== fn || fn.parent_scope.resolve() === compressor.find_parent(AST_Scope));
var inline = compressor.option("inline");
return true;
}
});
- args.unshift(scope.body.indexOf(compressor.parent(level - 1)) + 1, 0);
+ args.unshift(scope.body.indexOf(child) + 1, 0);
if (decls.length) args.push(make_node(AST_Var, fn, {
definitions: decls
}));