Skip to content

Commit

Permalink
Improved doc-strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Jun 10, 2023
1 parent 8df01bc commit d17e67e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pyVHDLModel/DesignUnit.py
Expand Up @@ -311,6 +311,23 @@ class Context(PrimaryUnit):
"""
Represents a context declaration.
A context contains a generic list of all its items (library clauses, use clauses and context references) in
:data:`_references`.
Furthermore, when a context gets initialized, the item kinds get separated into individual lists:
* :class:`~pyVHDLModel.DesignUnit.LibraryClause` |rarr| :data:`_libraryReferences`
* :class:`~pyVHDLModel.DesignUnit.UseClause` |rarr| :data:`_packageReferences`
* :class:`~pyVHDLModel.DesignUnit.ContextReference` |rarr| :data:`_contextReferences`
When :meth:`pyVHDLModel.Design.LinkContexts` got called, these lists were processed and the fields:
* :data:`_referencedLibraries` (:pycode:`Dict[libName, Library]`)
* :data:`_referencedPackages` (:pycode:`Dict[libName, [pkgName, Package]]`)
* :data:`_referencedContexts` (:pycode:`Dict[libName, [ctxName, Context]]`)
are populated.
.. admonition:: Example
.. code-block:: VHDL
Expand Down
15 changes: 15 additions & 0 deletions pyVHDLModel/__init__.py
Expand Up @@ -836,6 +836,21 @@ def _LinkItems(package: Package):
_LinkItems(package)

def LinkContexts(self) -> None:
"""
Resolves and links all items (library clauses, use clauses and nested context references) in contexts.
It iterates all contexts in the design. Therefore, the library of the context is used as the working library. By
default, the working library is implicitly referenced in :data:`_referencedLibraries`. In addition, a new empty
dictionary is created in :data:`_referencedPackages` and :data:`_referencedContexts` for that working library.
At first, all library clauses are resolved (a library clause my have multiple library reference symbols). For each
referenced library an entry in :data:`_referencedLibraries` is generated and new empty dictionaries in
:data:`_referencedPackages` and :data:`_referencedContexts` for that working library. In addition, a vertex in the
dependency graph is added for that relationship.
At second, all use clauses are resolved (a use clause my have multiple package member reference symbols). For each
references package,
"""
for context in self.IterateDesignUnits(DesignUnitKind.Context): # type: Context
# Create entries in _referenced*** for the current working library under its real name.
workingLibrary: Library = context.Library
Expand Down

0 comments on commit d17e67e

Please sign in to comment.