function tighten_body(statements, compressor) {
var scope = compressor.find_parent(AST_Scope);
- var in_loop = is_in_loop();
+ var in_loop = is_in_node(AST_IterationStatement);
var CHANGED, max_iter = 10;
do {
CHANGED = false;
}
} while (CHANGED && max_iter-- > 0);
- function is_in_loop() {
+ function is_in_node(type) {
+ if (compressor.self() instanceof type) return true;
for (var node, level = 0; node = compressor.parent(level); level++) {
- if (node instanceof AST_IterationStatement) return true;
+ if (node instanceof type) return true;
if (node instanceof AST_Scope) break;
}
return false;
if (scope.uses_eval || scope.uses_with) return statements;
var args;
var candidates = [];
- var in_try = compressor.self() instanceof AST_Try;
+ var in_try = is_in_node(AST_Try);
var stat_index = statements.length;
var scanner = new TreeTransformer(function(node, descend) {
if (abort) return node;