Merge branch 'master' into harmony-v3.3.1
This commit is contained in:
@@ -4220,7 +4220,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_func_expr(fn) && !fn.is_generator && !fn.async) {
|
if (is_func_expr(fn) && !fn.is_generator && !fn.async) {
|
||||||
var def, scope, value;
|
var def, value, scope, level = -1;
|
||||||
if (compressor.option("inline")
|
if (compressor.option("inline")
|
||||||
&& simple_args
|
&& simple_args
|
||||||
&& !fn.uses_arguments
|
&& !fn.uses_arguments
|
||||||
@@ -4233,9 +4233,9 @@ merge(Compressor.prototype, {
|
|||||||
&& fn.is_constant_expression(exp.scope))
|
&& fn.is_constant_expression(exp.scope))
|
||||||
&& !self.pure
|
&& !self.pure
|
||||||
&& !fn.contains_this()
|
&& !fn.contains_this()
|
||||||
&& (scope = can_flatten_args(fn))
|
&& can_flatten_args(fn)
|
||||||
&& (value = flatten_body(stat))) {
|
&& (value = flatten_body(stat))) {
|
||||||
var expressions = flatten_args(fn, scope);
|
var expressions = flatten_args(fn);
|
||||||
expressions.push(value.clone(true));
|
expressions.push(value.clone(true));
|
||||||
return make_sequence(self, expressions).optimize(compressor);
|
return make_sequence(self, expressions).optimize(compressor);
|
||||||
}
|
}
|
||||||
@@ -4268,10 +4268,9 @@ merge(Compressor.prototype, {
|
|||||||
return self;
|
return self;
|
||||||
|
|
||||||
function can_flatten_args(fn) {
|
function can_flatten_args(fn) {
|
||||||
var scope, level = 0;
|
|
||||||
var catches = Object.create(null);
|
var catches = Object.create(null);
|
||||||
do {
|
do {
|
||||||
scope = compressor.parent(level++);
|
scope = compressor.parent(++level);
|
||||||
if (scope instanceof AST_SymbolRef) {
|
if (scope instanceof AST_SymbolRef) {
|
||||||
scope = scope.fixed_value();
|
scope = scope.fixed_value();
|
||||||
} else if (scope instanceof AST_Catch) {
|
} else if (scope instanceof AST_Catch) {
|
||||||
@@ -4288,10 +4287,10 @@ merge(Compressor.prototype, {
|
|||||||
&& !catches[arg.name]
|
&& !catches[arg.name]
|
||||||
&& !identifier_atom(arg.name)
|
&& !identifier_atom(arg.name)
|
||||||
&& !scope.var_names()[arg.name];
|
&& !scope.var_names()[arg.name];
|
||||||
}) && scope;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function flatten_args(fn, scope) {
|
function flatten_args(fn) {
|
||||||
var decls = [];
|
var decls = [];
|
||||||
var expressions = [];
|
var expressions = [];
|
||||||
for (var len = fn.argnames.length, i = len; --i >= 0;) {
|
for (var len = fn.argnames.length, i = len; --i >= 0;) {
|
||||||
@@ -4325,8 +4324,7 @@ merge(Compressor.prototype, {
|
|||||||
expressions.push(self.args[i]);
|
expressions.push(self.args[i]);
|
||||||
}
|
}
|
||||||
if (decls.length) {
|
if (decls.length) {
|
||||||
for (i = 0; compressor.parent(i) !== scope;) i++;
|
i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
|
||||||
i = scope.body.indexOf(compressor.parent(i - 1)) + 1;
|
|
||||||
scope.body.splice(i, 0, make_node(AST_Var, fn, {
|
scope.body.splice(i, 0, make_node(AST_Var, fn, {
|
||||||
definitions: decls
|
definitions: decls
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony",
|
"homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "3.3.0",
|
"version": "3.3.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ var urls = [
|
|||||||
"http://builds.emberjs.com/tags/v2.11.0/ember.prod.js",
|
"http://builds.emberjs.com/tags/v2.11.0/ember.prod.js",
|
||||||
"https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js",
|
"https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js",
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.js",
|
"https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.js",
|
||||||
|
"https://raw.githubusercontent.com/kangax/html-minifier/v3.5.7/dist/htmlminifier.js",
|
||||||
];
|
];
|
||||||
var results = {};
|
var results = {};
|
||||||
var remaining = 2 * urls.length;
|
var remaining = 2 * urls.length;
|
||||||
|
|||||||
@@ -1548,3 +1548,27 @@ issue_2647_3: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recursive_inline: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
h();
|
||||||
|
}
|
||||||
|
function g(a) {
|
||||||
|
a();
|
||||||
|
}
|
||||||
|
function h(b) {
|
||||||
|
g();
|
||||||
|
if (b) x();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user