aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/Symbol.py
diff options
context:
space:
mode:
authorUnai Martinez-Corral <38422348+umarcor@users.noreply.github.com>2021-06-22 12:05:45 +0100
committerGitHub <noreply@github.com>2021-06-22 12:05:45 +0100
commitbf45d9939dc26d0d584dd549923b9962f83360ec (patch)
tree976beef99129705fa8d0e592dfba4fad61b80135 /pyGHDL/dom/Symbol.py
parent15f447b1270a815748fdbcce46d97abd9eecc21d (diff)
parent0a69901be945dfb6c5372e657332d5e5ddfa10c7 (diff)
downloadghdl-bf45d9939dc26d0d584dd549923b9962f83360ec.tar.gz
ghdl-bf45d9939dc26d0d584dd549923b9962f83360ec.tar.bz2
ghdl-bf45d9939dc26d0d584dd549923b9962f83360ec.zip
More expression kinds and function calls (#1802)
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)