aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-23 17:52:54 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-23 17:52:54 -0800
commit5f00b61350b9236c36e81dafd5e8e3a9c93b347e (patch)
tree37cb321037e3dc0145a48024c4e64239ee684173 /tools
parentb86abc2ecfea9ccbb93cad2fe4e9f8574beb7ed8 (diff)
don't get confused by temporary empty nodes when calculating assigns in the loop variable optimizer
Diffstat (limited to 'tools')
-rw-r--r--tools/js-optimizer.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 6e82451c..587221a6 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -271,6 +271,16 @@ function isEmptyNode(node) {
return node.length === 2 && node[0] === 'toplevel' && node[1].length === 0;
}
+function clearEmptyNodes(list) {
+ for (var i = 0; i < list.length;) {
+ if (isEmptyNode(list[i]) || (list[i][0] === 'stat' && isEmptyNode(list[i][1]))) {
+ list.splice(i, 1);
+ } else {
+ i++;
+ }
+ }
+}
+
// Passes
// Dump the AST. Useful for debugging. For example,
@@ -2692,6 +2702,7 @@ function eliminate(ast, memSafe) {
}
if (ifTrue[1][0] && ifTrue[1][0][0] === 'break') {
var assigns = ifFalse[1];
+ clearEmptyNodes(assigns);
var loopers = [], helpers = [];
for (var i = 0; i < assigns.length; i++) {
if (assigns[i][0] === 'stat' && assigns[i][1][0] === 'assign') {