Class LogicalOperationInstr

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

public final class LogicalOperationInstr extends IRInstr
IR instruction for logical operations (AND/OR) with short-circuit capability.

This high-level instruction provides a declarative approach to Boolean operations, allowing backends to choose between short-circuit and full evaluation strategies: - LLVM: Lower to conditional branches with PHI nodes - JVM: Lower to bytecode jumps or full method calls - Other backends: Optimize based on target-specific capabilities

Contains complete evaluation paths for both operands and the logical result. Backends can use the primitive boolean condition to make short-circuit decisions.

Format: LOGICAL_AND_BLOCK/OR_BLOCK result = left_operand, condition, right_evaluation, logical_result

  • Method Details

    • andOperation

      public static IRInstr andOperation(LogicalDetails logicalDetails)
      Create logical AND operation.
    • orOperation

      public static IRInstr orOperation(LogicalDetails logicalDetails)
      Create logical OR operation.
    • getOperation

      public LogicalOperationInstr.Operation getOperation()
      Get the operation type (AND or OR).
    • getLeftEvaluationInstructions

      public List<IRInstr> getLeftEvaluationInstructions()
      Get the left operand evaluation instructions. These instructions evaluate the left EK9 Boolean operand.
    • getLeftOperand

      public String getLeftOperand()
      Get the left operand variable name.
    • getCondition

      public String getCondition()
      Get the primitive boolean condition variable name.
    • getRightEvaluationInstructions

      public List<IRInstr> getRightEvaluationInstructions()
      Get the right operand evaluation instructions. These instructions evaluate the right EK9 Boolean operand.
    • getRightOperand

      public String getRightOperand()
      Get the variable name that holds the right operand EK9 Boolean.
    • getResultComputationInstructions

      public List<IRInstr> getResultComputationInstructions()
      Get the result computation instructions. These instructions compute the logical AND/OR operation result.
    • getLogicalResult

      public String getLogicalResult()
      Get the variable name that holds the logical operation result.
    • getScopeId

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

      public OperandEvaluation getLeftEvaluation()
      Get the left operand evaluation record.
    • getConditionalEvaluation

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

      public OperandEvaluation getRightEvaluation()
      Get the right operand evaluation record.
    • getResultEvaluation

      public OperandEvaluation getResultEvaluation()
      Get the result evaluation record.
    • getOperationContext

      public LogicalOperationContext getOperationContext()
      Get the logical operation context record.
    • toString

      public String toString()
      Overrides:
      toString in class IRInstr