Class ForStatementGenerator

java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.ForStatementGenerator
All Implemented Interfaces:
Function<EK9Parser.ForStatementExpressionContext, List<IRInstr>>

public final class ForStatementGenerator extends AbstractGenerator implements Function<EK9Parser.ForStatementExpressionContext, List<IRInstr>>
Coordinates for-statement IR generation by delegating to specialized generators.

Handles two distinct loop types:

  • For-range loops (for i in 1..10): Delegates to ForRangeGenerator
  • For-in loops (for item in collection): Delegates to ForInGenerator

ARCHITECTURE: Follows ExprInstrGenerator coordinator pattern - thin orchestration layer that delegates complex implementation to focused, specialized generators.

  • Constructor Details

  • Method Details

    • apply

      Main entry point for for-statement IR generation.

      Routes to appropriate specialized generator based on loop type: - forLoop() present → for-in loop (iterator-based collection iteration) - forRange() present → for-range loop (polymorphic range iteration) - returningParam() present → expression form (not yet implemented)

      Specified by:
      apply in interface Function<EK9Parser.ForStatementExpressionContext, List<IRInstr>>
      Parameters:
      ctx - ForStatementExpressionContext from parser
      Returns:
      IR instructions for the complete for-statement