Removes inlining of variable's values into && and || expression, as it

sometimes can violate evaluation order. Fixes creation of arrays of
arrays of primitives.
This commit is contained in:
Alexey Andreev 2014-03-27 15:48:34 +04:00
parent bf68cf4b7d
commit 2f2985bb10
2 changed files with 8 additions and 3 deletions

View File

@ -45,6 +45,14 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
@Override
public void visit(BinaryExpr expr) {
switch (expr.getOperation()) {
case AND:
case OR:
resultExpr = expr;
return;
default:
break;
}
expr.getSecondOperand().acceptVisitor(this);
Expr b = resultExpr;
expr.getFirstOperand().acceptVisitor(this);

View File

@ -1149,9 +1149,6 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
public void visit(NewArrayExpr expr) {
try {
ValueType type = expr.getType();
while (type instanceof ValueType.Array) {
type = ((ValueType.Array)type).getItemType();
}
if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) {
case BOOLEAN: