};
function extract_declarations_from_unreachable_code(compressor, stat, target) {
+ warn_dead_code(stat);
stat.walk(new TreeWalker(function(node){
if (node instanceof AST_Definitions || node instanceof AST_Defun) {
compressor.warn("Declarations in unreachable code! [{line},{col}]", node.start);
});
} else if (self instanceof AST_While) {
if (compressor.option("dead_code")) {
- warn_dead_code(self);
var a = [];
extract_declarations_from_unreachable_code(compressor, self.body, a);
return make_node(AST_BlockStatement, self, { body: a });
}
+ } else {
+ return self.body;
}
}
return self;
this.condition = cond[0];
}
if (!compressor.option("loops")) return this;
- if (this.condition) {
- var cond = this.condition.evaluate(compressor);
+ if (cond) {
if (cond.length == 2 && !cond[1]) {
if (compressor.option("dead_code")) {
- warn_dead_code(this.body);
var a = [];
- if (this.init instanceof AST_Statement) a.push(this.init);
- else if (this.init) a.push(make_node(AST_SimpleStatement, this.init, {
- body: this.init
- }));
+ if (this.init instanceof AST_Statement) {
+ a.push(this.init);
+ }
+ else if (this.init) {
+ a.push(make_node(AST_SimpleStatement, this.init, {
+ body: this.init
+ }));
+ }
extract_declarations_from_unreachable_code(compressor, this.body, a);
- return make_node(AST_BlockStatement, this, {
- body: a
- });
+ return make_node(AST_BlockStatement, this, { body: a });
}
}
}
if (compressor.option("dead_code")) {
var a = [];
if (self.alternative) {
- warn_dead_code(self.alternative);
extract_declarations_from_unreachable_code(compressor, self.alternative, a);
}
a.push(self.body);
} else {
AST_Node.warn("Condition always false [{line},{col}]", self.condition.start);
if (compressor.option("dead_code")) {
- warn_dead_code(self.body);
var a = [];
extract_declarations_from_unreachable_code(compressor, self.body, a);
if (self.alternative) a.push(self.alternative);