mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
Fix bug in AST optimization
This commit is contained in:
parent
1200354a7b
commit
a7ac256c47
|
@ -119,15 +119,21 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expr.getSecondOperand().acceptVisitor(this);
|
Expr b = expr.getSecondOperand();
|
||||||
Expr b = resultExpr;
|
Expr a = expr.getFirstOperand();
|
||||||
if (b instanceof ConstantExpr && expr.getOperation() == BinaryOperation.SUBTRACT) {
|
|
||||||
if (tryMakePositive((ConstantExpr) b)) {
|
if (a instanceof VariableExpr || a instanceof ConstantExpr) {
|
||||||
expr.setOperation(BinaryOperation.ADD);
|
b.acceptVisitor(this);
|
||||||
|
b = resultExpr;
|
||||||
|
if (b instanceof ConstantExpr && expr.getOperation() == BinaryOperation.SUBTRACT) {
|
||||||
|
if (tryMakePositive((ConstantExpr) b)) {
|
||||||
|
expr.setOperation(BinaryOperation.ADD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
a.acceptVisitor(this);
|
||||||
|
a = resultExpr;
|
||||||
}
|
}
|
||||||
expr.getFirstOperand().acceptVisitor(this);
|
|
||||||
Expr a = resultExpr;
|
|
||||||
Expr p = a;
|
Expr p = a;
|
||||||
Expr q = b;
|
Expr q = b;
|
||||||
boolean invert = false;
|
boolean invert = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user