aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-21 14:34:42 +0200
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-22 12:26:59 +0200
commitf0796bfab0032e6e7f9c8f52b789bab06ab7e4df (patch)
tree61fa06ffafc2c6ad3e3865c324517c1b29ea59c6 /pyGHDL/dom
parent5303bb777dedfa03bbc3d042bb14c5d9bbae6b52 (diff)
downloadghdl-f0796bfab0032e6e7f9c8f52b789bab06ab7e4df.tar.gz
ghdl-f0796bfab0032e6e7f9c8f52b789bab06ab7e4df.tar.bz2
ghdl-f0796bfab0032e6e7f9c8f52b789bab06ab7e4df.zip
Start handling function calls.
Diffstat (limited to 'pyGHDL/dom')
-rw-r--r--pyGHDL/dom/Symbol.py33
-rw-r--r--pyGHDL/dom/_Translate.py7
2 files changed, 34 insertions, 6 deletions
diff --git a/pyGHDL/dom/Symbol.py b/pyGHDL/dom/Symbol.py
index af9e59b1d..c82c39729 100644
--- a/pyGHDL/dom/Symbol.py
+++ b/pyGHDL/dom/Symbol.py
@@ -30,6 +30,10 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
+from pyGHDL.dom.Common import DOMException
+from pyGHDL.libghdl import utils
+
+from pyGHDL.libghdl.vhdl import nodes
from pydecor import export
from typing import List
@@ -40,7 +44,8 @@ from pyVHDLModel.VHDLModel import (
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,
)
@@ -80,8 +85,30 @@ class ConstrainedSubTypeSymbol(VHDLModel_ConstrainedSubTypeSymbol):
@export
-class SimpleObjectSymbol(VHDLModel_SimpleObjectSymbol):
+class SimpleObjectOrFunctionCallSymbol(VHDLModel_SimpleObjectOrFunctionCallSymbol):
+ @classmethod
+ def parse(cls, node):
+ name = GetNameOfNode(node)
+ return cls(name)
+
+
+@export
+class IndexedObjectOrFunctionCallSymbol(VHDLModel_IndexedObjectOrFunctionCallSymbol):
@classmethod
def parse(cls, node):
- name = NodeToName(node)
+ prefix = nodes.Get_Prefix(node)
+ name = GetNameOfNode(prefix)
+
+ for item in utils.chain_iter(nodes.Get_Association_Chain(node)):
+ kind = GetIirKindOfNode(item)
+
+ if kind == nodes.Iir_Kind.Association_Element_By_Expression:
+ pass
+ else:
+ raise DOMException(
+ "Unknown association kind '{kindName}'({kind}) in array index or function call '{node}'.".format(
+ kind=kind, kindName=kind.name, node=node
+ )
+ )
+
return cls(name)
diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py
index 119f5816e..eed6a226b 100644
--- a/pyGHDL/dom/_Translate.py
+++ b/pyGHDL/dom/_Translate.py
@@ -42,9 +42,9 @@ from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode
from pyGHDL.dom.Common import DOMException
from pyGHDL.dom.Range import Range, RangeExpression
from pyGHDL.dom.Symbol import (
- SimpleObjectSymbol,
+ SimpleObjectOrFunctionCallSymbol,
SimpleSubTypeSymbol,
- ConstrainedSubTypeSymbol,
+ ConstrainedSubTypeSymbol, IndexedObjectOrFunctionCallSymbol,
)
from pyGHDL.dom.Literal import IntegerLiteral, CharacterLiteral, FloatingPointLiteral, StringLiteral
from pyGHDL.dom.Expression import (
@@ -135,7 +135,8 @@ def GetRangeFromNode(node) -> Range:
__EXPRESSION_TRANSLATION = {
- nodes.Iir_Kind.Simple_Name: SimpleObjectSymbol,
+ nodes.Iir_Kind.Simple_Name: SimpleObjectOrFunctionCallSymbol,
+ nodes.Iir_Kind.Parenthesis_Name: IndexedObjectOrFunctionCallSymbol,
nodes.Iir_Kind.Integer_Literal: IntegerLiteral,
nodes.Iir_Kind.Floating_Point_Literal: FloatingPointLiteral,
nodes.Iir_Kind.Character_Literal: CharacterLiteral,