From 5303bb777dedfa03bbc3d042bb14c5d9bbae6b52 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 21 Jun 2021 14:34:03 +0200 Subject: Renamed 'NodeToName' to 'GetNameOfNode'. --- pyGHDL/dom/Symbol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyGHDL/dom/Symbol.py') diff --git a/pyGHDL/dom/Symbol.py b/pyGHDL/dom/Symbol.py index 020f9fbc7..af9e59b1d 100644 --- a/pyGHDL/dom/Symbol.py +++ b/pyGHDL/dom/Symbol.py @@ -34,7 +34,7 @@ from pydecor import export from typing import List -from pyGHDL.dom._Utils import NodeToName +from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode from pyVHDLModel.VHDLModel import ( EntitySymbol as VHDLModel_EntitySymbol, SimpleSubTypeSymbol as VHDLModel_SimpleSubTypeSymbol, -- cgit v1.2.3 From f0796bfab0032e6e7f9c8f52b789bab06ab7e4df Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 21 Jun 2021 14:34:42 +0200 Subject: Start handling function calls. --- pyGHDL/dom/Symbol.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'pyGHDL/dom/Symbol.py') 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) -- cgit v1.2.3 From ec37f2b5efe56d442ea51d3e10d16742f3cd4bce Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 21 Jun 2021 15:21:06 +0200 Subject: Minimal handling of types and subtypes. --- pyGHDL/dom/Symbol.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'pyGHDL/dom/Symbol.py') diff --git a/pyGHDL/dom/Symbol.py b/pyGHDL/dom/Symbol.py index c82c39729..047fd624f 100644 --- a/pyGHDL/dom/Symbol.py +++ b/pyGHDL/dom/Symbol.py @@ -30,15 +30,9 @@ # # 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 +from pydecor import export -from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode from pyVHDLModel.VHDLModel import ( EntitySymbol as VHDLModel_EntitySymbol, SimpleSubTypeSymbol as VHDLModel_SimpleSubTypeSymbol, @@ -49,6 +43,11 @@ from pyVHDLModel.VHDLModel import ( 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__ = [] @@ -94,21 +93,29 @@ class SimpleObjectOrFunctionCallSymbol(VHDLModel_SimpleObjectOrFunctionCallSymbo @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: - pass + expr = None # GetExpressionFromNode(nodes.Get_Associated_Expr(item)) + + associations.append(expr) else: raise DOMException( - "Unknown association kind '{kindName}'({kind}) in array index or function call '{node}'.".format( + "Unknown association kind '{kindName}'({kind}) in array index/slice or function call '{node}'.".format( kind=kind, kindName=kind.name, node=node ) ) - return cls(name) + return cls(name, associations) -- cgit v1.2.3 From ad34fac3f4e30f0ff13e1630b42373f31b2918a4 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 21 Jun 2021 21:44:31 +0200 Subject: Fixed function call parameters. Fixed physical literal units. Added basic Procedure detection. --- pyGHDL/dom/Symbol.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pyGHDL/dom/Symbol.py') diff --git a/pyGHDL/dom/Symbol.py b/pyGHDL/dom/Symbol.py index 047fd624f..1865e4481 100644 --- a/pyGHDL/dom/Symbol.py +++ b/pyGHDL/dom/Symbol.py @@ -108,7 +108,8 @@ class IndexedObjectOrFunctionCallSymbol(VHDLModel_IndexedObjectOrFunctionCallSym kind = GetIirKindOfNode(item) if kind == nodes.Iir_Kind.Association_Element_By_Expression: - expr = None # GetExpressionFromNode(nodes.Get_Associated_Expr(item)) + actual = nodes.Get_Actual(item) + expr = GetExpressionFromNode(actual) associations.append(expr) else: -- cgit v1.2.3