Merge branch 'master' into harmony-v3.3.7

This commit is contained in:
alexlamsl
2018-01-14 17:15:16 +08:00
5 changed files with 142 additions and 20 deletions

View File

@@ -1829,6 +1829,7 @@ merge(Compressor.prototype, {
do {
var node = exprs[0];
if (!(node instanceof AST_Assign)) break;
if (node.operator != "=") break;
if (!(node.left instanceof AST_PropAccess)) break;
var sym = node.left.expression;
if (!(sym instanceof AST_SymbolRef)) break;
@@ -1865,8 +1866,26 @@ merge(Compressor.prototype, {
statements[++j] = stat;
defs = stat;
}
} else if (stat instanceof AST_Exit) {
var exprs = join_object_assignments(prev, stat.value);
if (exprs) {
CHANGED = true;
if (exprs.length) {
stat.value = make_sequence(stat.value, exprs);
} else if (stat.value instanceof AST_Sequence) {
stat.value = stat.value.tail_node().left;
} else {
stat.value = stat.value.left;
}
}
statements[++j] = stat;
} else if (stat instanceof AST_For) {
if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
var exprs = join_object_assignments(prev, stat.init);
if (exprs) {
CHANGED = true;
stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
statements[++j] = stat;
} else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
if (stat.init) {
prev.definitions = prev.definitions.concat(stat.init.definitions);
}

View File

@@ -58,7 +58,7 @@ function SymbolDef(scope, orig, init) {
this.id = SymbolDef.next_id++;
};
SymbolDef.next_id = 1e6;
SymbolDef.next_id = 1;
SymbolDef.prototype = {
unmangleable: function(options) {