Record Class EvaluationVariableDetails

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

public record EvaluationVariableDetails(String evaluationVariable, String evaluationVariableType, List<IRInstr> evaluationVariableSetup) extends Record
Record containing evaluation variable management information for CONTROL_FLOW_CHAIN constructs.

Evaluation variables are used in switch statements where the switch expression is computed and stored in a variable for comparison against case conditions: - switch statements: "switch someVar" or "switch var := expr" - switch expressions: "result <- switch someVar"

For if/else statements and Question operators, evaluation variables are not used since conditions are evaluated directly as boolean expressions.

  • Constructor Details

    • EvaluationVariableDetails

      public EvaluationVariableDetails(String evaluationVariable, String evaluationVariableType, List<IRInstr> evaluationVariableSetup)
      Creates an instance of a EvaluationVariableDetails record class.
      Parameters:
      evaluationVariable - the value for the evaluationVariable record component
      evaluationVariableType - the value for the evaluationVariableType record component
      evaluationVariableSetup - the value for the evaluationVariableSetup record component
  • Method Details

    • none

      public static EvaluationVariableDetails none()
      Create empty evaluation variable details (no evaluation variable).
    • forVariable

      public static EvaluationVariableDetails forVariable(String evaluationVariable, String evaluationVariableType)
      Create evaluation variable details for existing variable.
    • withSetup

      public static EvaluationVariableDetails withSetup(String evaluationVariable, String evaluationVariableType, List<IRInstr> evaluationVariableSetup)
      Create evaluation variable details with setup instructions.
    • hasEvaluationVariable

      public boolean hasEvaluationVariable()
      Check if this has an evaluation variable.
    • hasSetupInstructions

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

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

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

      public String evaluationVariable()
      Returns the value of the evaluationVariable record component.
      Returns:
      the value of the evaluationVariable record component
    • evaluationVariableType

      public String evaluationVariableType()
      Returns the value of the evaluationVariableType record component.
      Returns:
      the value of the evaluationVariableType record component
    • evaluationVariableSetup

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