minor AST cleanup (AST_BlockStatement may inherit from AST_Block)

This commit is contained in:
Mihai Bazon
2012-10-09 13:52:32 +03:00
parent e1862cd36f
commit 9ead49641d
3 changed files with 17 additions and 30 deletions

View File

@@ -682,15 +682,13 @@ merge(Compressor.prototype, {
def(AST_Constant, function(){ return false });
def(AST_This, function(){ return false });
function block(){
def(AST_Block, function(){
for (var i = this.body.length; --i >= 0;) {
if (this.body[i].has_side_effects())
return true;
}
return false;
};
def(AST_Block, block);
def(AST_BlockStatement, block);
});
def(AST_SimpleStatement, function(){
if (this.body instanceof AST_Function) return false;
@@ -780,6 +778,11 @@ merge(Compressor.prototype, {
return self.label.references.length == 0 ? self.body : self;
});
OPT(AST_Block, function(self, compressor){
self.body = tighten_body(self.body, compressor);
return self;
});
OPT(AST_BlockStatement, function(self, compressor){
self.body = tighten_body(self.body, compressor);
switch (self.body.length) {
@@ -789,11 +792,6 @@ merge(Compressor.prototype, {
return self;
});
OPT(AST_Block, function(self, compressor){
self.body = tighten_body(self.body, compressor);
return self;
});
AST_Scope.DEFMETHOD("drop_unused", function(compressor){
var self = this;
if (compressor.option("unused")