diff options
Diffstat (limited to 'pyGHDL/dom/_Utils.py')
-rw-r--r-- | pyGHDL/dom/_Utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pyGHDL/dom/_Utils.py b/pyGHDL/dom/_Utils.py index 1b9dd06fb..3803374f3 100644 --- a/pyGHDL/dom/_Utils.py +++ b/pyGHDL/dom/_Utils.py @@ -39,6 +39,7 @@ from pyGHDL.dom.Symbol import ( PackageReferenceSymbol, PackageMembersReferenceSymbol, AllPackageMembersReferenceSymbol, + ContextReferenceSymbol, ) from pyVHDLModel.SyntaxModel import Mode @@ -166,6 +167,16 @@ def GetPackageSymbol(node: Iir) -> PackageReferenceSymbol: raise DOMException(f"{kind.name} at {Position.parse(node)}") +def GetContextSymbol(node: Iir) -> ContextReferenceSymbol: + kind = GetIirKindOfNode(node) + if kind == nodes.Iir_Kind.Selected_Name: + name = GetNameOfNode(node) + prefixName = GetLibrarySymbol(nodes.Get_Prefix(node)) + return ContextReferenceSymbol(node, name, prefixName) + else: + raise DOMException(f"{kind.name} at {Position.parse(node)}") + + def GetLibrarySymbol(node: Iir) -> LibraryReferenceSymbol: kind = GetIirKindOfNode(node) if kind == nodes.Iir_Kind.Simple_Name: |