Class SwitchChainBlockGenerator
java.lang.Object
org.ek9lang.compiler.phase7.SwitchChainBlockGenerator
- All Implemented Interfaces:
Function<SwitchChainDetails,
List<IRInstr>>
public final class SwitchChainBlockGenerator
extends Object
implements Function<SwitchChainDetails,List<IRInstr>>
Unified generator for all EK9 control flow constructs using SWITCH_CHAIN_BLOCK.
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
ConstructorsConstructorDescriptionSwitchChainBlockGenerator
(IRContext context, RecordExprProcessing recordExprProcessing, Function<ExprProcessingDetails, List<IRInstr>> rawExprProcessor) -
Method Summary
Modifier and TypeMethodDescriptionapply
(SwitchChainDetails 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
-
SwitchChainBlockGenerator
public SwitchChainBlockGenerator(IRContext context, RecordExprProcessing recordExprProcessing, Function<ExprProcessingDetails, List<IRInstr>> rawExprProcessor)
-
-
Method Details
-
apply
- Specified by:
apply
in interfaceFunction<SwitchChainDetails,
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
-