Class QuestionOperatorInstr

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

public final class QuestionOperatorInstr extends IRInstr
IR instruction for question operator (expression?) with null-safe capability.

This high-level instruction provides a declarative approach to null-safe _isSet() calls, allowing backends to choose between branching and conditional selection strategies: - LLVM: Lower to conditional select or branches based on optimization context - JVM: Lower to bytecode jumps or conditional expressions - Other backends: Optimize based on target-specific capabilities

Contains complete evaluation paths for both null and non-null cases. Backends can use this information to make optimal code generation decisions.

Format: QUESTION_BLOCK result = operand_evaluation, null_case_evaluation, set_case_evaluation

  • Method Details

    • questionBlock

      public static QuestionOperatorInstr questionBlock(QuestionDetails questionDetails)
      Create question operator block.
    • getOperandEvaluationInstructions

      public List<IRInstr> getOperandEvaluationInstructions()
      Get instructions for evaluating the operand (the expression that ? is applied to).
    • getOperand

      public String getOperand()
      Get the operand variable name.
    • getNullCheckCondition

      public String getNullCheckCondition()
      Get the null check condition variable name (result of IS_NULL check).
    • getNullCaseEvaluationInstructions

      public List<IRInstr> getNullCaseEvaluationInstructions()
      Get instructions for the null case (when operand is null).
    • getNullResult

      public String getNullResult()
      Get the result variable for the null case.
    • getSetCaseEvaluationInstructions

      public List<IRInstr> getSetCaseEvaluationInstructions()
      Get instructions for the set case (when operand is not null).
    • getSetResult

      public String getSetResult()
      Get the result variable for the set case.
    • getScopeId

      public String getScopeId()
      Get the scope ID for memory management.
    • getOperandEvaluation

      public OperandEvaluation getOperandEvaluation()
      Get the operand evaluation record.
    • getNullCaseEvaluation

      public OperandEvaluation getNullCaseEvaluation()
      Get the null case evaluation record.
    • getSetCaseEvaluation

      public OperandEvaluation getSetCaseEvaluation()
      Get the set case evaluation record.
    • toString

      public String toString()
      Overrides:
      toString in class IRInstr