Class ForInGenerator

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

public final class ForInGenerator extends AbstractGenerator implements Function<EK9Parser.ForStatementExpressionContext, List<IRInstr>>
Generates IR for for-in loops and expressions: for item in collection.

Supports both statement and expression forms:

  • Statement form: for item in collection - no return value
  • Expression form: result <- for item in collection <- rtn <- 0 - accumulator pattern

Reuses while loop infrastructure with iterator setup.

Follows WhileStatementGenerator pattern with 4 scopes: - Outer scope (guards + iterator + return variable for expression form) - Whole loop scope - Condition iteration scope (hasNext) - Body iteration scope (next + user body)