Class ControlFlowChainInstr
java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.ControlFlowChainInstr
- All Implemented Interfaces:
INode
Unified IR instruction for all EK9 control flow constructs.
This instruction replaces and unifies the following specialized IR opcodes: - QUESTION_BLOCK (Question operator ?) - GUARDED_ASSIGNMENT_BLOCK (Guarded assignment :=?) - 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
-
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.Get the scope ID for memory management.booleanCheck if this construct has a default case.booleanCheck if this construct has enum optimization information.booleanCheck if this construct has an evaluation variable.booleanCheck if this construct has a return variable.booleanisSwitch()Check if this is a switch construct.toString()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. -
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. -
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. -
hasEnumOptimization
public boolean hasEnumOptimization()Check if this construct has enum optimization information. -
isSwitch
public boolean isSwitch()Check if this is a switch construct. -
toString
-