aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/Symbol.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyGHDL/dom/Symbol.py')
-rw-r--r--pyGHDL/dom/Symbol.py47
1 files changed, 41 insertions, 6 deletions
diff --git a/pyGHDL/dom/Symbol.py b/pyGHDL/dom/Symbol.py
index 020f9fbc7..1865e4481 100644
--- a/pyGHDL/dom/Symbol.py
+++ b/pyGHDL/dom/Symbol.py
@@ -30,20 +30,24 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
-from pydecor import export
-
from typing import List
+from pydecor import export
-from pyGHDL.dom._Utils import NodeToName
from pyVHDLModel.VHDLModel import (
EntitySymbol as VHDLModel_EntitySymbol,
SimpleSubTypeSymbol as VHDLModel_SimpleSubTypeSymbol,
ConstrainedSubTypeSymbol as VHDLModel_ConstrainedSubTypeSymbol,
EnumerationLiteralSymbol as VHDLModel_EnumerationLiteralSymbol,
- SimpleObjectSymbol as VHDLModel_SimpleObjectSymbol,
+ SimpleObjectOrFunctionCallSymbol as VHDLModel_SimpleObjectOrFunctionCallSymbol,
+ IndexedObjectOrFunctionCallSymbol as VHDLModel_IndexedObjectOrFunctionCallSymbol,
Constraint,
)
+from pyGHDL.libghdl import utils
+from pyGHDL.libghdl.vhdl import nodes
+from pyGHDL.dom._Utils import GetIirKindOfNode, GetNameOfNode
+from pyGHDL.dom.Common import DOMException
+
__all__ = []
@@ -80,8 +84,39 @@ class ConstrainedSubTypeSymbol(VHDLModel_ConstrainedSubTypeSymbol):
@export
-class SimpleObjectSymbol(VHDLModel_SimpleObjectSymbol):
+class SimpleObjectOrFunctionCallSymbol(VHDLModel_SimpleObjectOrFunctionCallSymbol):
@classmethod
def parse(cls, node):
- name = NodeToName(node)
+ name = GetNameOfNode(node)
return cls(name)
+
+
+@export
+class IndexedObjectOrFunctionCallSymbol(VHDLModel_IndexedObjectOrFunctionCallSymbol):
+ def __init__(self, name: str, associations: List):
+ super().__init__(objectName=name)
+
+ @classmethod
+ def parse(cls, node):
+ from pyGHDL.dom._Translate import GetExpressionFromNode
+
+ prefix = nodes.Get_Prefix(node)
+ name = GetNameOfNode(prefix)
+
+ associations = []
+ for item in utils.chain_iter(nodes.Get_Association_Chain(node)):
+ kind = GetIirKindOfNode(item)
+
+ if kind == nodes.Iir_Kind.Association_Element_By_Expression:
+ actual = nodes.Get_Actual(item)
+ expr = GetExpressionFromNode(actual)
+
+ associations.append(expr)
+ else:
+ raise DOMException(
+ "Unknown association kind '{kindName}'({kind}) in array index/slice or function call '{node}'.".format(
+ kind=kind, kindName=kind.name, node=node
+ )
+ )
+
+ return cls(name, associations)