Class WhileStatementGenerator
java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.WhileStatementGenerator
- All Implemented Interfaces:
Function<EK9Parser.WhileStatementExpressionContext, List<IRInstr>>
public final class WhileStatementGenerator
extends AbstractGenerator
implements Function<EK9Parser.WhileStatementExpressionContext, List<IRInstr>>
Generates IR for while and do-while loops and expressions using CONTROL_FLOW_CHAIN.
Supports both statement and expression forms:
- Statement form:
while condition { body }- no return value - Expression form:
result <- while condition <- rtn <- 0 { body }- accumulator pattern
Scope structure:
Outer Scope (_scope_1): Loop wrapper for guards + return variable (expression form) Whole Loop Scope (_scope_2): Loop control structure Condition Iteration Scope (_scope_3): Condition temps, enters/exits each iteration Body Iteration Scope (_scope_4): Body execution, enters/exits each iteration
The outer scope pattern enables guard and expression form support. Both condition and body use iteration scopes for tight memory management.
-
Field Summary
Fields inherited from class AbstractGenerator
debugInfoCreator, instructionBuilder, stackContext, typeNameOrException -
Constructor Summary
ConstructorsConstructorDescriptionWhileStatementGenerator(IRGenerationContext stackContext, GeneratorSet generators) -
Method Summary
Modifier and TypeMethodDescriptionMethods inherited from class AbstractGenerator
createTempVariable, createTempVariableFromContext, extractReturnType, getRecordedSymbolOrException, processBlockStatements, validateNoPreFlowStatement, validateStatementFormOnly
-
Constructor Details
-
WhileStatementGenerator
-
-
Method Details
-
apply
- Specified by:
applyin interfaceFunction<EK9Parser.WhileStatementExpressionContext, List<IRInstr>>
-