Class ControlFlowChainInstr
java.lang.Object
org.ek9lang.compiler.ir.IRInstr
org.ek9lang.compiler.ir.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 ControlFlowChainInstr
controlFlowChain
(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 enum optimization information.Get the variable being evaluated (for switch statements).Get instructions to setup the evaluation variable.Get the type of the evaluation variable.Get the explicit return variable.Get instructions to setup the return variable.Get the type of the return variable.Get the scope ID for memory management.boolean
Check if this construct has a default case.boolean
Check if this construct has enum optimization information.boolean
Check if this construct has an evaluation variable.boolean
Check if this construct has a return variable.boolean
isIfElse()
Check if this is an if/else construct.boolean
Check if this is a Question operator.boolean
isSwitch()
Check if this is a switch construct.toString()
Methods inherited from class org.ek9lang.compiler.ir.IRInstr
accept, addOperand, addOperands, equals, getDebugInfo, getOpcode, getOperands, getResult, hashCode, hasResult, isControlFlow, isLabel, isMemoryManagement, isMethodCall
-
Method Details
-
controlFlowChain
Create a unified switch chain block instruction. -
getChainType
Get the type of control flow construct. -
getEvaluationVariable
Get the variable being evaluated (for switch statements). -
getEvaluationVariableType
Get the type of the evaluation variable. -
getEvaluationVariableSetup
-
getReturnVariable
Get the explicit return variable. -
getReturnVariableType
Get the type of the return variable. -
getReturnVariableSetup
-
getConditionChain
Get the sequential condition chain. -
getDefaultBodyEvaluation
-
getDefaultResult
Get the default case result variable. -
getEnumOptimizationInfo
Get enum optimization information. -
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. -
isQuestionOperator
public boolean isQuestionOperator()Check if this is a Question operator. -
isIfElse
public boolean isIfElse()Check if this is an if/else construct. -
isSwitch
public boolean isSwitch()Check if this is a switch construct. -
toString
-