/*
* Remove any dead statements after an abrupt change in code flow and
* promote safe statements within nested blocks to this block.
*/
for (int i = 0; i < x.statements.size(); i++) {
JStatement stmt = x.statements.get(i);
if (stmt instanceof JBlock) {
/*
* Promote a sub-block's children to the current block, unless the
* sub-block contains local declarations as children.
*/
JBlock block = (JBlock) stmt;
if (canPromoteBlock(block)) {
x.statements.remove(i);
x.statements.addAll(i, block.statements);
i--;
didChange = true;
continue;
}
}
if (stmt.unconditionalControlBreak()) {
// Abrupt change in flow, chop the remaining items from this block
for (int j = i + 1; j < x.statements.size();) {
x.statements.remove(j);
didChange = true;
}