@@ -4466,34 +4466,6 @@ merge(Compressor.prototype, {
|
|||||||
def(AST_Statement, function() {
|
def(AST_Statement, function() {
|
||||||
throw new Error("Cannot negate a statement");
|
throw new Error("Cannot negate a statement");
|
||||||
});
|
});
|
||||||
def(AST_Arrow, function() {
|
|
||||||
return basic_negation(this);
|
|
||||||
});
|
|
||||||
def(AST_AsyncArrow, function() {
|
|
||||||
return basic_negation(this);
|
|
||||||
});
|
|
||||||
def(AST_AsyncFunction, function() {
|
|
||||||
return basic_negation(this);
|
|
||||||
});
|
|
||||||
def(AST_Function, function() {
|
|
||||||
return basic_negation(this);
|
|
||||||
});
|
|
||||||
def(AST_UnaryPrefix, function() {
|
|
||||||
if (this.operator == "!")
|
|
||||||
return this.expression;
|
|
||||||
return basic_negation(this);
|
|
||||||
});
|
|
||||||
def(AST_Sequence, function(compressor) {
|
|
||||||
var expressions = this.expressions.slice();
|
|
||||||
expressions.push(expressions.pop().negate(compressor));
|
|
||||||
return make_sequence(this, expressions);
|
|
||||||
});
|
|
||||||
def(AST_Conditional, function(compressor, first_in_statement) {
|
|
||||||
var self = this.clone();
|
|
||||||
self.consequent = self.consequent.negate(compressor);
|
|
||||||
self.alternative = self.alternative.negate(compressor);
|
|
||||||
return best(this, self, first_in_statement);
|
|
||||||
});
|
|
||||||
def(AST_Binary, function(compressor, first_in_statement) {
|
def(AST_Binary, function(compressor, first_in_statement) {
|
||||||
var self = this.clone(), op = this.operator;
|
var self = this.clone(), op = this.operator;
|
||||||
if (compressor.option("unsafe_comps")) {
|
if (compressor.option("unsafe_comps")) {
|
||||||
@@ -4522,6 +4494,25 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
return basic_negation(this);
|
return basic_negation(this);
|
||||||
});
|
});
|
||||||
|
def(AST_Conditional, function(compressor, first_in_statement) {
|
||||||
|
var self = this.clone();
|
||||||
|
self.consequent = self.consequent.negate(compressor);
|
||||||
|
self.alternative = self.alternative.negate(compressor);
|
||||||
|
return best(this, self, first_in_statement);
|
||||||
|
});
|
||||||
|
def(AST_LambdaExpression, function() {
|
||||||
|
return basic_negation(this);
|
||||||
|
});
|
||||||
|
def(AST_Sequence, function(compressor) {
|
||||||
|
var expressions = this.expressions.slice();
|
||||||
|
expressions.push(expressions.pop().negate(compressor));
|
||||||
|
return make_sequence(this, expressions);
|
||||||
|
});
|
||||||
|
def(AST_UnaryPrefix, function() {
|
||||||
|
if (this.operator == "!")
|
||||||
|
return this.expression;
|
||||||
|
return basic_negation(this);
|
||||||
|
});
|
||||||
})(function(node, func) {
|
})(function(node, func) {
|
||||||
node.DEFMETHOD("negate", function(compressor, first_in_statement) {
|
node.DEFMETHOD("negate", function(compressor, first_in_statement) {
|
||||||
return func.call(this, compressor, first_in_statement);
|
return func.call(this, compressor, first_in_statement);
|
||||||
|
|||||||
@@ -587,3 +587,18 @@ issue_4618: {
|
|||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4623: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
if (console ? function*() {} : 0)
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(console ? function*() {} : 0) && console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user