Class ControlFlowChainGenerator
java.lang.Object
org.ek9lang.compiler.phase7.ControlFlowChainGenerator
- All Implemented Interfaces:
Function<ControlFlowChainDetails,
List<IRInstr>>
public final class ControlFlowChainGenerator
extends Object
implements Function<ControlFlowChainDetails,List<IRInstr>>
Unified generator for all EK9 control flow constructs using CONTROL_FLOW_CHAIN.
This generator replaces multiple specialized generators: - QuestionBlockGenerator → generateQuestionOperator() - GuardedAssignmentBlockGenerator → generateGuardedAssignment() - Future: If/else and switch statement generators
Key architectural benefits: - Single source of truth for all control flow logic - Consistent memory management patterns across all constructs - Unified optimization metadata for backend code generation - Reduced code duplication and maintenance burden
-
Constructor Summary
ConstructorsConstructorDescriptionControlFlowChainGenerator
(IRContext context, Function<ExprProcessingDetails, List<IRInstr>> rawExprProcessor) -
Method Summary
Modifier and TypeMethodDescriptionapply
(ControlFlowChainDetails details) generateGuardedAssignment
(ISymbol lhsSymbol, List<IRInstr> assignmentEvaluation, String assignmentResult, BasicDetails basicDetails) Generate SWITCH_CHAIN_BLOCK for guarded assignment (:=?).generateQuestionOperator
(ExprProcessingDetails exprDetails) Generate SWITCH_CHAIN_BLOCK for Question operator (?).generateQuestionOperatorForVariable
(ISymbol variableSymbol, String resultVariable, BasicDetails basicDetails) Generate SWITCH_CHAIN_BLOCK for Question operator applied to a variable.
-
Constructor Details
-
ControlFlowChainGenerator
public ControlFlowChainGenerator(IRContext context, Function<ExprProcessingDetails, List<IRInstr>> rawExprProcessor)
-
-
Method Details
-
apply
- Specified by:
apply
in interfaceFunction<ControlFlowChainDetails,
List<IRInstr>>
-
generateQuestionOperator
Generate SWITCH_CHAIN_BLOCK for Question operator (?). Converts "operand?" to a two-case chain: null check + _isSet() default. Question operator is self-contained - no RETAIN/SCOPE_REGISTER needed on input. -
generateQuestionOperatorForVariable
public List<IRInstr> generateQuestionOperatorForVariable(ISymbol variableSymbol, String resultVariable, BasicDetails basicDetails) Generate SWITCH_CHAIN_BLOCK for Question operator applied to a variable. Used by guarded assignment composition. -
generateGuardedAssignment
-