aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-08 17:03:09 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-08 22:51:59 +0300
commit1c8ba35844f4032fd9f12961a0feee1a78153aa3 (patch)
tree7fb61dc8a14c141fad11d5b6bed910a3889d815a
parent5a8e6ce735f6fbdf32fc730735843b225424e357 (diff)
downloadtracifyjs-1c8ba35844f4032fd9f12961a0feee1a78153aa3.tar.gz
tracifyjs-1c8ba35844f4032fd9f12961a0feee1a78153aa3.zip
minor
-rw-r--r--lib/compress.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 953fd901..3ce06298 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -166,6 +166,7 @@ function Compressor(options, false_by_default) {
};
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);
@@ -579,11 +580,12 @@ function Compressor(options, false_by_default) {
});
} 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;
@@ -605,20 +607,20 @@ function Compressor(options, false_by_default) {
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 });
}
}
}
@@ -675,7 +677,6 @@ function Compressor(options, false_by_default) {
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);
@@ -684,7 +685,6 @@ function Compressor(options, false_by_default) {
} 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);