Class SwitchChainBlockInstr

java.lang.Object
org.ek9lang.compiler.ir.IRInstr
org.ek9lang.compiler.ir.SwitchChainBlockInstr
All Implemented Interfaces:
INode

public final class SwitchChainBlockInstr extends IRInstr
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 Details

    • switchChainBlock

      public static SwitchChainBlockInstr switchChainBlock(SwitchChainDetails details)
      Create a unified switch chain block instruction.
    • getChainType

      public String getChainType()
      Get the type of control flow construct.
    • getEvaluationVariable

      public String getEvaluationVariable()
      Get the variable being evaluated (for switch statements).
    • getEvaluationVariableType

      public String getEvaluationVariableType()
      Get the type of the evaluation variable.
    • getEvaluationVariableSetup

      public List<IRInstr> getEvaluationVariableSetup()
      Get instructions to setup the evaluation variable.
    • getReturnVariable

      public String getReturnVariable()
      Get the explicit return variable.
    • getReturnVariableType

      public String getReturnVariableType()
      Get the type of the return variable.
    • getReturnVariableSetup

      public List<IRInstr> getReturnVariableSetup()
      Get instructions to setup the return variable.
    • getConditionChain

      public List<ConditionCase> getConditionChain()
      Get the sequential condition chain.
    • getDefaultBodyEvaluation

      public List<IRInstr> getDefaultBodyEvaluation()
      Get the default/else case evaluation instructions.
    • getDefaultResult

      public String getDefaultResult()
      Get the default case result variable.
    • getEnumOptimizationInfo

      public EnumOptimizationInfo getEnumOptimizationInfo()
      Get enum optimization information.
    • getScopeId

      public String 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

      public String toString()
      Overrides:
      toString in class IRInstr