Record Class GuardVariableDetails

java.lang.Object
java.lang.Record
org.ek9lang.compiler.ir.data.GuardVariableDetails

public record GuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId, String conditionScopeId) extends Record
Record containing guard variable management information for CONTROL_FLOW_CHAIN constructs.

Guard variables are used in EK9 control flow constructs like: - if/when with guards: "when var <- expr with condition" - switch with guards: "switch var := expr with var" - for loops with guards: "for var ?= expr then iterator" - while/do-while with guards: "while var <- expr then condition"

Provides SSA conversion hints to LLVM backend for proper phi node placement and scope management for guard variable lifetime.

For WHILE/DO-WHILE loops, the guard entry check is evaluated ONCE at loop entry. If the check fails, the entire loop is skipped. The condition is then evaluated on each iteration WITHOUT the guard check.

  • Constructor Details

    • GuardVariableDetails

      public GuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId, String conditionScopeId)
      Creates an instance of a GuardVariableDetails record class.
      Parameters:
      guardVariables - the value for the guardVariables record component
      guardScopeSetup - the value for the guardScopeSetup record component
      guardEntryCheck - the value for the guardEntryCheck record component
      guardEntryCheckPrimitive - the value for the guardEntryCheckPrimitive record component
      guardEntryCheckResult - the value for the guardEntryCheckResult record component
      guardScopeId - the value for the guardScopeId record component
      conditionScopeId - the value for the conditionScopeId record component
  • Method Details

    • none

      public static GuardVariableDetails none()
      Create empty guard variable details (no guards).
    • create

      public static GuardVariableDetails create(List<String> guardVariables, List<IRInstr> guardScopeSetup, String guardScopeId, String conditionScopeId)
      Create guard variable details for IF/SWITCH (no entry check needed - evaluates with condition).
    • createWithEntryCheck

      public static GuardVariableDetails createWithEntryCheck(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId)
      Create guard variable details for WHILE/DO-WHILE loops (with entry check). The entry check is evaluated ONCE at loop entry. If it fails, the loop is skipped.
      Parameters:
      guardVariables - List of guard variable names
      guardScopeSetup - Instructions to setup guard variables
      guardEntryCheck - Instructions for guard check (IS_NULL + _isSet)
      guardEntryCheckPrimitive - Primitive boolean for branching
      guardEntryCheckResult - EK9 Boolean result for condition_result in IF wrapper
      guardScopeId - Scope ID for guard variable lifetime
    • hasGuardVariables

      public boolean hasGuardVariables()
      Check if this has guard variables.
    • hasGuardScope

      public boolean hasGuardScope()
      Check if this has a guard scope.
    • hasSharedConditionScope

      public boolean hasSharedConditionScope()
      Check if this has a shared condition scope.
    • hasGuardEntryCheck

      public boolean hasGuardEntryCheck()
      Check if this has a guard entry check (for WHILE/DO-WHILE loops).
    • isEmpty

      public boolean isEmpty()
      Check if this guard details object is empty (no guard features).
    • toString

      @Nonnull public String toString()
      IR-optimized toString following EK9's bracket-only, no-indentation format. Returns empty string if no guard information to prevent rightward drift.
      Specified by:
      toString in class Record
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • guardVariables

      public List<String> guardVariables()
      Returns the value of the guardVariables record component.
      Returns:
      the value of the guardVariables record component
    • guardScopeSetup

      public List<IRInstr> guardScopeSetup()
      Returns the value of the guardScopeSetup record component.
      Returns:
      the value of the guardScopeSetup record component
    • guardEntryCheck

      public List<IRInstr> guardEntryCheck()
      Returns the value of the guardEntryCheck record component.
      Returns:
      the value of the guardEntryCheck record component
    • guardEntryCheckPrimitive

      public String guardEntryCheckPrimitive()
      Returns the value of the guardEntryCheckPrimitive record component.
      Returns:
      the value of the guardEntryCheckPrimitive record component
    • guardEntryCheckResult

      public String guardEntryCheckResult()
      Returns the value of the guardEntryCheckResult record component.
      Returns:
      the value of the guardEntryCheckResult record component
    • guardScopeId

      public String guardScopeId()
      Returns the value of the guardScopeId record component.
      Returns:
      the value of the guardScopeId record component
    • conditionScopeId

      public String conditionScopeId()
      Returns the value of the conditionScopeId record component.
      Returns:
      the value of the conditionScopeId record component