/** * Generates a sequence of bytescodes * * @param code the code list */ public void genCode(GenerationContext context) { CodeSequence code = context.getCodeSequence(); setLineNumber(code); code.pushContext(this); if (cond.isConstant() && cond.booleanValue()) { // while (true) code.plantLabel(getContinueLabel()); // body: LocalVariableScope scope = new LocalVariableScope(); code.pushLocalVariableScope(scope); body.genCode(context); // BODY CODE code.popLocalVariableScope(scope); code.plantJumpInstruction(opc_goto, getContinueLabel()); // GOTO body } else { CodeLabel bodyLabel = new CodeLabel(); code.plantJumpInstruction(opc_goto, getContinueLabel()); // GOTO cont code.plantLabel(bodyLabel); // body: LocalVariableScope scope = new LocalVariableScope(); code.pushLocalVariableScope(scope); body.genCode(context); // BODY CODE code.popLocalVariableScope(scope); code.plantLabel(getContinueLabel()); // cont: cond.genBranch(true, context, bodyLabel); // EXPR CODE; IFNE body } code.plantLabel(getBreakLabel()); // end: ... code.popContext(this); }