Class SupersFirst
java.lang.Object
org.ek9lang.compiler.support.SupersFirst
THE supers-first walk: act on every node of a set of sites AFTER everything it depends on, each node once.
The end-of-phase-2 post-passes (the sub-type constructors, the constrained types, sameness, inherited dispatchers,
the field-less ?) all need "decide the super before the type below it", and each had copied the same
started-set recursion (front-end rationalisation F28, A-5). They differ only in WHAT a node depends on, so that is
the successors function: the super, the super and the traits, the constrained base.
- Only nodes that are among the
rootsare acted on; a successor that is not one (a built-in super, a type of another kind) is skipped, not walked into. - Each node is marked BEFORE its successors are visited, so a loop in a broken hierarchy stops here - the hierarchy checks that follow report it.
- Nodes are keyed by IDENTITY, never by
equals/hashCode. The passes MUTATE the symbol they key on - a completed operator, an inherited-dispatcher marker, a linked super - andAggregateSymbol.hashCodereads mutable state, so a hash-keyed set could lose an entry mid-walk or merge two distinct symbols that compare equal by structure. (The old comments said the hash walks the super chain; it no longer does - FE41/FE51 - but identity is still the right key.)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidforEach(Collection<? extends T> roots, Function<? super T, ? extends Collection<? extends T>> successors, Consumer<? super T> act) Visit every root, each after its successors, once.
-
Method Details
-
forEach
public static <T> void forEach(Collection<? extends T> roots, Function<? super T, ? extends Collection<? extends T>> successors, Consumer<? super T> act) Visit every root, each after its successors, once. Roots are visited in the order given.- Parameters:
roots- the nodes to act on, in the order to start from; also the only nodes ever acted onsuccessors- what a node must be acted on after (the super, the traits, a constrained base)act- the action
-