Class WhileLoopAsmGenerator


final class WhileLoopAsmGenerator extends AbstractControlFlowAsmGenerator
Specialized generator for EK9 while loops. Handles CONTROL_FLOW_CHAIN with chain_type: "WHILE_LOOP".

JVM Bytecode Pattern:

loop_start:
  [condition evaluation]
  iload primitive_condition
  ifeq loop_end              ; Exit if false
  [body instructions]
  goto loop_start            ; Iterate again
loop_end:

Stack Frame Invariant: Stack is empty before loop, after condition, after body, and after loop exit.

  • Constructor Details

  • Method Details

    • generate

      public void generate(ControlFlowChainInstr instr)
      Generate bytecode for while loop.

      Control Flow:

      1. Place loop start label
      2. Evaluate condition (leaves stack empty)
      3. Branch to loop end if condition is false
      4. Execute body (leaves stack empty)
      5. Jump back to loop start
      6. Place loop end label

      Stack Frame Invariant: Pre-condition: stack is empty Post-condition: stack is empty

      Parameters:
      instr - CONTROL_FLOW_CHAIN instruction with WHILE_LOOP type