@@ -4466,34 +4466,6 @@ merge(Compressor.prototype, {
|
||||
def(AST_Statement, function() {
|
||||
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) {
|
||||
var self = this.clone(), op = this.operator;
|
||||
if (compressor.option("unsafe_comps")) {
|
||||
@@ -4522,6 +4494,25 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
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) {
|
||||
node.DEFMETHOD("negate", function(compressor, first_in_statement) {
|
||||
return func.call(this, compressor, first_in_statement);
|
||||
|
||||
Reference in New Issue
Block a user