JS: transfer all empty statement simplifications RedundantLabelRemoval to EmptyStatementElimination, so that empty statements can be eliminated everywhere, not in labeled blocks only.

This commit is contained in:
Alexey Andreev
2017-01-19 18:53:56 +03:00
parent ac0df8eef9
commit c1838d423b
10 changed files with 148 additions and 87 deletions
@@ -0,0 +1,3 @@
function box() {
return "OK";
}
@@ -0,0 +1,20 @@
function box() {
{}
{
{}
{}
}
var $x = "OK";
if ($x == "123") {}
else if ($x == "234") {} else {}
if ($x == "qwe") {}
switch ($x) {
case 1:
case 2:
default:
}
return $x;
}
@@ -0,0 +1,17 @@
var global = "";
function id(value) {
global += value + ";";
return value;
}
function test(x) {
id(x);
id(x + 1);
}
function box() {
test(23);
if (global != "23;24;") return "fail";
return "OK";
}
@@ -0,0 +1,23 @@
var global = "";
function id(value) {
global += value + ";";
return value;
}
function test(x) {
$outer: {
if (id(x) + id(x + 1) > 0) {
break $outer;
}
else {
break $outer;
}
}
}
function box() {
test(23);
if (global != "23;24;") return "fail";
return "OK";
}
@@ -0,0 +1,7 @@
function test(x) {
return "OK";
}
function box() {
return test(23);
}
@@ -0,0 +1,12 @@
function test(x) {
$outer: {
if (x > 10) {
break $outer;
}
}
return "OK";
}
function box() {
return test(23);
}