public HoldingContainer visitIfExpression(IfExpression ifExpr, ClassGenerator<?> generator) throws RuntimeException {
JBlock local = generator.getEvalBlock();
HoldingContainer output = generator.declare(ifExpr.getMajorType());
JConditional jc = null;
JBlock conditionalBlock = new JBlock(false, false);
IfCondition c = ifExpr.ifCondition;
HoldingContainer holdingContainer = c.condition.accept(this, generator);
if (jc == null) {
if (holdingContainer.isOptional()) {
jc = conditionalBlock._if(holdingContainer.getIsSet().eq(JExpr.lit(1)).cand(holdingContainer.getValue().eq(JExpr.lit(1))));
} else {
jc = conditionalBlock._if(holdingContainer.getValue().eq(JExpr.lit(1)));
}
} else {
if (holdingContainer.isOptional()) {
jc = jc._else()._if(holdingContainer.getIsSet().eq(JExpr.lit(1)).cand(holdingContainer.getValue().eq(JExpr.lit(1))));
} else {
jc = jc._else()._if(holdingContainer.getValue().eq(JExpr.lit(1)));
}
}
generator.nestEvalBlock(jc._then());
HoldingContainer thenExpr = c.expression.accept(this, generator);
generator.unNestEvalBlock();
if (thenExpr.isOptional()) {
JConditional newCond = jc._then()._if(thenExpr.getIsSet().ne(JExpr.lit(0)));
JBlock b = newCond._then();
b.assign(output.getHolder(), thenExpr.getHolder());
//b.assign(output.getIsSet(), thenExpr.getIsSet());
} else {
jc._then().assign(output.getHolder(), thenExpr.getHolder());
}
generator.nestEvalBlock(jc._else());
HoldingContainer elseExpr = ifExpr.elseExpression.accept(this, generator);
generator.unNestEvalBlock();
if (elseExpr.isOptional()) {
JConditional newCond = jc._else()._if(elseExpr.getIsSet().ne(JExpr.lit(0)));
JBlock b = newCond._then();
b.assign(output.getHolder(), elseExpr.getHolder());
//b.assign(output.getIsSet(), elseExpr.getIsSet());
} else {
jc._else().assign(output.getHolder(), elseExpr.getHolder());
}