diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-05-19 11:51:06 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-05-19 11:51:06 -0700 |
commit | 4de2914fe17f3b3e169329ad35022e3ee124114a (patch) | |
tree | 3f994171e130aa749f6de6be6e8a93220216e188 | |
parent | 4ed0af723b235ae2504c65b6aaeb4b7c57fa435a (diff) |
fix emitsBoolean handling of conditional, and add handling of num
-rw-r--r-- | tools/js-optimizer.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 0cd27aa8..d89145d5 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -750,9 +750,12 @@ function simplifyExpressions(ast) { } function emitsBoolean(node) { + if (node[0] === 'num') { + return node[1] === 0 || node[1] === 1; + } if (node[0] === 'binary') return node[1] in COMPARE_OPS; if (node[0] === 'unary-prefix') return node[1] === '!'; - if (node[0] === 'conditional') return true; + if (node[0] === 'conditional') return emitsBoolean(node[2]) && emitsBoolean(node[3]); return false; } |