use of org.wso2.ballerinalang.programfile.Instruction in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangWhile whileNode) {
Instruction gotoTopJumpInstr = InstructionFactory.get(InstructionCodes.GOTO, getOperand(this.nextIP()));
this.genNode(whileNode.expr, this.env);
Operand exitLoopJumpAddr = getOperand(-1);
Instruction exitLoopJumpInstr = InstructionFactory.get(InstructionCodes.GOTO, exitLoopJumpAddr);
emit(InstructionCodes.BR_FALSE, whileNode.expr.regIndex, exitLoopJumpAddr);
this.loopResetInstructionStack.push(gotoTopJumpInstr);
this.loopExitInstructionStack.push(exitLoopJumpInstr);
this.genNode(whileNode.body, this.env);
this.loopResetInstructionStack.pop();
this.loopExitInstructionStack.pop();
this.emit(gotoTopJumpInstr);
exitLoopJumpAddr.value = nextIP();
}
Aggregations