Fixes bug that caused TeaVM compiler to freeze when compiling a certain

bytecode sequence
This commit is contained in:
konsoletyper 2014-04-04 11:10:29 +04:00
parent 99c9617834
commit 25f4ad4b45

View File

@ -381,16 +381,18 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
cond.getConsequent().addAll(innerCond.getConsequent());
cond.setCondition(Expr.binary(BinaryOperation.AND, cond.getCondition(),
innerCond.getCondition()));
} else {
--i;
} else if (cond.getAlternative().size() != 1 ||
!(cond.getAlternative().get(0) instanceof ConditionalStatement)) {
cond.setCondition(ExprOptimizer.invert(cond.getCondition()));
cond.getConsequent().clear();
cond.getConsequent().addAll(cond.getAlternative());
cond.getAlternative().clear();
cond.getAlternative().add(innerCond);
}
--i;
}
}
}
} else if (stmt instanceof BlockStatement) {
BlockStatement nestedBlock = (BlockStatement)stmt;
eliminateRedundantBreaks(nestedBlock.getBody(), nestedBlock);