diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-09-21 11:23:44 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-09-21 11:23:44 +0300 |
commit | c4f8c2103fd77e3a6666034c2ca19a5ef09fe68b (patch) | |
tree | 4b76d69d3daef5dedae674338b7b00eaa8afd943 | |
parent | e8da72d304778cdaf4570f24838effee73f6b993 (diff) | |
download | tracifyjs-c4f8c2103fd77e3a6666034c2ca19a5ef09fe68b.tar.gz tracifyjs-c4f8c2103fd77e3a6666034c2ca19a5ef09fe68b.zip |
more on detecting side effects
-rw-r--r-- | lib/compress.js | 14 |
1 files changed, 13 insertions, 1 deletions
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); }); |