From c4f8c2103fd77e3a6666034c2ca19a5ef09fe68b Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Fri, 21 Sep 2012 11:23:44 +0300 Subject: [PATCH] more on detecting side effects --- lib/compress.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 834cc388..89352c00 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -690,6 +690,13 @@ function Compressor(options, false_by_default) { def(AST_Constant, function(){ return false }); def(AST_This, function(){ return false }); def(AST_Function, function(){ return false }); + def(AST_BlockStatement, function(){ + for (var i = this.body.length; --i >= 0;) { + if (this.body[i].has_side_effects()) + return true; + } + return false; + }); def(AST_SimpleStatement, function(){ return this.body.has_side_effects(); @@ -707,7 +714,8 @@ function Compressor(options, false_by_default) { def(AST_Unary, function(){ return this.operator == "delete" || this.operator == "++" - || this.operator == "--"; + || this.operator == "--" + || this.expression.has_side_effects(); }); def(AST_SymbolRef, function(){ return false }); def(AST_Object, function(){ @@ -732,6 +740,10 @@ function Compressor(options, false_by_default) { return this.expression.has_side_effects() || this.property.has_side_effects(); }); + def(AST_Seq, function(){ + return this.car.has_side_effects() + || this.cdr.has_side_effects(); + }); })(function(node, func){ node.DEFMETHOD("has_side_effects", func); }); -- 2.34.1