@@ -185,7 +185,7 @@ function Compressor(options, false_by_default) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Compressor.prototype = new TreeTransformer(function(node, descend, in_list) {
|
Compressor.prototype = new TreeTransformer(function(node, descend) {
|
||||||
if (node._squeezed) return node;
|
if (node._squeezed) return node;
|
||||||
var is_scope = node instanceof AST_Scope;
|
var is_scope = node instanceof AST_Scope;
|
||||||
if (is_scope) {
|
if (is_scope) {
|
||||||
@@ -270,7 +270,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
(function(OPT) {
|
(function(OPT) {
|
||||||
OPT(AST_Node, function(self, compressor) {
|
OPT(AST_Node, function(self) {
|
||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -10926,7 +10926,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (can_substitute_directly()) {
|
if (can_substitute_directly()) {
|
||||||
var args = self.args.slice();
|
var args = self.args.slice();
|
||||||
var refs = [];
|
var refs = [];
|
||||||
var retValue = value.clone(true).transform(new TreeTransformer(function(node) {
|
var retValue = value.optimize(compressor).clone(true).transform(new TreeTransformer(function(node) {
|
||||||
if (node instanceof AST_SymbolRef) {
|
if (node instanceof AST_SymbolRef) {
|
||||||
var def = node.definition();
|
var def = node.definition();
|
||||||
if (fn.variables.get(node.name) !== def) {
|
if (fn.variables.get(node.name) !== def) {
|
||||||
|
|||||||
@@ -8817,3 +8817,103 @@ issue_5766_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5841_1: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 42;
|
||||||
|
(function() {
|
||||||
|
f();
|
||||||
|
var b = f();
|
||||||
|
function f() {
|
||||||
|
if (console && a)
|
||||||
|
g && g();
|
||||||
|
}
|
||||||
|
function g() {
|
||||||
|
var c;
|
||||||
|
for (;console.log("foo"););
|
||||||
|
(function h(d) {
|
||||||
|
d && d.p;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 42;
|
||||||
|
(function() {
|
||||||
|
f();
|
||||||
|
f();
|
||||||
|
function f() {
|
||||||
|
{
|
||||||
|
if (console && a) {
|
||||||
|
for (;console.log("foo"););
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5841_2: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 42;
|
||||||
|
(function() {
|
||||||
|
f();
|
||||||
|
var b = f();
|
||||||
|
function f() {
|
||||||
|
if (console && a)
|
||||||
|
g && g();
|
||||||
|
}
|
||||||
|
function g() {
|
||||||
|
var c;
|
||||||
|
for (;console.log("foo"););
|
||||||
|
(function h(d) {
|
||||||
|
d && d.p;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 42;
|
||||||
|
(function() {
|
||||||
|
f();
|
||||||
|
f();
|
||||||
|
function f() {
|
||||||
|
if (console && a)
|
||||||
|
for (;console.log("foo"););
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user