Record Class GuardVariableDetails

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

public record GuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, 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"

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

  • Constructor Details

    • GuardVariableDetails

      public GuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, 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
      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 with all components.
    • 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.
    • 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
    • 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