@@ -2330,7 +2330,7 @@ merge(Compressor.prototype, {
|
||||
statements.length = n;
|
||||
}
|
||||
|
||||
function join_assigns(defn, body) {
|
||||
function join_assigns(defn, body, keep) {
|
||||
var exprs;
|
||||
if (body instanceof AST_Assign) {
|
||||
exprs = [ body ];
|
||||
@@ -2352,14 +2352,14 @@ merge(Compressor.prototype, {
|
||||
if (defn instanceof AST_Definitions) {
|
||||
var def = defn.definitions[defn.definitions.length - 1];
|
||||
if (trim_assigns(def.name, def.value, exprs)) trimmed = true;
|
||||
if (join_var_assign(defn.definitions, exprs)) trimmed = true;
|
||||
if (join_var_assign(defn.definitions, exprs, keep || 0)) trimmed = true;
|
||||
}
|
||||
return trimmed && exprs;
|
||||
}
|
||||
|
||||
function join_var_assign(definitions, exprs) {
|
||||
function join_var_assign(definitions, exprs, keep) {
|
||||
var trimmed = false;
|
||||
while (exprs.length) {
|
||||
while (exprs.length > keep) {
|
||||
var expr = exprs[0];
|
||||
if (!(expr instanceof AST_Assign)) break;
|
||||
if (expr.operator != "=") break;
|
||||
@@ -2367,7 +2367,9 @@ merge(Compressor.prototype, {
|
||||
if (!(lhs instanceof AST_SymbolRef)) break;
|
||||
if (is_undeclared_ref(lhs)) break;
|
||||
var def = lhs.definition();
|
||||
if (def.scope !== definitions[0].name.scope) break;
|
||||
if (def.scope !== lhs.scope) break;
|
||||
if (def.orig.length > def.eliminated + 1) break;
|
||||
if (def.orig[0].TYPE != "SymbolVar") break;
|
||||
var name = make_node(AST_SymbolVar, lhs, lhs);
|
||||
definitions.push(make_node(AST_VarDef, expr, {
|
||||
name: name,
|
||||
@@ -2478,7 +2480,7 @@ merge(Compressor.prototype, {
|
||||
|
||||
function join_assigns_expr(value) {
|
||||
statements[++j] = stat;
|
||||
var exprs = join_assigns(prev, value);
|
||||
var exprs = join_assigns(prev, value, 1);
|
||||
if (!exprs) return value;
|
||||
CHANGED = true;
|
||||
var tail = value.tail_node();
|
||||
@@ -6045,11 +6047,21 @@ merge(Compressor.prototype, {
|
||||
|
||||
function can_inject_symbols() {
|
||||
var catches = Object.create(null);
|
||||
var child;
|
||||
scope = compressor.self();
|
||||
do {
|
||||
child = scope;
|
||||
scope = compressor.parent(++level);
|
||||
if (scope instanceof AST_Catch) {
|
||||
catches[scope.argname.name] = true;
|
||||
} else if (scope instanceof AST_IterationStatement) {
|
||||
} else if (scope instanceof AST_DWLoop) {
|
||||
in_loop = [];
|
||||
} else if (scope instanceof AST_For) {
|
||||
if (scope.init === child) continue;
|
||||
in_loop = [];
|
||||
} else if (scope instanceof AST_ForIn) {
|
||||
if (scope.init === child) continue;
|
||||
if (scope.object === child) continue;
|
||||
in_loop = [];
|
||||
} else if (scope instanceof AST_SymbolRef) {
|
||||
if (scope.fixed_value() instanceof AST_Scope) return false;
|
||||
|
||||
Reference in New Issue
Block a user