Class GuardedAssignmentAsmGenerator


final class GuardedAssignmentAsmGenerator extends AbstractControlFlowAsmGenerator
Specialized generator for EK9 guarded assignment (:=?). Handles CONTROL_FLOW_CHAIN with chain_type: "GUARDED_ASSIGNMENT".

EK9 Guarded Assignment Pattern: variable :=? value

  • Assigns value to variable only if variable is null or not set
  • Prevents overwriting already-initialized variables
  • Useful for default value initialization

Generates bytecode that checks if the target variable is unset (null or _isSet() false), and only performs the assignment if so. Follows the condition/branch/body pattern from AbstractControlFlowAsmGenerator.

  • Constructor Details

  • Method Details

    • generate

      public void generate(ControlFlowChainInstr instr)
      Generate bytecode for guarded assignment.

      EK9 Pattern: variable :=? value

      Semantic Flow:

      1. Check if target variable is unset (null or _isSet() returns false)
      2. If UNSET: evaluate RHS expression and assign to target
      3. If SET: skip assignment (fall through to end)

      Stack Frame Invariant: Pre-condition: stack is empty Post-condition: stack is empty (assignment stored in variable)

      Parameters:
      instr - CONTROL_FLOW_CHAIN instruction with GUARDED_ASSIGNMENT type