Class IfElseAsmGenerator


final class IfElseAsmGenerator extends AbstractControlFlowAsmGenerator
Specialized generator for EK9 if/else statements. Handles CONTROL_FLOW_CHAIN with chain_type: "IF_ELSE".

Supports: - Simple if (no else) - If with else - If/else if chains - If/else if/else chains

Stack Frame Invariant: All paths arrive at 'end' label with empty stack. Statement form has no result variable (unlike expression form which would).

  • Constructor Details

  • Method Details

    • generate

      public void generate(ControlFlowChainInstr instr)
      Generate bytecode for if/else statement.

      Bytecode Pattern:

      ; Evaluate first condition
      [condition evaluation instructions]
      load primitive_condition
      ifeq next_or_else_label    ; Branch if false
      [if body]
      goto end_label
      
      next_or_else_label:
      ; Either next condition or else block or fall through
      
      end_label:
      ; All paths converge here
      
      Parameters:
      instr - CONTROL_FLOW_CHAIN instruction with IF_ELSE type