builder.addStatement(new IfStatement(condition1, trueLabel, firstFalse, firstNA));
// first is true.
// set the result to true and do the next test
builder.addLabel(firstFalse);
builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(false))));
builder.addStatement(new GotoStatement(test2Label));
// first is NA
// set the result to NA and do the next test
builder.addLabel(firstNA);
builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(LogicalVector.NA))));
builder.addStatement(new GotoStatement(test2Label));
// check second condition
builder.addLabel(test2Label);
SimpleExpression condition2 = builder.translateSimpleExpression(context, call.getArgument(1));
builder.addStatement(new IfStatement(condition2,
trueLabel,
finishLabel, // if condition 2 is false, then the result is equal to condition1
naLabel));
builder.addLabel(trueLabel);
builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(true))));
builder.addStatement(new GotoStatement(finishLabel));
builder.addLabel(naLabel);
builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(LogicalVector.NA))));
builder.addLabel(finishLabel);
return result;
}