exp.left.definition().bool_fn++;
}
});
- def(AST_Case, function(tw) {
- push(tw);
- this.expression.walk(tw);
- pop(tw);
- push(tw);
- walk_body(this, tw);
- pop(tw);
- return true;
- });
def(AST_Conditional, function(tw) {
this.condition.walk(tw);
push(tw);
pop(tw);
return true;
});
- def(AST_Default, function(tw, descend) {
- push(tw);
- descend();
- pop(tw);
- return true;
- });
def(AST_Defun, function(tw, descend, compressor) {
var id = this.name.definition().id;
if (tw.defun_visited[id]) return true;
pop(tw);
return true;
});
+ def(AST_Switch, function(tw) {
+ this.expression.walk(tw);
+ var first = true;
+ this.body.forEach(function(branch) {
+ if (branch instanceof AST_Default) return;
+ branch.expression.walk(tw);
+ if (first) {
+ first = false;
+ push(tw);
+ }
+ })
+ if (!first) pop(tw);
+ walk_body(this, tw);
+ return true;
+ });
+ def(AST_SwitchBranch, function(tw) {
+ push(tw);
+ walk_body(this, tw);
+ pop(tw);
+ return true;
+ });
def(AST_SymbolCatch, function() {
this.definition().fixed = false;
});
if (!compressor.option("merge_vars")) return;
var self = this, segment = null;
var first = [], last = [], index = 0;
- var declarations = Object.create(null);
+ var declarations = new Dictionary();
var references = Object.create(null);
var prev = Object.create(null);
var tw = new TreeWalker(function(node, descend) {
}
if (node instanceof AST_Switch) {
node.expression.walk(tw);
- var first = true;
+ var save = segment;
node.body.forEach(function(branch) {
if (branch instanceof AST_Default) return;
- if (!first) push();
branch.expression.walk(tw);
- if (!first) pop();
- first = false;
+ if (save === segment) push();
});
+ segment = save;
node.body.forEach(function(branch) {
push();
- branch.body.forEach(function(stat) {
- stat.walk(tw);
- });
+ walk_body(branch, tw);
pop();
});
return true;
}
if (node instanceof AST_Try) {
push();
- node.body.forEach(function(stat) {
- stat.walk(tw);
- });
+ walk_body(node, tw);
pop();
if (node.bcatch) {
references[node.bcatch.argname.definition().id] = false;
push();
- node.bcatch.body.forEach(function(stat) {
- stat.walk(tw);
- });
+ walk_body(node.bcatch, tw);
pop();
}
if (node.bfinally) node.bfinally.walk(tw);
node.value.walk(tw);
mark(node.name, true);
} else {
- var id = node.name.definition().id;
- if (!(id in declarations)) declarations[id] = [];
- declarations[id].push(node.name);
+ declarations.add(node.name.definition().id, node.name);
}
return true;
}
continue;
}
var orig = [], refs = [];
- if (id in declarations) declarations[id].forEach(function(sym) {
+ if (declarations.has(id)) declarations.get(id).forEach(function(sym) {
sym.thedef = def;
sym.name = def.name;
orig.push(sym);