Class ConceptualAccess

java.lang.Object
org.ek9lang.compiler.support.ConceptualAccess

public final class ConceptualAccess extends Object
THE record of what a generic's body USES of its conceptual T, and the reading of it. Inside a generic body T has only a placeholder's members, so every constructor, method or operator the body calls on it is marked, and when a type argument is substituted (phase4/ParameterisedTypeOrError) it must have each marked member - and, for a pure scope or a range, a pure one - or the parameterisation is an error (E07620, E10032) instead of IR generation failing on a compile-clean program.

Three phase-3 places wrote the marks by hand and phase 4 read them raw (front-end rationalisation B-11): a call of T() or a method (ResolveIdentifierReferenceCallOrError), an operator (RequiredOperatorPresentOrError, and every route that resolves one) and a for range over T (ForRangeOrError). They call note...; the reader asks isAccessed.... A comparison coalescing operator on T marks T itself (noteCoalescingComparison(IAggregateSymbol), E07187).

An ordering of a type BUILT ON T - a comparator-less sort, a natural-order PriorityQueue, <?, a range or a comparison over DictEntry of (K, Integer), OrderedBox of T - is recorded the same way (noteOrderingUse(IAggregateSymbol, MethodSymbol, boolean), noteNaturalOrderQueue(ISymbol), on each T the type is built on) and judged where the parameters are substituted (orderingUsesOf(List), phase4/ParameterisedTypeOrError), with the verdict the same type gets when it is written directly (D71, D63). Phase 3 cannot judge it: the type's <=> survives over the conceptual T and is withdrawn for some type arguments.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    How the generic's body asks a type built on its type parameters to order, which decides the verdict where the parameters are replaced: exactly the one the same type gets when it is written directly (phase 5's RetractedComparatorUseOrError).
    static final record 
    One ordering the generic's body asks of a type built on its type parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    True when the generic's body uses this member of T.
    static boolean
    True when the member is the copy constructor of a for range over T.
    static boolean
    True when the body used the member from a pure scope.
    static boolean
    True when the type is built on conceptual type parameters without being one: a parameterisation with a bare T among its leaves (DictEntry of (K, Integer), List of (OrderedBox of T)), or a generic template named in its own body (this < other inside OrderedBox of type T, which is OrderedBox of T).
    static boolean
    True when the generic's body selects between values of this conceptual T with a comparison coalescing operator.
    static void
    Note that the generic's body uses this member of its conceptual T.
    static void
    note(MethodSymbol member, boolean inPureScope)
    As note(MethodSymbol), and when the body is in a pure scope remember that too: the concrete member must then be pure (a conceptual constructor's own purity is meaningless - it is synthetic on T).
    static void
    noteByRange(MethodSymbol copyConstructor, boolean inPureScope)
    Note the copy constructor a for range over T will use: which one runs, and whether it is pure, is only known at parameterisation.
    static void
    Note that the generic's body selects between values of its conceptual T with <? or >? (D24 Q4 REVISED).
    static void
    Note an operator the body used on owner, but only when owner IS a conceptual type parameter - a concrete type needs no deferred check.
    static void
    Note a natural-order PriorityQueue of this element type, when it is built on a conceptual parameter without being one (PriorityQueue of (OrderedBox of T)).
    static void
    noteOrderingUse(IAggregateSymbol owner, MethodSymbol operator, boolean writtenAsAnOperatorCall)
    Note, where a resolved ordering operator (<=> < <= > >=) is used on a type that is built on a conceptual parameter without being one (DictEntry of (K, Integer)).
    orderingUsesOf(List<? extends ISymbol> typeParameters)
    The orderings of types built on any of these conceptual parameters that the generic's body uses, each once (a type built on several parameters is recorded on each).
    The conceptual parameters a (non-bare) parameterisation is built on, each once; for a generic template (named in its own body) its own type parameters.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • note

      public static void note(MethodSymbol member)
      Note that the generic's body uses this member of its conceptual T.
    • note

      public static void note(MethodSymbol member, boolean inPureScope)
      As note(MethodSymbol), and when the body is in a pure scope remember that too: the concrete member must then be pure (a conceptual constructor's own purity is meaningless - it is synthetic on T).
    • noteByRange

      public static void noteByRange(MethodSymbol copyConstructor, boolean inPureScope)
      Note the copy constructor a for range over T will use: which one runs, and whether it is pure, is only known at parameterisation.
    • noteIfConceptual

      public static void noteIfConceptual(IAggregateSymbol owner, MethodSymbol operator)
      Note an operator the body used on owner, but only when owner IS a conceptual type parameter - a concrete type needs no deferred check. EVERY route that resolves an operator calls this: the operator expression (RequiredOperatorPresentOrError), a stream terminal's or tee's | (StreamAssemblyOrError) and a mutating or assignment operator such as :=:, :~: or += (LhsAndRhsAssignmentOrError), so phase4/ParameterisedTypeOrError reports a parameterising type that lacks it (E07620).
    • noteCoalescingComparison

      public static void noteCoalescingComparison(IAggregateSymbol conceptualT)
      Note that the generic's body selects between values of its conceptual T with <? or >? (D24 Q4 REVISED). Whether that is allowed depends on the type argument - its values must not be of different run-time types whose <=> is unset (Sameness.mayMixRuntimeTypes(IAggregateSymbol, ISymbol)) - so it is judged where T is substituted (E07187). The mark is on T itself, so a constrained T is judged too.
    • noteOrderingUse

      public static void noteOrderingUse(IAggregateSymbol owner, MethodSymbol operator, boolean writtenAsAnOperatorCall)
      Note, where a resolved ordering operator (<=> < <= > >=) is used on a type that is built on a conceptual parameter without being one (DictEntry of (K, Integer)). Every route that resolves an operator goes through phase3/RequiredOperatorPresentOrError, which calls this: a comparator-less sort, <?, a range (ConceptualAccess.OrderingKind.NEEDS_ORDERING) or an operator written as a call (ConceptualAccess.OrderingKind.OPERATOR_CALL, the route that records the call). A bare T is noteIfConceptual(IAggregateSymbol, MethodSymbol)'s.
      Parameters:
      owner - the type the operator was resolved on
      operator - the operator
      writtenAsAnOperatorCall - true when the use is an operator call the expression records (a binary operator or a case)
    • noteNaturalOrderQueue

      public static void noteNaturalOrderQueue(ISymbol elementType)
      Note a natural-order PriorityQueue of this element type, when it is built on a conceptual parameter without being one (PriorityQueue of (OrderedBox of T)). A bare T element takes the sort's own steps.
    • isBuiltOnTypeParameters

      public static boolean isBuiltOnTypeParameters(ISymbol type)
      True when the type is built on conceptual type parameters without being one: a parameterisation with a bare T among its leaves (DictEntry of (K, Integer), List of (OrderedBox of T)), or a generic template named in its own body (this < other inside OrderedBox of type T, which is OrderedBox of T).
    • typeParametersUnder

      public static List<IAggregateSymbol> typeParametersUnder(ISymbol type)
      The conceptual parameters a (non-bare) parameterisation is built on, each once; for a generic template (named in its own body) its own type parameters.
    • orderingUsesOf

      public static List<ConceptualAccess.OrderingUse> orderingUsesOf(List<? extends ISymbol> typeParameters)
      The orderings of types built on any of these conceptual parameters that the generic's body uses, each once (a type built on several parameters is recorded on each).
    • isComparedByCoalescing

      public static boolean isComparedByCoalescing(IAggregateSymbol conceptualT)
      True when the generic's body selects between values of this conceptual T with a comparison coalescing operator.
    • isAccessed

      public static boolean isAccessed(MethodSymbol member)
      True when the generic's body uses this member of T.
    • isAccessedByRange

      public static boolean isAccessedByRange(MethodSymbol member)
      True when the member is the copy constructor of a for range over T.
    • isAccessedInPureScope

      public static boolean isAccessedInPureScope(MethodSymbol member)
      True when the body used the member from a pure scope.