@@ -1552,6 +1552,12 @@ Compressor.prototype.compress = function(node) {
|
|||||||
AST_SymbolDeclaration.DEFMETHOD("convert_symbol", convert_symbol);
|
AST_SymbolDeclaration.DEFMETHOD("convert_symbol", convert_symbol);
|
||||||
AST_SymbolRef.DEFMETHOD("convert_symbol", convert_symbol);
|
AST_SymbolRef.DEFMETHOD("convert_symbol", convert_symbol);
|
||||||
|
|
||||||
|
function process_to_assign(ref) {
|
||||||
|
var def = ref.definition();
|
||||||
|
def.assignments++;
|
||||||
|
def.references.push(ref);
|
||||||
|
}
|
||||||
|
|
||||||
function mark_destructured(process, tw) {
|
function mark_destructured(process, tw) {
|
||||||
var marker = new TreeWalker(function(node) {
|
var marker = new TreeWalker(function(node) {
|
||||||
if (node instanceof AST_DefaultValue) {
|
if (node instanceof AST_DefaultValue) {
|
||||||
@@ -3539,9 +3545,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (!var_def.value) return;
|
if (!var_def.value) return;
|
||||||
exprs.push(make_node(AST_Assign, var_def, {
|
exprs.push(make_node(AST_Assign, var_def, {
|
||||||
operator: "=",
|
operator: "=",
|
||||||
left: var_def.name.convert_symbol(AST_SymbolRef, function(ref) {
|
left: var_def.name.convert_symbol(AST_SymbolRef, process_to_assign),
|
||||||
ref.definition().references.push(ref);
|
|
||||||
}),
|
|
||||||
right: var_def.value,
|
right: var_def.value,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -9084,9 +9088,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
body: make_sequence(self.body, body_exprs),
|
body: make_sequence(self.body, body_exprs),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
body_refs.forEach(function(ref) {
|
body_refs.forEach(process_to_assign);
|
||||||
ref.definition().references.push(ref);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (alt_exprs) {
|
if (alt_exprs) {
|
||||||
[].push.apply(body, alt_defuns);
|
[].push.apply(body, alt_defuns);
|
||||||
@@ -9100,9 +9102,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
body: make_sequence(self.alternative, alt_exprs),
|
body: make_sequence(self.alternative, alt_exprs),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
alt_refs.forEach(function(ref) {
|
alt_refs.forEach(process_to_assign);
|
||||||
ref.definition().references.push(ref);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (var_defs.length > 0) body.push(make_node(AST_Var, self, { definitions: var_defs }));
|
if (var_defs.length > 0) body.push(make_node(AST_Var, self, { definitions: var_defs }));
|
||||||
if (body.length > 0) {
|
if (body.length > 0) {
|
||||||
@@ -9146,12 +9146,8 @@ Compressor.prototype.compress = function(node) {
|
|||||||
}),
|
}),
|
||||||
}).optimize(compressor));
|
}).optimize(compressor));
|
||||||
}
|
}
|
||||||
body_refs.forEach(function(ref) {
|
body_refs.forEach(process_to_assign);
|
||||||
ref.definition().references.push(ref);
|
alt_refs.forEach(process_to_assign);
|
||||||
});
|
|
||||||
alt_refs.forEach(function(ref) {
|
|
||||||
ref.definition().references.push(ref);
|
|
||||||
});
|
|
||||||
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
||||||
}
|
}
|
||||||
if (is_empty(self.body)) self = make_node(AST_If, self, {
|
if (is_empty(self.body)) self = make_node(AST_If, self, {
|
||||||
@@ -10450,6 +10446,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
scope.enclosed.push(def);
|
scope.enclosed.push(def);
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
var sym = make_node(AST_SymbolRef, name, name);
|
var sym = make_node(AST_SymbolRef, name, name);
|
||||||
|
def.assignments++;
|
||||||
def.references.push(sym);
|
def.references.push(sym);
|
||||||
expressions.push(make_node(AST_Assign, self, {
|
expressions.push(make_node(AST_Assign, self, {
|
||||||
operator: "=",
|
operator: "=",
|
||||||
@@ -10523,6 +10520,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
|
|
||||||
function process(ref, name) {
|
function process(ref, name) {
|
||||||
var def = name.definition();
|
var def = name.definition();
|
||||||
|
def.assignments++;
|
||||||
def.references.push(ref);
|
def.references.push(ref);
|
||||||
var symbol = make_node(AST_SymbolVar, name, name);
|
var symbol = make_node(AST_SymbolVar, name, name);
|
||||||
def.orig.push(symbol);
|
def.orig.push(symbol);
|
||||||
|
|||||||
@@ -2007,3 +2007,58 @@ issue_5232_3: {
|
|||||||
"undefined",
|
"undefined",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5334_1: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
hoist_props: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
if (console.log("PASS"))
|
||||||
|
var o = true, o = {
|
||||||
|
p: o += console.log("FAIL"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
var o;
|
||||||
|
console.log("PASS") && (o = true, o = {
|
||||||
|
p: o += console.log("FAIL"),
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5334_2: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
hoist_props: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 3,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
if (console.log("PASS"))
|
||||||
|
var o = true, o = {
|
||||||
|
p: o += console.log("FAIL"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("PASS") && console.log("FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user