Class PropertyTypeGraph
?, $,
$$, ==, <=>, #?) could recurse forever (PropertyCycleMarker).
Nodes - three kinds, so the graph stays LINEAR in types plus properties plus subtype relations:
FIELDS(X)- the fields an object of exact type X carries: X's own fields (the same set the generated operators walk,GeneratedOperatorFields) and, through one edge, its super's.HOLDS(T)- what a property DECLARED as T can hold. ONE node per type, however many properties use it: an edge toFIELDS(T)when T can be constructed and one toFIELDS(S)for each concrete subtype S of an open, abstract or trait T (ConcreteSubtypeFinder, whole-program, dynamic classes included). Subtypes are never expanded per property. A built-in generic container (List,Optional,Result,Dict, ...) holds its type arguments, so its node points at theirs.ANY- ONE shared node forAny(and a bareT), with an edge toFIELDSof every concrete aggregate: anAnycan hold anything.
A node with ONE successor is never made: a property of a closed type points straight at that type's
FIELDS, a List of Node straight at what a Node property would, and a built-in type nothing
extends (String, Integer, ...) is not a node at all - it has no properties. So the graph holds the user types plus
one node per type that genuinely fans out.
A function-typed property is not followed: a function's generated operators never recurse into what it
captured ($$/$ on a function is Any's unset answer, its ? is always true).
Lazy, from the roots. Successors are computed once per node and only for nodes reached
(StronglyConnectedComponents asks lazily), so a program with no generated operators builds nothing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumThe three kinds of node - see the class javadoc.(package private) static final recordOne node, keyed by kind and fully qualified type name (value equality, as the shared Tarjan requires).static final recordThe size of the part of the graph that was reached - what the linearity test asserts on.static interfaceThe two whole-program facts the graph needs: the concrete subtypes of a type, and every aggregate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) List<? extends IAggregateSymbol> Every aggregate in the program - where the roots are chosen from.The cyclic strongly connected components reachable from the roots.fieldsOf(IAggregateSymbol aggregate) The node for the fields of an object of exactly this type - what a root, or a cycle member, is.The node for what a property declared with this type can hold, or empty when it can hold nothing that has properties of its own (a function, a built-in leaf, an unresolved type).static PropertyTypeGraphover(ConcreteSubtypeFinder subtypeFinder, ISymbol anyType) The graph over the program, its subtypes and aggregates from the phase's ONE shared subtype index.size()How much of the graph has been built so far.(package private) Collection<PropertyTypeGraph.Node> The successors of a node - computed once, cached.typeNames(StronglyConnectedComponents.Component<PropertyTypeGraph.Node> component, PropertyTypeGraph.Kind kind) The type names of every node of the given kind in one component - for marking.(package private) IAggregateSymboltypeOf(PropertyTypeGraph.Node node) The aggregate a node stands for (not forANY).
-
Constructor Details
-
PropertyTypeGraph
-
-
Method Details
-
over
The graph over the program, its subtypes and aggregates from the phase's ONE shared subtype index. -
allAggregates
List<? extends IAggregateSymbol> allAggregates()Every aggregate in the program - where the roots are chosen from. -
fieldsOf
The node for the fields of an object of exactly this type - what a root, or a cycle member, is. -
holdsOf
The node for what a property declared with this type can hold, or empty when it can hold nothing that has properties of its own (a function, a built-in leaf, an unresolved type). -
typeOf
The aggregate a node stands for (not forANY). -
successors
The successors of a node - computed once, cached. -
cyclesFrom
public List<StronglyConnectedComponents.Component<PropertyTypeGraph.Node>> cyclesFrom(Collection<PropertyTypeGraph.Node> roots) The cyclic strongly connected components reachable from the roots. -
size
How much of the graph has been built so far. -
typeNames
static Set<String> typeNames(StronglyConnectedComponents.Component<PropertyTypeGraph.Node> component, PropertyTypeGraph.Kind kind) The type names of every node of the given kind in one component - for marking.
-