Class ControlFlowChainInstr
java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.ControlFlowChainInstr
- All Implemented Interfaces:
CompositeInstr, INode
Unified IR instruction for all EK9 control flow constructs.
This instruction replaces and unifies the following specialized IR opcodes: - QUESTION_BLOCK (Question operator ?) - ASSIGN_IF_UNSET_BLOCK (Assign-if-unset :=?) - Future: IF_BLOCK, SWITCH_BLOCK constructs
Key architectural benefits: - Single source of truth for all control flow logic - Consistent memory management across all constructs - Enhanced backend optimization opportunities - Reduced IR complexity and maintenance burden
Backends can optimize based on chainType hints and optimization metadata: - QUESTION_OPERATOR: Null check + method call optimization - IF_ELSE/IF_ELSE_IF: Standard conditional branching - SWITCH/SWITCH_ENUM: Jump tables, binary search, or sequential evaluation
-
Nested Class Summary
Nested classes/interfaces inherited from interface CompositeInstr
CompositeInstr.Activation, CompositeInstr.NestedList -
Method Summary
Modifier and TypeMethodDescriptionstatic ControlFlowChainInstrcontrolFlowChain(ControlFlowChainDetails details) Create a unified switch chain block instruction.Get the type of control flow construct.Get the sequential condition chain.Get the default/else case evaluation instructions.Get the default case result variable.The instructions that evaluate this chain's control/evaluation variable (a guard'sswitch v <- ...).The instructions that declare/initialise this chain's RETURN variable (the<- rtn <- ...of an expression-form try/switch/if).Get the scope ID for memory management.Get the try block details (for TRY_CATCH_FINALLY).booleanCheck if this construct has a default case.booleanCheck if this construct has an evaluation variable.booleanCheck if this construct has a return variable.booleanisLoop()True when this chain is a loop: its condition-chain lists run once per iteration.Every nested list, in the order the IR text renders them.toString()withNestedLists(UnaryOperator<List<IRInstr>> rewrite) A copy with every nested list replaced byrewriteof it - exactly the listsCompositeInstr.nestedLists()reports, in that order;thiswhen no list changed.Methods inherited from class IRInstr
accept, addOperand, addOperands, equals, getDebugInfo, getEscapeMetaData, getOpcode, getOperands, getResult, hasEscapeMetaData, hashCode, hasResult, isControlFlow, isLabel, isMemoryManagement, isMethodCall, setEscapeMetaData
-
Method Details
-
controlFlowChain
Create a unified switch chain block instruction. -
isLoop
public boolean isLoop()True when this chain is a loop: its condition-chain lists run once per iteration. -
nestedLists
Description copied from interface:CompositeInstrEvery nested list, in the order the IR text renders them. Absent (null) lists are omitted.- Specified by:
nestedListsin interfaceCompositeInstr
-
withNestedLists
Description copied from interface:CompositeInstrA copy with every nested list replaced byrewriteof it - exactly the listsCompositeInstr.nestedLists()reports, in that order;thiswhen no list changed.- Specified by:
withNestedListsin interfaceCompositeInstr
-
getChainType
Get the type of control flow construct. -
getConditionChain
Get the sequential condition chain. -
getDefaultBodyEvaluation
-
getDefaultResult
Get the default case result variable. -
getScopeId
Get the scope ID for memory management. -
getTryBlockDetails
Get the try block details (for TRY_CATCH_FINALLY). -
getReturnVariableSetup
The instructions that declare/initialise this chain's RETURN variable (the<- rtn <- ...of an expression-form try/switch/if). Exposed because a back end must be able to pre-scan every instruction list the emission walk descends into -- the native cleanup-pad pass hoists an entry-block alloca per SCOPE_REGISTERed object, and a return variable declared here that it could not see got an INLINE alloca that a landingpad above it does not dominate ("instruction does not dominate all uses"). -
getEvaluationVariableSetup
The instructions that evaluate this chain's control/evaluation variable (a guard'sswitch v <- ...). Same pre-scan requirement asgetReturnVariableSetup(). -
getFinallyBlockEvaluation
-
hasEvaluationVariable
public boolean hasEvaluationVariable()Check if this construct has an evaluation variable. -
hasReturnVariable
public boolean hasReturnVariable()Check if this construct has a return variable. -
hasDefaultCase
public boolean hasDefaultCase()Check if this construct has a default case. -
toString
-