aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-10-30 10:45:58 +0200
committerMihai Bazon <mihai@bazon.net>2013-10-30 10:45:58 +0200
commitb70670b69fbc3badd6186d6a6671754976bd36cb (patch)
treece718f65540d1899fa249b682af8de0a821fba61 /lib
parent9dd97605bc724c78b7f73177ae8ceaee92cc01d2 (diff)
downloadtracifyjs-b70670b69fbc3badd6186d6a6671754976bd36cb.tar.gz
tracifyjs-b70670b69fbc3badd6186d6a6671754976bd36cb.zip
Fix regression after e4c530240650535d1cb46569dfb013193471af05
`x * (y * z)` ==> `x * y * z` -- the better place to do this is in the compressor rather than codegen.
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 813561c4..0bbd24ee 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2089,6 +2089,19 @@ merge(Compressor.prototype, {
}
}
}
+ // x * (y * z) ==> x * y * z
+ if (self.right instanceof AST_Binary
+ && self.right.operator == self.operator
+ && (self.operator == "*" || self.operator == "&&" || self.operator == "||"))
+ {
+ self.left = make_node(AST_Binary, self.left, {
+ operator : self.operator,
+ left : self.left,
+ right : self.right.left
+ });
+ self.right = self.right.right;
+ return self.transform(compressor);
+ }
return self.evaluate(compressor)[0];
});