Merge branch 'master' into harmony-v2.8.10

This commit is contained in:
alexlamsl
2017-03-09 06:02:28 +08:00
12 changed files with 201 additions and 74 deletions

View File

@@ -1943,6 +1943,7 @@ merge(Compressor.prototype, {
}
if (node instanceof AST_Definitions && !(tt.parent() instanceof AST_ForIn)) {
var def = node.definitions.filter(function(def){
if (def.value) def.value = def.value.transform(tt);
if (def.is_destructuring()) return true;
if (def.name.definition().id in in_use_ids) return true;
if (!drop_vars && def.name.definition().global) return true;
@@ -2006,18 +2007,16 @@ merge(Compressor.prototype, {
}
return node;
}
if (assign_as_unused) {
var n = node;
while (n instanceof AST_Assign
&& n.operator == "="
&& n.left instanceof AST_SymbolRef) {
var def = n.left.definition();
if (def.id in in_use_ids
|| !drop_vars && def.global
|| self.variables.get(def.name) !== def) break;
n = n.right;
if (assign_as_unused
&& node instanceof AST_Assign
&& node.operator == "="
&& node.left instanceof AST_SymbolRef) {
var def = node.left.definition();
if (!(def.id in in_use_ids)
&& (drop_vars || !def.global)
&& self.variables.get(def.name) === def) {
return maintain_this_binding(tt.parent(), node, node.right.transform(tt));
}
if (n !== node) return n;
}
if (node instanceof AST_For) {
descend(node, this);
@@ -2218,7 +2217,8 @@ merge(Compressor.prototype, {
def(AST_This, return_null);
def(AST_Call, function(compressor, first_in_statement){
if (!this.has_pure_annotation(compressor) && compressor.pure_funcs(this)) {
if (this.expression instanceof AST_Function) {
if (this.expression instanceof AST_Function
&& (!this.expression.name || !this.expression.name.definition().references.length)) {
var node = this.clone();
node.expression = node.expression.process_expression(false);
return node;
@@ -2742,9 +2742,6 @@ merge(Compressor.prototype, {
if (compressor.option("unused")
&& def.references.length == 1
&& compressor.find_parent(AST_Scope) === def.scope) {
if (!compressor.option("keep_fnames")) {
exp.name = null;
}
self.expression = exp;
}
}