From 25f4ad4b45cb7ab4a3536efd21370fed3e2717cb Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Fri, 4 Apr 2014 11:10:29 +0400 Subject: [PATCH] Fixes bug that caused TeaVM compiler to freeze when compiling a certain bytecode sequence --- .../main/java/org/teavm/javascript/OptimizingVisitor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java b/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java index de5bf6203..00cc71819 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java +++ b/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java @@ -381,14 +381,16 @@ 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; } - --i; } } } else if (stmt instanceof BlockStatement) {