more on detecting side effects
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user