aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/Type.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyGHDL/dom/Type.py')
-rw-r--r--pyGHDL/dom/Type.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/pyGHDL/dom/Type.py b/pyGHDL/dom/Type.py
index b0f2d1311..2b71ccc3c 100644
--- a/pyGHDL/dom/Type.py
+++ b/pyGHDL/dom/Type.py
@@ -13,7 +13,7 @@
#
# License:
# ============================================================================
-# Copyright (C) 2019-2021 Tristan Gingold
+# Copyright (C) 2019-2022 Tristan Gingold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
-from typing import List, Union, Iterator, Tuple
+from typing import List, Union, Iterator, Tuple, Iterable
from pyTooling.Decorators import export
@@ -185,20 +185,18 @@ class RecordTypeElement(VHDLModel_RecordTypeElement, DOMMixin):
DOMMixin.__init__(self, node)
@classmethod
- def parse(cls, elementDeclarationNode: Iir) -> "RecordTypeElement":
+ def parse(cls, elementDeclarationNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "RecordTypeElement":
from pyGHDL.dom._Utils import GetNameOfNode
from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode
elementName = GetNameOfNode(elementDeclarationNode)
elementType = GetSubtypeIndicationFromNode(elementDeclarationNode, "record element", elementName)
- return cls(
- elementDeclarationNode,
- [
- elementName,
- ],
- elementType,
- )
+ identifiers = [elementName]
+ if furtherIdentifiers is not None:
+ identifiers.extend(furtherIdentifiers)
+
+ return cls(elementDeclarationNode, identifiers, elementType)
@export
@@ -214,13 +212,12 @@ class RecordType(VHDLModel_RecordType, DOMMixin):
elements = []
elementDeclarations = nodes.Get_Elements_Declaration_List(typeDefinitionNode)
+ furtherIdentifiers = []
elementCount = flists.Flast(elementDeclarations) + 1
index = 0
while index < elementCount:
elementDeclaration = flists.Get_Nth_Element(elementDeclarations, index)
- element = RecordTypeElement.parse(elementDeclaration)
-
# Lookahead for elements with multiple identifiers at once
if nodes.Get_Has_Identifier_List(elementDeclaration):
index += 1
@@ -228,7 +225,7 @@ class RecordType(VHDLModel_RecordType, DOMMixin):
nextNode: Iir = flists.Get_Nth_Element(elementDeclarations, index)
# Consecutive identifiers are found, if the subtype indication is Null
if nodes.Get_Subtype_Indication(nextNode) == nodes.Null_Iir:
- element.Identifiers.append(GetNameOfNode(nextNode))
+ furtherIdentifiers.append(GetNameOfNode(nextNode))
else:
break
index += 1
@@ -239,7 +236,9 @@ class RecordType(VHDLModel_RecordType, DOMMixin):
else:
index += 1
+ element = RecordTypeElement.parse(elementDeclaration, furtherIdentifiers)
elements.append(element)
+ furtherIdentifiers.clear()
return cls(typeDefinitionNode, typeName, elements)