pop();
return true;
}
+ if (node instanceof AST_Break) {
+ var target = tw.loopcontrol_target(node);
+ if (!(target instanceof AST_IterationStatement)) insert(target);
+ return true;
+ }
if (node instanceof AST_Conditional) {
node.condition.walk(tw);
push();
}
if (node instanceof AST_Continue) {
var target = tw.loopcontrol_target(node);
- if (!(target instanceof AST_Do)) return true;
- var stack = [];
- while (!HOP(segment, "block") || segment.block !== target) {
- stack.push(segment);
- pop();
- }
- segment.loop = "c";
- push();
- while (stack.length) {
- var seg = stack.pop();
- push();
- if (HOP(seg, "block")) segment.block = seg.block;
- if (HOP(seg, "loop")) segment.loop = seg.loop;
- }
+ if (target instanceof AST_Do) insert(target);
return true;
}
if (node instanceof AST_Do) {
}
if (node instanceof AST_LabeledStatement) {
push();
- segment.block = node;
+ segment.block = node.body;
node.body.walk(tw);
pop();
return true;
segment = save;
node.body.forEach(function(branch) {
push();
+ segment.block = node;
walk_body(branch, tw);
pop();
});
});
}
+ function insert(target) {
+ var stack = [];
+ while (!HOP(segment, "block") || segment.block !== target) {
+ stack.push(segment);
+ pop();
+ }
+ segment.loop = "c";
+ push();
+ while (stack.length) {
+ var seg = stack.pop();
+ push();
+ if (HOP(seg, "block")) segment.block = seg.block;
+ if (HOP(seg, "loop")) segment.loop = seg.loop;
+ }
+ }
+
function must_visit(base, segment) {
return base === segment || base.isPrototypeOf(segment);
}