self.expression = best_of_expression(expression, self.expression);
}
if (compressor.option("dead_code")) {
- var blocks = Object.create(null);
+ var prev_block;
var decl = [];
var body = [];
var default_branch;
continue;
}
}
+ var case_side_effects = branch instanceof AST_Case && branch.expression.has_side_effects(compressor);
if (aborts(branch)) {
- var key = make_node(AST_BlockStatement, branch, branch).print_to_string();
- var block;
- if (!fallthrough && (block = blocks[key])) {
- block.body = [];
- body.splice(body.indexOf(block) + 1, 0, branch);
- } else {
- body.push(branch);
- }
+ var block = make_node(AST_BlockStatement, branch, branch).print_to_string();
+ if (!fallthrough && prev_block === block) body[body.length - 1].body = [];
+ body.push(branch);
+ prev_block = block;
fallthrough = false;
} else {
body.push(branch);
+ prev_block = null;
fallthrough = true;
}
- if (branch instanceof AST_Case && branch.expression.has_side_effects(compressor))
- blocks = Object.create(null);
- if (!fallthrough) blocks[key] = branch;
}
for (; i < len && fallthrough; i++) {
branch = self.body[i];
- if (branch instanceof AST_Case) {
- exact_match.body.push(make_node(AST_SimpleStatement, branch.expression, {
- body: branch.expression
- }));
- }
exact_match.body = exact_match.body.concat(branch.body);
fallthrough = !aborts(exact_match);
}
case 6:
return createExpression(recurmax) + ';';
case 7:
- return ';'; // TODO: disabled until some switch issues are resolved
// note: case args are actual expressions
// note: default does not _need_ to be last
return 'switch (' + createExpression(recurmax) + ') { ' + createSwitchParts(recurmax, 4) + '}';