@@ -4469,6 +4469,11 @@ merge(Compressor.prototype, {
|
|||||||
pop();
|
pop();
|
||||||
return true;
|
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) {
|
if (node instanceof AST_Conditional) {
|
||||||
node.condition.walk(tw);
|
node.condition.walk(tw);
|
||||||
push();
|
push();
|
||||||
@@ -4488,20 +4493,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (node instanceof AST_Continue) {
|
if (node instanceof AST_Continue) {
|
||||||
var target = tw.loopcontrol_target(node);
|
var target = tw.loopcontrol_target(node);
|
||||||
if (!(target instanceof AST_Do)) return true;
|
if (target instanceof AST_Do) 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;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Do) {
|
if (node instanceof AST_Do) {
|
||||||
@@ -4550,7 +4542,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (node instanceof AST_LabeledStatement) {
|
if (node instanceof AST_LabeledStatement) {
|
||||||
push();
|
push();
|
||||||
segment.block = node;
|
segment.block = node.body;
|
||||||
node.body.walk(tw);
|
node.body.walk(tw);
|
||||||
pop();
|
pop();
|
||||||
return true;
|
return true;
|
||||||
@@ -4587,6 +4579,7 @@ merge(Compressor.prototype, {
|
|||||||
segment = save;
|
segment = save;
|
||||||
node.body.forEach(function(branch) {
|
node.body.forEach(function(branch) {
|
||||||
push();
|
push();
|
||||||
|
segment.block = node;
|
||||||
walk_body(branch, tw);
|
walk_body(branch, tw);
|
||||||
pop();
|
pop();
|
||||||
});
|
});
|
||||||
@@ -4742,6 +4735,22 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function must_visit(base, segment) {
|
||||||
return base === segment || base.isPrototypeOf(segment);
|
return base === segment || base.isPrototypeOf(segment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3092,3 +3092,35 @@ issue_4237_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4253: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
switch (0) {
|
||||||
|
default:
|
||||||
|
var a = "FAIL";
|
||||||
|
a = a && a;
|
||||||
|
try {
|
||||||
|
break;
|
||||||
|
} catch (e) {}
|
||||||
|
var b = 42;
|
||||||
|
}
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (0) {
|
||||||
|
default:
|
||||||
|
var a = "FAIL";
|
||||||
|
a = a && a;
|
||||||
|
try {
|
||||||
|
break;
|
||||||
|
} catch (e) {}
|
||||||
|
var b = 42;
|
||||||
|
}
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user