@@ -688,6 +688,8 @@ to be `false` and all symbol names will be omitted.
|
|||||||
- `loops` (default: `true`) -- optimizations for `do`, `while` and `for` loops
|
- `loops` (default: `true`) -- optimizations for `do`, `while` and `for` loops
|
||||||
when we can statically determine the condition.
|
when we can statically determine the condition.
|
||||||
|
|
||||||
|
- `merge_vars` (default: `true`) -- combine and reuse variables.
|
||||||
|
|
||||||
- `negate_iife` (default: `true`) -- negate "Immediately-Called Function Expressions"
|
- `negate_iife` (default: `true`) -- negate "Immediately-Called Function Expressions"
|
||||||
where the return value is discarded, to avoid the parens that the
|
where the return value is discarded, to avoid the parens that the
|
||||||
code generator would insert.
|
code generator would insert.
|
||||||
|
|||||||
@@ -3892,7 +3892,8 @@ merge(Compressor.prototype, {
|
|||||||
if (is_undeclared_ref(expr) && global_pure_fns[expr.name]) return true;
|
if (is_undeclared_ref(expr) && global_pure_fns[expr.name]) return true;
|
||||||
if (expr instanceof AST_Dot && is_undeclared_ref(expr.expression)) {
|
if (expr instanceof AST_Dot && is_undeclared_ref(expr.expression)) {
|
||||||
var static_fn = static_fns[expr.expression.name];
|
var static_fn = static_fns[expr.expression.name];
|
||||||
return static_fn && static_fn[expr.property];
|
return static_fn && (static_fn[expr.property]
|
||||||
|
|| expr.expression.name == "Math" && expr.property == "random");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.pure || !compressor.pure_funcs(this);
|
return this.pure || !compressor.pure_funcs(this);
|
||||||
|
|||||||
@@ -245,6 +245,31 @@ unsafe_builtin_2: {
|
|||||||
expect_stdout: "object PASS PASS"
|
expect_stdout: "object PASS PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe_builtin_3: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {};
|
||||||
|
if (42 < Math.random())
|
||||||
|
o.p = "FAIL";
|
||||||
|
else
|
||||||
|
o.p = "PASS";
|
||||||
|
for (var k in o)
|
||||||
|
console.log(k, o[k]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {};
|
||||||
|
o.p = 42 < Math.random() ? "FAIL" : "PASS";
|
||||||
|
for (var k in o)
|
||||||
|
console.log(k, o[k]);
|
||||||
|
}
|
||||||
|
expect_stdout: "p PASS"
|
||||||
|
}
|
||||||
|
|
||||||
unsafe_string_replace: {
|
unsafe_string_replace: {
|
||||||
options = {
|
options = {
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user