* Remove any dead statements after an abrupt change in code flow and
* promote safe statements within nested blocks to this block.
*/
List<JsStatement> stmts = x.getStatements();
for (int i = 0; i < stmts.size(); i++) {
JsStatement stmt = stmts.get(i);
if (stmt instanceof JsBlock) {
// Promote a sub-block's children to the current block.
JsBlock block = (JsBlock) stmt;
stmts.remove(i);
stmts.addAll(i, block.getStatements());
i--;
didChange = true;
continue;
}
if (!stmt.unconditionalControlBreak()) {
continue;
}
// Abrupt change in flow, chop the remaining items from this block
for (int j = i + 1; j < stmts.size();) {
JsStatement toRemove = stmts.get(j);
JsStatement toReplace = ensureDeclarations(toRemove);
if (toReplace == null) {
stmts.remove(j);
didChange = true;
} else if (toReplace == toRemove) {
++j;