Record Class LeafPath

java.lang.Object
java.lang.Record
org.ek9lang.compiler.support.inputvariety.LeafPath
Record Components:
fields - the field steps from the declared parameter to this leaf; empty when the parameter is itself the leaf (a scalar, an enum, or an opaque non-record aggregate)
leafType - the resolved type of the leaf value itself — the type whose class model applies

public record LeafPath(List<LeafField> fields, ISymbol leafType) extends Record
One scalar leaf dimension of a callable's input space, together with the field path walked to reach it from the declared parameter (design EK9_INPUT_VARIATION_METRIC_DESIGN.md §4.5/§4.6).

This is what lets the numerator and the denominator stay in lock-step. Both come from the single traversal in EquivalenceClassModel.leafPathsOf(ISymbol): the denominator projects each leaf to its TypeVariety (how many classes this leaf could show), while the numerator projects the same leaf to a field access the backend emits (which class the leaf actually showed). Were the two to walk a record's fields separately they could disagree on order, depth or width bounds — and a numerator counting different leaves than the floor makes 100% unreachable or spuriously reachable. One traversal, two projections, so that drift cannot happen.

  • Constructor Summary

    Constructors
    Constructor
    Description
    LeafPath(List<LeafField> fields, ISymbol leafType)
    Creates an instance of a LeafPath record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The record-nesting depth of this leaf: one field step per record hop (see §4.5 MAX_DEPTH).
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the fields record component.
    final int
    Returns a hash code value for this object.
    boolean
    True when the declared parameter IS the leaf — no record decomposition was applied.
    Returns the value of the leafType record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LeafPath

      public LeafPath(List<LeafField> fields, ISymbol leafType)
      Creates an instance of a LeafPath record class.
      Parameters:
      fields - the value for the fields record component
      leafType - the value for the leafType record component
  • Method Details

    • depth

      public int depth()
      The record-nesting depth of this leaf: one field step per record hop (see §4.5 MAX_DEPTH).
    • isDirect

      public boolean isDirect()
      True when the declared parameter IS the leaf — no record decomposition was applied.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
    • fields

      public List<LeafField> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component
    • leafType

      public ISymbol leafType()
      Returns the value of the leafType record component.
      Returns:
      the value of the leafType record component