diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-08-16 23:56:16 +0200 |
---|---|---|
committer | umarcor <unai.martinezcorral@ehu.eus> | 2021-08-23 16:35:36 +0200 |
commit | 597bc9928352ba187bdb0a707332a5f7a0a28e1a (patch) | |
tree | ba8eba2a7842a7a24cc0b2f5cbb7c578a39111c3 /pyGHDL/dom | |
parent | 3f0308a5f807269aa5691fa1c704c0e9147d45f1 (diff) | |
download | ghdl-597bc9928352ba187bdb0a707332a5f7a0a28e1a.tar.gz ghdl-597bc9928352ba187bdb0a707332a5f7a0a28e1a.tar.bz2 ghdl-597bc9928352ba187bdb0a707332a5f7a0a28e1a.zip |
Handle context references.
Diffstat (limited to 'pyGHDL/dom')
-rw-r--r-- | pyGHDL/dom/DesignUnit.py | 26 | ||||
-rw-r--r-- | pyGHDL/dom/NonStandard.py | 3 |
2 files changed, 25 insertions, 4 deletions
diff --git a/pyGHDL/dom/DesignUnit.py b/pyGHDL/dom/DesignUnit.py index c905a439d..7f4d8e964 100644 --- a/pyGHDL/dom/DesignUnit.py +++ b/pyGHDL/dom/DesignUnit.py @@ -47,6 +47,7 @@ from pydecor import export from pyVHDLModel.SyntaxModel import ( LibraryClause as VHDLModel_LibraryClause, UseClause as VHDLModel_UseClause, + ContextReference as VHDLModel_ContextReference, Entity as VHDLModel_Entity, Architecture as VHDLModel_Architecture, Package as VHDLModel_Package, @@ -82,16 +83,16 @@ __all__ = [] @export class LibraryClause(VHDLModel_LibraryClause, DOMMixin): - def __init__(self, node: Iir, names: Iterable[Name]): + def __init__(self, libraryNode: Iir, names: Iterable[Name]): super().__init__(names) - DOMMixin.__init__(self, node) + DOMMixin.__init__(self, libraryNode) @export class UseClause(VHDLModel_UseClause, DOMMixin): - def __init__(self, node: Iir, names: Iterable[Name]): + def __init__(self, useNode: Iir, names: Iterable[Name]): super().__init__(names) - DOMMixin.__init__(self, node) + DOMMixin.__init__(self, useNode) @classmethod def parse(cls, useNode: Iir): @@ -105,6 +106,23 @@ class UseClause(VHDLModel_UseClause, DOMMixin): @export +class ContextReference(VHDLModel_ContextReference, DOMMixin): + def __init__(self, contextNode: Iir, names: Iterable[Name]): + super().__init__(names) + DOMMixin.__init__(self, contextNode) + + @classmethod + def parse(cls, contextNode: Iir): + from pyGHDL.dom._Translate import GetNameFromNode + + contexts = [GetNameFromNode(nodes.Get_Selected_Name(contextNode))] + for context in utils.chain_iter(nodes.Get_Context_Reference_Chain(contextNode)): + contexts.append(GetNameFromNode(nodes.Get_Selected_Name(context))) + + return cls(contextNode, contexts) + + +@export class Entity(VHDLModel_Entity, DOMMixin): def __init__( self, diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index b59efeacb..1cd98b4fa 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.py @@ -74,6 +74,7 @@ from pyGHDL.dom.DesignUnit import ( PackageInstantiation, LibraryClause, UseClause, + ContextReference, ) from pyGHDL.dom.PSL import VerificationUnit, VerificationProperty, VerificationMode @@ -189,6 +190,8 @@ class Document(VHDLModel_Document): contextNames = [] elif itemKind is nodes.Iir_Kind.Use_Clause: contextItems.append(UseClause.parse(item)) + elif itemKind is nodes.Iir_Kind.Context_Reference: + contextItems.append(ContextReference.parse(item)) else: pos = Position.parse(item) raise DOMException( |