raesl.compile.typechecking.orderer
#
Generic class for resolving an order of checking ‘things’ assuming each thing has a name, and knows the names of its direct dependencies.
Module Contents#
Classes#
Entry in the orderer. |
|
Class that orders entries so their 'needed_by' entries are processed first. |
Attributes#
- raesl.compile.typechecking.orderer.TypeOfData#
- class raesl.compile.typechecking.orderer.OrdererEntry(name: str, data: TypeOfData)#
Entry in the orderer.
- Parameters:
name – Name of the entry.
data – Data associated with the entry.
- needed_by#
List of entries that depend on this entry. May only be accessed by the Orderer.
- depend_on#
List of entries that need this entry. May only be accessed by the Orderer.
- __repr__()#
Return repr(self).
- class raesl.compile.typechecking.orderer.Orderer#
Class that orders entries so their ‘needed_by’ entries are processed first.
- _independent_entries#
Entries that do not depend on other entries.
- _dependent_entries#
Entries that depend on other entries.
- add_dependency(provide: str, needs: Iterable[str], data: TypeOfData = None)#
Add a dependency where the ‘provide’ name depends on the ‘needs’ names.
- Parameters:
provide – Name of the ‘thing’ that this dependency provides.
needs – Names of ‘things’ that are required by the provide ‘thing’.
data – Optional data associated with ‘provide’. At most one such data item should exist, class cannot handle multiple data items.
- resolve() Tuple[List[OrdererEntry], List[OrdererEntry] | None] #
Resolve the dependency chain by peeling away independent entries. This should cause some dependent entries to become independent, allowing them to be peeled as well.
- Returns:
- Ordered sequence of entries containing name and associated data, and
optionally a cycle of entries if at least one cycle exists. Note that the Orderer returns one arbitrary cycle in such a case.
- find_entry(name: str) OrdererEntry | None #
Try to find an entry with the provided name. Useful for duplicate name detection.
- Returns:
The found entry (treat as read-only), or None.
- _find_create_entry(name: str, data: TypeOfData = None) OrdererEntry #
Find or create an entry with the provide name.
- Parameters:
name – name of the entry to find or create.
data – Optional data associated with the name. It is copied into the entry whenever possible without overwriting existing data.
- Returns:
The entry.