diff options
Diffstat (limited to 'pyGHDL/dom/_Translate.py')
-rw-r--r-- | pyGHDL/dom/_Translate.py | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index a125abfe5..b3a48769b 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -464,13 +464,14 @@ def GetGenericsFromChainedNodes( GenericFunctionInterfaceItem, ) + furtherIdentifiers = [] generic = nodeChain while generic != nodes.Null_Iir: kind = GetIirKindOfNode(generic) if kind == nodes.Iir_Kind.Interface_Constant_Declaration: from pyGHDL.dom.InterfaceItem import GenericConstantInterfaceItem - genericConstant = GenericConstantInterfaceItem.parse(generic) + parseNode = generic # Lookahead for generics with multiple identifiers at once if nodes.Get_Has_Identifier_List(generic): @@ -478,7 +479,7 @@ def GetGenericsFromChainedNodes( for nextGeneric in utils.chain_iter(nextNode): # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextGeneric) == nodes.Null_Iir: - genericConstant.Identifiers.append(GetNameOfNode(nextGeneric)) + furtherIdentifiers.append(GetNameOfNode(nextGeneric)) else: generic = nextGeneric break @@ -492,7 +493,8 @@ def GetGenericsFromChainedNodes( else: generic = nodes.Get_Chain(generic) - yield genericConstant + yield GenericConstantInterfaceItem.parse(parseNode, furtherIdentifiers) + furtherIdentifiers.clear() continue else: if kind == nodes.Iir_Kind.Interface_Type_Declaration: @@ -517,13 +519,14 @@ def GetPortsFromChainedNodes( nodeChain: Iir, ) -> Generator[PortInterfaceItem, None, None]: + furtherIdentifiers = [] port = nodeChain while port != nodes.Null_Iir: kind = GetIirKindOfNode(port) if kind == nodes.Iir_Kind.Interface_Signal_Declaration: from pyGHDL.dom.InterfaceItem import PortSignalInterfaceItem - portSignal = PortSignalInterfaceItem.parse(port) + portToParse = port # Lookahead for ports with multiple identifiers at once if nodes.Get_Has_Identifier_List(port): @@ -531,7 +534,7 @@ def GetPortsFromChainedNodes( for nextPort in utils.chain_iter(nextNode): # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextPort) == nodes.Null_Iir: - portSignal.Identifiers.append(GetNameOfNode(nextPort)) + furtherIdentifiers.append(GetNameOfNode(nextPort)) else: port = nextPort break @@ -545,7 +548,8 @@ def GetPortsFromChainedNodes( else: port = nodes.Get_Chain(port) - yield portSignal + yield PortSignalInterfaceItem.parse(portToParse, furtherIdentifiers) + furtherIdentifiers.clear() continue else: position = Position.parse(port) @@ -559,25 +563,30 @@ def GetParameterFromChainedNodes( nodeChain: Iir, ) -> Generator[ParameterInterfaceItem, None, None]: + identifiers = [] parameter = nodeChain while parameter != nodes.Null_Iir: kind = GetIirKindOfNode(parameter) if kind == nodes.Iir_Kind.Interface_Constant_Declaration: from pyGHDL.dom.InterfaceItem import ParameterConstantInterfaceItem - param = ParameterConstantInterfaceItem.parse(parameter) + parseMethod = ParameterConstantInterfaceItem.parse + parseNode = parameter elif kind == nodes.Iir_Kind.Interface_Variable_Declaration: from pyGHDL.dom.InterfaceItem import ParameterVariableInterfaceItem - param = ParameterVariableInterfaceItem.parse(parameter) + parseMethod = ParameterVariableInterfaceItem.parse + parseNode = parameter elif kind == nodes.Iir_Kind.Interface_Signal_Declaration: from pyGHDL.dom.InterfaceItem import ParameterSignalInterfaceItem - param = ParameterSignalInterfaceItem.parse(parameter) + parseMethod = ParameterSignalInterfaceItem.parse + parseNode = parameter elif kind == nodes.Iir_Kind.Interface_File_Declaration: from pyGHDL.dom.InterfaceItem import ParameterFileInterfaceItem - param = ParameterFileInterfaceItem.parse(parameter) + parseMethod = ParameterFileInterfaceItem.parse + parseNode = parameter else: position = Position.parse(parameter) raise DOMException( @@ -590,7 +599,7 @@ def GetParameterFromChainedNodes( for nextParameter in utils.chain_iter(nextNode): # Consecutive identifiers are found, if the subtype indication is Null if nodes.Get_Subtype_Indication(nextParameter) == nodes.Null_Iir: - param.Identifiers.append(GetNameOfNode(nextParameter)) + identifiers.append(GetNameOfNode(nextParameter)) else: parameter = nextParameter break @@ -604,7 +613,7 @@ def GetParameterFromChainedNodes( else: parameter = nodes.Get_Chain(parameter) - yield param + yield parseMethod(parseNode, identifiers) def GetMapAspect(mapAspect: Iir, cls: Type, entity: str) -> Generator[AssociationItem, None, None]: @@ -650,6 +659,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,23 +667,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) @@ -782,7 +796,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 @@ -796,7 +810,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( |