Record Class ReturnVariableDetails

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

public record ReturnVariableDetails(String returnVariable, String returnVariableType, List<IRInstr> returnVariableSetup) extends Record
Record containing return variable management information for CONTROL_FLOW_CHAIN constructs.

Return variables are used in expression forms of control flow constructs where the result of the construct is assigned to a declared variable: - switch expressions: "result <- switch someVar" - if expressions: "result <- if condition then value1 else value2"

For statement forms (if statements, switch statements), return variables are not used since the construct doesn't produce a result value.

  • Constructor Details

    • ReturnVariableDetails

      public ReturnVariableDetails(String returnVariable, String returnVariableType, List<IRInstr> returnVariableSetup)
      Creates an instance of a ReturnVariableDetails record class.
      Parameters:
      returnVariable - the value for the returnVariable record component
      returnVariableType - the value for the returnVariableType record component
      returnVariableSetup - the value for the returnVariableSetup record component
  • Method Details

    • none

      public static ReturnVariableDetails none()
      Create empty return variable details (no return variable).
    • forVariable

      public static ReturnVariableDetails forVariable(String returnVariable, String returnVariableType)
      Create return variable details for existing variable.
    • withSetup

      public static ReturnVariableDetails withSetup(String returnVariable, String returnVariableType, List<IRInstr> returnVariableSetup)
      Create return variable details with setup instructions.
    • hasReturnVariable

      public boolean hasReturnVariable()
      Check if this has a return variable.
    • hasSetupInstructions

      public boolean hasSetupInstructions()
      Check if this has setup instructions.
    • isEmpty

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

      @Nonnull public String toString()
      IR-optimized toString following EK9's bracket-only, no-indentation format. Returns empty string if no return variable 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.
    • returnVariable

      public String returnVariable()
      Returns the value of the returnVariable record component.
      Returns:
      the value of the returnVariable record component
    • returnVariableType

      public String returnVariableType()
      Returns the value of the returnVariableType record component.
      Returns:
      the value of the returnVariableType record component
    • returnVariableSetup

      public List<IRInstr> returnVariableSetup()
      Returns the value of the returnVariableSetup record component.
      Returns:
      the value of the returnVariableSetup record component