if (compressor.option("dead_code")) {
statements = eliminate_dead_code(statements, compressor);
}
- if (compressor.option("sequences")) {
- statements = sequencesize(statements, compressor);
- }
if (compressor.option("if_return")) {
statements = handle_if_return(statements, compressor);
}
+ if (compressor.option("sequences")) {
+ statements = sequencesize(statements, compressor);
+ }
if (compressor.option("join_vars")) {
statements = join_consecutive_vars(statements, compressor);
}
def(AST_Statement, function(){
throw new Error("Cannot negate a statement");
});
+ def(AST_Function, function(){
+ return basic_negation(this);
+ });
def(AST_UnaryPrefix, function(){
if (this.operator == "!")
return this.expression;
});
})(function(node, func){
node.DEFMETHOD("negate", function(compressor){
- return func.call(this, compressor).optimize(compressor);
+ return func.call(this, compressor);
});
});
if (this.operator.length == 2) this.operator += "=";
}
break;
- case "&&":
- case "||":
- if (this.left instanceof AST_UnaryPrefix && this.left.operator == "!"
- && this.right instanceof AST_UnaryPrefix && this.right.operator == "!") {
- this.left = this.left.expression;
- this.right = this.right.expression;
- this.operator = this.operator == "&&" ? "||" : "&&";
- return make_node(AST_UnaryPrefix, this, {
- operator: "!",
- expression: this
- }).optimize(compressor);
- }
- break;
}
if (compressor.option("booleans") && compressor.in_boolean_context()) switch (this.operator) {
case "&&":
case "<": reverse(">"); break;
case "<=": reverse(">="); break;
}
+ if (!(compressor.parent() instanceof AST_Binary)) {
+ var negated = make_node(AST_UnaryPrefix, self, {
+ operator: "!",
+ expression: self.negate(compressor)
+ });
+ self = best_of(self, negated);
+ }
}
return self;
});