Class GuardedAssignmentBlockInstr

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

public final class GuardedAssignmentBlockInstr extends IRInstr
IR instruction for guarded assignment block (:=? operator) with null-safe capability.

This high-level instruction provides a declarative approach to conditional assignment, 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 condition checking and assignment execution. Backends can use this information to make optimal code generation decisions.

Assignment Logic: Assign only if LHS is null OR LHS._isSet() == false Uses QUESTION_BLOCK semantics internally for consistent null-safety behavior.

Format: GUARDED_ASSIGNMENT_BLOCK result = condition_evaluation, assignment_evaluation

  • Method Details

    • guardedAssignmentBlock

      public static GuardedAssignmentBlockInstr guardedAssignmentBlock(ConditionalEvaluation conditionalEvaluation, OperandEvaluation assignmentEvaluation, BasicDetails basicDetails)
      Create guarded assignment block.
    • getConditionEvaluationInstructions

      public List<IRInstr> getConditionEvaluationInstructions()
      Get instructions for evaluating the assignment condition (should assignment occur?).
    • getConditionResult

      public String getConditionResult()
      Get the condition result variable name (Boolean indicating if assignment should occur).
    • getAssignmentEvaluationInstructions

      public List<IRInstr> getAssignmentEvaluationInstructions()
      Get instructions for performing the assignment (when condition is true).
    • getAssignmentResult

      public String getAssignmentResult()
      Get the assignment result variable name.
    • getScopeId

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

      public ConditionalEvaluation getConditionalEvaluation()
      Get the conditional evaluation record.
    • getAssignmentEvaluation

      public OperandEvaluation getAssignmentEvaluation()
      Get the assignment evaluation record.
    • toString

      public String toString()
      Overrides:
      toString in class IRInstr