:py:mod:`raesl.compile.typechecking.orderer` ============================================ .. py:module:: raesl.compile.typechecking.orderer .. autoapi-nested-parse:: 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 ~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.orderer.OrdererEntry raesl.compile.typechecking.orderer.Orderer Attributes ~~~~~~~~~~ .. autoapisummary:: raesl.compile.typechecking.orderer.TypeOfData .. py:data:: TypeOfData .. py:class:: OrdererEntry(name: str, data: TypeOfData) Entry in the orderer. :param name: Name of the entry. :param data: Data associated with the entry. .. attribute:: needed_by List of entries that depend on this entry. May only be accessed by the Orderer. .. attribute:: depend_on List of entries that need this entry. May only be accessed by the Orderer. .. py:method:: __repr__() Return repr(self). .. py:class:: Orderer Class that orders entries so their 'needed_by' entries are processed first. .. attribute:: _independent_entries Entries that do not depend on other entries. .. attribute:: _dependent_entries Entries that depend on other entries. .. py:method:: add_dependency(provide: str, needs: Iterable[str], data: TypeOfData = None) Add a dependency where the 'provide' name depends on the 'needs' names. :param provide: Name of the 'thing' that this dependency provides. :param needs: Names of 'things' that are required by the provide 'thing'. :param data: Optional data associated with 'provide'. At most one such data item should exist, class cannot handle multiple data items. .. py:method:: resolve() -> Tuple[List[OrdererEntry], Optional[List[OrdererEntry]]] 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. .. py:method:: find_entry(name: str) -> Optional[OrdererEntry] Try to find an entry with the provided name. Useful for duplicate name detection. :returns: The found entry (treat as read-only), or None. .. py:method:: _find_create_entry(name: str, data: TypeOfData = None) -> OrdererEntry Find or create an entry with the provide name. :param name: name of the entry to find or create. :param data: Optional data associated with the name. It is copied into the entry whenever possible without overwriting existing data. :returns: The entry.