diff options
-rw-r--r-- | lib/compress.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 7faf2df5..06b133f9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -478,6 +478,7 @@ function Compressor(options, false_by_default) { return this.left.has_side_effects() || this.right.has_side_effects (); }); + def(AST_Assign, function(){ return true }); def(AST_Conditional, function(){ return this.condition.has_side_effects() || this.consequent.has_side_effects() @@ -488,6 +489,7 @@ function Compressor(options, false_by_default) { || this.operator == "++" || this.operator == "--"; }); + def(AST_SymbolRef, function(){ return false }); })(function(node, func){ node.DEFMETHOD("has_side_effects", func); }); @@ -1100,7 +1102,25 @@ function Compressor(options, false_by_default) { } break; } - return this.evaluate(compressor)[0]; + var exp = this.evaluate(compressor); + if (exp.length == 2) { + if (best_of(exp[0], this) !== this) + return exp[0]; + } + var self = this; + if (compressor.option("comparations")) { + var reverse = function(op) { + self.operator = op; + var tmp = self.left; + self.left = self.right; + self.right = tmp; + }; + if (self instanceof AST_Binary) switch (self.operator) { + case "<": reverse(">"); break; + case "<=": reverse(">="); break; + } + } + return self; }); SQUEEZE(AST_Assign, function(self, compressor){ |