Merge branch 'master' into harmony-v3.0.12

This commit is contained in:
alexlamsl
2017-05-27 18:12:10 +08:00
13 changed files with 497 additions and 94 deletions

View File

@@ -991,15 +991,15 @@ merge(Compressor.prototype, {
CHANGED = true;
stat = stat.clone();
stat.condition = stat.condition.negate(compressor);
var funs = extract_functions_from_statement_array(ret);
var body = as_statement_array(stat.alternative).concat(ret);
var funs = extract_functions_from_statement_array(body);
stat.body = make_node(AST_BlockStatement, stat, {
body: body
});
stat.alternative = value ? make_node(AST_SimpleStatement, value, {
body: value.expression
}) : null;
ret = funs.concat([ stat.transform(compressor) ]);
ret = [ stat.transform(compressor) ].concat(funs);
continue loop;
}
//---
@@ -1248,7 +1248,7 @@ merge(Compressor.prototype, {
target.push(node);
return true;
}
if (node instanceof AST_Defun) {
if (node instanceof AST_Defun && (node === stat || !compressor.has_directive("use strict"))) {
target.push(node);
return true;
}
@@ -2386,11 +2386,13 @@ merge(Compressor.prototype, {
dirs.push(node);
return make_node(AST_EmptyStatement, node);
}
if (hoist_funs && node instanceof AST_Defun && !(tt.parent() instanceof AST_Export)) {
if (hoist_funs && node instanceof AST_Defun
&& !(tt.parent() instanceof AST_Export)
&& (tt.parent() === self || !compressor.has_directive("use strict"))) {
hoisted.push(node);
return make_node(AST_EmptyStatement, node);
}
if (node instanceof AST_Var && hoist_vars) {
if (hoist_vars && node instanceof AST_Var) {
node.definitions.forEach(function(def){
if (def.name instanceof AST_Destructuring) return;
vars.set(def.name.name, def);