@@ -1429,6 +1429,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var identifier_atom = makePredicate("Infinity NaN undefined");
|
||||||
function is_lhs_read_only(lhs, compressor) {
|
function is_lhs_read_only(lhs, compressor) {
|
||||||
if (lhs instanceof AST_ObjectIdentity) return true;
|
if (lhs instanceof AST_ObjectIdentity) return true;
|
||||||
if (lhs instanceof AST_PropAccess) {
|
if (lhs instanceof AST_PropAccess) {
|
||||||
@@ -1616,13 +1617,6 @@ merge(Compressor.prototype, {
|
|||||||
|| compressor.option("unsafe") && global_names[this.name];
|
|| compressor.option("unsafe") && global_names[this.name];
|
||||||
});
|
});
|
||||||
|
|
||||||
var identifier_atom = makePredicate("Infinity NaN undefined");
|
|
||||||
function is_identifier_atom(node) {
|
|
||||||
return node instanceof AST_Infinity
|
|
||||||
|| node instanceof AST_NaN
|
|
||||||
|| node instanceof AST_Undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function declarations_only(node) {
|
function declarations_only(node) {
|
||||||
return all(node.definitions, function(var_def) {
|
return all(node.definitions, function(var_def) {
|
||||||
return !var_def.value;
|
return !var_def.value;
|
||||||
@@ -9438,11 +9432,7 @@ merge(Compressor.prototype, {
|
|||||||
OPT(AST_UnaryPrefix, function(self, compressor) {
|
OPT(AST_UnaryPrefix, function(self, compressor) {
|
||||||
var op = self.operator;
|
var op = self.operator;
|
||||||
var exp = self.expression;
|
var exp = self.expression;
|
||||||
if (compressor.option("evaluate")
|
if (compressor.option("evaluate") && op == "delete" && !may_not_delete(exp)) {
|
||||||
&& op == "delete"
|
|
||||||
&& !(exp instanceof AST_SymbolRef
|
|
||||||
|| exp instanceof AST_PropAccess
|
|
||||||
|| is_identifier_atom(exp))) {
|
|
||||||
return make_sequence(self, [ exp, make_node(AST_True, self) ]).optimize(compressor);
|
return make_sequence(self, [ exp, make_node(AST_True, self) ]).optimize(compressor);
|
||||||
}
|
}
|
||||||
if (compressor.option("sequences") && can_lift()) {
|
if (compressor.option("sequences") && can_lift()) {
|
||||||
@@ -9496,10 +9486,19 @@ merge(Compressor.prototype, {
|
|||||||
return op == "-" && (exp instanceof AST_Number || exp instanceof AST_Infinity)
|
return op == "-" && (exp instanceof AST_Number || exp instanceof AST_Infinity)
|
||||||
? self : try_evaluate(compressor, self);
|
? self : try_evaluate(compressor, self);
|
||||||
|
|
||||||
|
function may_not_delete(node) {
|
||||||
|
return node instanceof AST_Infinity
|
||||||
|
|| node instanceof AST_NaN
|
||||||
|
|| node instanceof AST_NewTarget
|
||||||
|
|| node instanceof AST_PropAccess
|
||||||
|
|| node instanceof AST_SymbolRef
|
||||||
|
|| node instanceof AST_Undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function can_lift() {
|
function can_lift() {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case "delete":
|
case "delete":
|
||||||
return !is_identifier_atom(exp.tail_node());
|
return !may_not_delete(exp.tail_node());
|
||||||
case "typeof":
|
case "typeof":
|
||||||
return !is_undeclared_ref(exp.tail_node());
|
return !is_undeclared_ref(exp.tail_node());
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5851,6 +5851,24 @@ new_target_collapse_vars: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_target_delete: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
new function() {
|
||||||
|
console.log(delete new.target);
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
new function() {
|
||||||
|
console.log(delete new.target);
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
new_target_reduce_vars: {
|
new_target_reduce_vars: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user