aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-12-03 22:44:50 +0100
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-12-23 23:42:30 +0100
commit5823ef28acc87cfbfc655b7e57a933ce1aca7a3c (patch)
tree5cbe045976644e829aecb2158aff89b2b057ddb5
parentb48f4c44f7a75cb0dadff20295bd2b9418f1d51b (diff)
downloadghdl-5823ef28acc87cfbfc655b7e57a933ce1aca7a3c.tar.gz
ghdl-5823ef28acc87cfbfc655b7e57a933ce1aca7a3c.tar.bz2
ghdl-5823ef28acc87cfbfc655b7e57a933ce1aca7a3c.zip
Fixed handling of multiple defined identifiers for latest pyVHDLModel.
-rw-r--r--pyGHDL/dom/Object.py46
-rw-r--r--pyGHDL/dom/_Translate.py21
2 files changed, 46 insertions, 21 deletions
diff --git a/pyGHDL/dom/Object.py b/pyGHDL/dom/Object.py
index 162bc8bef..1cf92179d 100644
--- a/pyGHDL/dom/Object.py
+++ b/pyGHDL/dom/Object.py
@@ -30,7 +30,7 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
-from typing import Union, List
+from typing import Union, List, Iterable
from pyTooling.Decorators import export
@@ -67,22 +67,25 @@ class Constant(VHDLModel_Constant, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, constantNode: Iir) -> Union["Constant", "DeferredConstant"]:
+ def parse(cls, constantNode: Iir, furtherIdentifiers: Iterable[str] = None) -> Union["Constant", "DeferredConstant"]:
from pyGHDL.dom._Translate import (
GetSubtypeIndicationFromNode,
GetExpressionFromNode,
)
name = GetNameOfNode(constantNode)
+ identifiers = [name]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
documentation = GetDocumentationOfNode(constantNode)
subtypeIndication = GetSubtypeIndicationFromNode(constantNode, "constant", name)
defaultValue = nodes.Get_Default_Value(constantNode)
if defaultValue != nodes.Null_Iir:
defaultExpression = GetExpressionFromNode(defaultValue)
- return cls(constantNode, [name], subtypeIndication, defaultExpression, documentation)
+ return cls(constantNode, identifiers, subtypeIndication, defaultExpression, documentation)
else:
- return DeferredConstant(constantNode, [name], subtypeIndication, documentation)
+ return DeferredConstant(constantNode, identifiers, subtypeIndication, documentation)
@export
@@ -92,14 +95,17 @@ class DeferredConstant(VHDLModel_DeferredConstant, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, constantNode: Iir) -> "DeferredConstant":
+ def parse(cls, constantNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "DeferredConstant":
from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode
name = GetNameOfNode(constantNode)
+ identifiers = [name]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
documentation = GetDocumentationOfNode(constantNode)
subtypeIndication = GetSubtypeIndicationFromNode(constantNode, "deferred constant", name)
- return cls(constantNode, [name], subtypeIndication, documentation)
+ return cls(constantNode, identifiers, subtypeIndication, documentation)
@export
@@ -116,13 +122,16 @@ class Variable(VHDLModel_Variable, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, variableNode: Iir) -> "Variable":
+ def parse(cls, variableNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "Variable":
from pyGHDL.dom._Translate import (
GetSubtypeIndicationFromNode,
GetExpressionFromNode,
)
name = GetNameOfNode(variableNode)
+ identifiers = [name]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
documentation = GetDocumentationOfNode(variableNode)
subtypeIndication = GetSubtypeIndicationFromNode(variableNode, "variable", name)
defaultValue = nodes.Get_Default_Value(variableNode)
@@ -130,7 +139,7 @@ class Variable(VHDLModel_Variable, DOMMixin):
if defaultValue != nodes.Null_Iir:
defaultExpression = GetExpressionFromNode(defaultValue)
- return cls(variableNode, [name], subtypeIndication, defaultExpression, documentation)
+ return cls(variableNode, identifiers, subtypeIndication, defaultExpression, documentation)
@export
@@ -140,14 +149,17 @@ class SharedVariable(VHDLModel_SharedVariable, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, variableNode: Iir) -> "SharedVariable":
+ def parse(cls, variableNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "SharedVariable":
from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode
name = GetNameOfNode(variableNode)
+ identifiers = [name]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
documentation = GetDocumentationOfNode(variableNode)
subtypeIndication = GetSubtypeIndicationFromNode(variableNode, "variable", name)
- return cls(variableNode, [name], subtypeIndication, documentation)
+ return cls(variableNode, identifiers, subtypeIndication, documentation)
@export
@@ -164,19 +176,22 @@ class Signal(VHDLModel_Signal, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, signalNode: Iir) -> "Signal":
+ def parse(cls, signalNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "Signal":
from pyGHDL.dom._Translate import (
GetSubtypeIndicationFromNode,
GetExpressionFromNode,
)
name = GetNameOfNode(signalNode)
+ identifiers = [name]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
documentation = GetDocumentationOfNode(signalNode)
subtypeIndication = GetSubtypeIndicationFromNode(signalNode, "signal", name)
default = nodes.Get_Default_Value(signalNode)
defaultExpression = GetExpressionFromNode(default) if default else None
- return cls(signalNode, [name], subtypeIndication, defaultExpression, documentation)
+ return cls(signalNode, identifiers, subtypeIndication, defaultExpression, documentation)
@export
@@ -186,13 +201,16 @@ class File(VHDLModel_File, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, fileNode: Iir) -> "File":
+ def parse(cls, fileNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "File":
from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode
name = GetNameOfNode(fileNode)
+ identifiers = [name]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
documentation = GetDocumentationOfNode(fileNode)
subtypeIndication = GetSubtypeIndicationFromNode(fileNode, "file", name)
# FIXME: handle file open stuff
- return cls(fileNode, [name], subtypeIndication, documentation)
+ return cls(fileNode, identifiers, subtypeIndication, documentation)
diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py
index 788f0abbd..ef8656e52 100644
--- a/pyGHDL/dom/_Translate.py
+++ b/pyGHDL/dom/_Translate.py
@@ -650,6 +650,7 @@ def GetParameterMapAspect(
def GetDeclaredItemsFromChainedNodes(nodeChain: Iir, entity: str, name: str) -> Generator[ModelEntity, None, None]:
+ furtherIdentifiers = []
item = nodeChain
lastKind = None
while item != nodes.Null_Iir:
@@ -657,22 +658,27 @@ def GetDeclaredItemsFromChainedNodes(nodeChain: Iir, entity: str, name: str) ->
if kind == nodes.Iir_Kind.Constant_Declaration:
from pyGHDL.dom.Object import Constant
- obj = Constant.parse(item)
+ objectParseMethod = Constant.parse
+ objectItem = item
elif kind == nodes.Iir_Kind.Variable_Declaration:
from pyGHDL.dom.Object import SharedVariable
if nodes.Get_Shared_Flag(item):
- obj = SharedVariable.parse(item)
+ objectParseMethod = SharedVariable.parse
+ objectItem = item
else:
- obj = Variable.parse(item)
+ objectParseMethod = Variable.parse
+ objectItem = item
elif kind == nodes.Iir_Kind.Signal_Declaration:
from pyGHDL.dom.Object import Signal
- obj = Signal.parse(item)
+ objectParseMethod = Signal.parse
+ objectItem = item
elif kind == nodes.Iir_Kind.File_Declaration:
from pyGHDL.dom.Object import File
- obj = File.parse(item)
+ objectParseMethod = File.parse
+ objectItem = item
else:
if kind == nodes.Iir_Kind.Type_Declaration:
yield GetTypeFromNode(item)
@@ -781,7 +787,7 @@ def GetDeclaredItemsFromChainedNodes(nodeChain: Iir, entity: str, name: str) ->
for nextItem in utils.chain_iter(nextNode):
# Consecutive identifiers are found, if the subtype indication is Null
if nodes.Get_Subtype_Indication(nextItem) == nodes.Null_Iir:
- obj.Identifiers.append(GetNameOfNode(nextItem))
+ furtherIdentifiers.append(GetNameOfNode(nextItem))
else:
item = nextItem
break
@@ -795,7 +801,8 @@ def GetDeclaredItemsFromChainedNodes(nodeChain: Iir, entity: str, name: str) ->
else:
item = nodes.Get_Chain(item)
- yield obj
+ yield objectParseMethod(objectItem, furtherIdentifiers)
+ furtherIdentifiers.clear()
def GetConcurrentStatementsFromChainedNodes(