Node actualCondition = skipOverNewlines(s, ifNode.getCondition());
Variable result = s.getNewTemporaryVariable();
Label falseLabel = s.getNewLabel();
Label doneLabel = s.getNewLabel();
Operand thenResult = null;
s.addInstr(new BEQInstr(build(actualCondition, s), BooleanLiteral.FALSE, falseLabel));
boolean thenNull = false;
boolean elseNull = false;
boolean thenUnil = false;
boolean elseUnil = false;
// Build the then part of the if-statement
if (ifNode.getThenBody() != null) {
thenResult = build(ifNode.getThenBody(), s);
if (thenResult != U_NIL) { // thenResult can be U_NIL if then-body ended with a return!
// Local optimization of break results to short-circuit the jump right away
// rather than wait to do it during an optimization pass.
Label tgt = doneLabel;
if (thenResult instanceof BreakResult) {
BreakResult br = (BreakResult)thenResult;
thenResult = br._result;
tgt = br._jumpTarget;
}
s.addInstr(new CopyInstr(result, thenResult));
s.addInstr(new JumpInstr(tgt));
}
else {
thenUnil = true;
}
}
else {
thenNull = true;
s.addInstr(new CopyInstr(result, Nil.NIL));
s.addInstr(new JumpInstr(doneLabel));
}
// Build the else part of the if-statement
s.addInstr(new LABEL_Instr(falseLabel));
if (ifNode.getElseBody() != null) {
Operand elseResult = build(ifNode.getElseBody(), s);
// elseResult can be U_NIL if then-body ended with a return!
if (elseResult != U_NIL) {
s.addInstr(new CopyInstr(result, elseResult));
}
else {