diff options
-rw-r--r-- | pyGHDL/dom/Attribute.py | 17 | ||||
-rw-r--r-- | pyGHDL/dom/DesignUnit.py | 54 | ||||
-rw-r--r-- | pyGHDL/dom/InterfaceItem.py | 110 | ||||
-rw-r--r-- | pyGHDL/dom/Misc.py | 16 | ||||
-rw-r--r-- | pyGHDL/dom/NonStandard.py | 11 | ||||
-rw-r--r-- | pyGHDL/dom/Object.py | 90 | ||||
-rw-r--r-- | pyGHDL/dom/Subprogram.py | 16 | ||||
-rw-r--r-- | pyGHDL/dom/Type.py | 10 |
8 files changed, 141 insertions, 183 deletions
diff --git a/pyGHDL/dom/Attribute.py b/pyGHDL/dom/Attribute.py index 86be400ac..576b05245 100644 --- a/pyGHDL/dom/Attribute.py +++ b/pyGHDL/dom/Attribute.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 @@ -46,7 +46,7 @@ from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.libghdl.vhdl.tokens import Tok from pyGHDL.dom import DOMMixin, Position, DOMException, Expression -from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode +from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode, GetDocumentationOfNode from pyGHDL.dom._Translate import GetNameFromNode, GetExpressionFromNode from pyGHDL.dom.Names import SimpleName from pyGHDL.dom.Symbol import SimpleSubtypeSymbol @@ -54,18 +54,19 @@ from pyGHDL.dom.Symbol import SimpleSubtypeSymbol @export class Attribute(VHDLModel_Attribute, DOMMixin): - def __init__(self, node: Iir, identifier: str, subtype: SubtypeOrSymbol): - super().__init__(identifier, subtype) + def __init__(self, node: Iir, identifier: str, subtype: SubtypeOrSymbol, documentation: str = None): + super().__init__(identifier, subtype, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, attributeNode: Iir) -> "Attribute": name = GetNameOfNode(attributeNode) + documentation = GetDocumentationOfNode(attributeNode) subtypeMark = nodes.Get_Type_Mark(attributeNode) subtypeName = GetNameOfNode(subtypeMark) subtype = SimpleSubtypeSymbol(subtypeMark, subtypeName) - return cls(attributeNode, name, subtype) + return cls(attributeNode, name, subtype, documentation) _TOKEN_TRANSLATION = { @@ -102,14 +103,16 @@ class AttributeSpecification(VHDLModel_AttributeSpecification, DOMMixin): attribute: Name, entityClass: EntityClass, expression: Expression, + documentation: str = None ): - super().__init__(identifiers, attribute, entityClass, expression) + super().__init__(identifiers, attribute, entityClass, expression, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, attributeNode: Iir) -> "AttributeSpecification": attributeDesignator = nodes.Get_Attribute_Designator(attributeNode) attributeName = GetNameFromNode(attributeDesignator) + documentation = GetDocumentationOfNode(attributeNode) names = [] entityNameList = nodes.Get_Entity_Name_List(attributeNode) @@ -136,4 +139,4 @@ class AttributeSpecification(VHDLModel_AttributeSpecification, DOMMixin): expression = GetExpressionFromNode(nodes.Get_Expression(attributeNode)) - return cls(attributeNode, names, attributeName, entityClass, expression) + return cls(attributeNode, names, attributeName, entityClass, expression, documentation) diff --git a/pyGHDL/dom/DesignUnit.py b/pyGHDL/dom/DesignUnit.py index f45cb8340..853184450 100644 --- a/pyGHDL/dom/DesignUnit.py +++ b/pyGHDL/dom/DesignUnit.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 @@ -66,7 +66,7 @@ from pyGHDL.libghdl import utils from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import DOMMixin, Position, DOMException -from pyGHDL.dom._Utils import GetNameOfNode +from pyGHDL.dom._Utils import GetNameOfNode, GetDocumentationOfNode from pyGHDL.dom._Translate import ( GetGenericsFromChainedNodes, GetPortsFromChainedNodes, @@ -132,13 +132,15 @@ class Entity(VHDLModel_Entity, DOMMixin): portItems: Iterable[PortInterfaceItem] = None, declaredItems: Iterable = None, statements: Iterable["ConcurrentStatement"] = None, + documentation: str = None ): - super().__init__(identifier, contextItems, genericItems, portItems, declaredItems, statements) + super().__init__(identifier, contextItems, genericItems, portItems, declaredItems, statements, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, entityNode: Iir, contextItems: Iterable[ContextUnion]): name = GetNameOfNode(entityNode) + documentation = GetDocumentationOfNode(entityNode) generics = GetGenericsFromChainedNodes(nodes.Get_Generic_Chain(entityNode)) ports = GetPortsFromChainedNodes(nodes.Get_Port_Chain(entityNode)) declaredItems = GetDeclaredItemsFromChainedNodes(nodes.Get_Declaration_Chain(entityNode), "entity", name) @@ -148,7 +150,7 @@ class Entity(VHDLModel_Entity, DOMMixin): # FIXME: read use clauses - return cls(entityNode, name, contextItems, generics, ports, declaredItems, statements) + return cls(entityNode, name, contextItems, generics, ports, declaredItems, statements, documentation) @export @@ -161,13 +163,15 @@ class Architecture(VHDLModel_Architecture, DOMMixin): contextItems: Iterable[ContextUnion] = None, declaredItems: Iterable = None, statements: Iterable["ConcurrentStatement"] = None, + documentation: str = None ): - super().__init__(identifier, entity, contextItems, declaredItems, statements) + super().__init__(identifier, entity, contextItems, declaredItems, statements, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, architectureNode: Iir, contextItems: Iterable[ContextUnion]): name = GetNameOfNode(architectureNode) + documentation = GetDocumentationOfNode(architectureNode) entityNameNode = nodes.Get_Entity_Name(architectureNode) entityName = GetNameOfNode(entityNameNode) entity = EntitySymbol(entityNameNode, SimpleName(entityNameNode, entityName)) @@ -180,7 +184,7 @@ class Architecture(VHDLModel_Architecture, DOMMixin): # FIXME: read use clauses - return cls(architectureNode, name, entity, contextItems, declaredItems, statements) + return cls(architectureNode, name, entity, contextItems, declaredItems, statements, documentation) @export @@ -191,17 +195,19 @@ class Component(VHDLModel_Component, DOMMixin): identifier: str, genericItems: Iterable[GenericInterfaceItem] = None, portItems: Iterable[PortInterfaceItem] = None, + documentation: str = None ): - super().__init__(identifier, genericItems, portItems) + super().__init__(identifier, genericItems, portItems, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, componentNode: Iir): name = GetNameOfNode(componentNode) + documentation = GetDocumentationOfNode(componentNode) generics = GetGenericsFromChainedNodes(nodes.Get_Generic_Chain(componentNode)) ports = GetPortsFromChainedNodes(nodes.Get_Port_Chain(componentNode)) - return cls(componentNode, name, generics, ports) + return cls(componentNode, name, generics, ports, documentation) @export @@ -213,13 +219,15 @@ class Package(VHDLModel_Package, DOMMixin): contextItems: Iterable[ContextUnion] = None, genericItems: Iterable[GenericInterfaceItem] = None, declaredItems: Iterable = None, + documentation: str = None ): - super().__init__(identifier, contextItems, genericItems, declaredItems) + super().__init__(identifier, contextItems, genericItems, declaredItems, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, packageNode: Iir, contextItems: Iterable[ContextUnion]): name = GetNameOfNode(packageNode) + documentation = GetDocumentationOfNode(packageNode) packageHeader = nodes.Get_Package_Header(packageNode) if packageHeader is not nodes.Null_Iir: @@ -231,7 +239,7 @@ class Package(VHDLModel_Package, DOMMixin): # FIXME: read use clauses - return cls(packageNode, name, contextItems, generics, declaredItems) + return cls(packageNode, name, contextItems, generics, declaredItems, documentation) @export @@ -242,18 +250,20 @@ class PackageBody(VHDLModel_PackageBody, DOMMixin): identifier: str, contextItems: Iterable[ContextUnion] = None, declaredItems: Iterable = None, + documentation: str = None ): - super().__init__(identifier, contextItems, declaredItems) + super().__init__(identifier, contextItems, declaredItems, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, packageBodyNode: Iir, contextItems: Iterable[ContextUnion]): name = GetNameOfNode(packageBodyNode) + documentation = GetDocumentationOfNode(packageBodyNode) declaredItems = GetDeclaredItemsFromChainedNodes(nodes.Get_Declaration_Chain(packageBodyNode), "package", name) # FIXME: read use clauses - return cls(packageBodyNode, name, contextItems, declaredItems) + return cls(packageBodyNode, name, contextItems, declaredItems, documentation) @export @@ -264,13 +274,15 @@ class PackageInstantiation(VHDLModel_PackageInstantiation, DOMMixin): identifier: str, uninstantiatedPackageName: Name, # genericItems: List[GenericInterfaceItem] = None, + documentation: str = None ): - super().__init__(identifier, uninstantiatedPackageName) + super().__init__(identifier, uninstantiatedPackageName, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, packageNode: Iir): name = GetNameOfNode(packageNode) + documentation = GetDocumentationOfNode(packageNode) uninstantiatedPackageName = nodes.Get_Uninstantiated_Package_Name(packageNode) # FIXME: read use clauses (does it apply here too?) @@ -278,7 +290,7 @@ class PackageInstantiation(VHDLModel_PackageInstantiation, DOMMixin): # FIXME: read generic map # genericAssociations = GetGenericMapAspect(nodes.Get_Generic_Map_Aspect_Chain(instantiationNode)) - return cls(packageNode, name, uninstantiatedPackageName) + return cls(packageNode, name, uninstantiatedPackageName, documentation) @export @@ -289,8 +301,9 @@ class Context(VHDLModel_Context, DOMMixin): identifier: str, libraryReferences: Iterable[LibraryClause] = None, packageReferences: Iterable[UseClause] = None, + documentation: str = None ): - super().__init__(identifier, libraryReferences, packageReferences) + super().__init__(identifier, libraryReferences, packageReferences, documentation) DOMMixin.__init__(self, node) @classmethod @@ -298,6 +311,7 @@ class Context(VHDLModel_Context, DOMMixin): from pyGHDL.dom._Utils import GetIirKindOfNode name = GetNameOfNode(contextNode) + documentation = GetDocumentationOfNode(contextNode) items = [] names = [] @@ -316,7 +330,7 @@ class Context(VHDLModel_Context, DOMMixin): pos = Position.parse(item) raise DOMException(f"Unknown context item kind '{kind.name}' in context at line {pos.Line}.") - return cls(contextNode, name, items) + return cls(contextNode, name, items, documentation) @export @@ -326,15 +340,17 @@ class Configuration(VHDLModel_Configuration, DOMMixin): node: Iir, identifier: str, contextItems: Iterable[Context] = None, + documentation: str = None ): - super().__init__(identifier, contextItems) + super().__init__(identifier, contextItems, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, configurationNode: Iir, contextItems: Iterable[Context]): - name = GetNameOfNode(configurationNode) + name = GetNameOfNode(configurationNode), + documentation = GetDocumentationOfNode(configurationNode) # FIXME: read use clauses # FIXME: read specifications - return cls(configurationNode, name, contextItems) + return cls(configurationNode, name, contextItems, documentation) diff --git a/pyGHDL/dom/InterfaceItem.py b/pyGHDL/dom/InterfaceItem.py index 66a8fe37b..e42c8dcb2 100644 --- a/pyGHDL/dom/InterfaceItem.py +++ b/pyGHDL/dom/InterfaceItem.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 @@ -53,7 +53,7 @@ from pyVHDLModel.SyntaxModel import ( from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import DOMMixin -from pyGHDL.dom._Utils import GetNameOfNode, GetModeOfNode +from pyGHDL.dom._Utils import GetNameOfNode, GetModeOfNode, GetDocumentationOfNode from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFromNode @@ -69,27 +69,21 @@ class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem, DOMMi mode: Mode, subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion, + documentation: str = None ): - super().__init__(identifiers, mode, subtype, defaultExpression) + super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, genericNode: Iir) -> "GenericConstantInterfaceItem": name = GetNameOfNode(genericNode) + documentation = GetDocumentationOfNode(genericNode) mode = GetModeOfNode(genericNode) subtypeIndication = GetSubtypeIndicationFromNode(genericNode, "generic", name) default = nodes.Get_Default_Value(genericNode) value = GetExpressionFromNode(default) if default else None - return cls( - genericNode, - [ - name, - ], - mode, - subtypeIndication, - value, - ) + return cls(genericNode, [name], mode, subtypeIndication, value, documentation) @export @@ -98,15 +92,17 @@ class GenericTypeInterfaceItem(VHDLModel_GenericTypeInterfaceItem, DOMMixin): self, node: Iir, identifier: str, + documentation: str = None ): - super().__init__(identifier) + super().__init__(identifier, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, genericNode: Iir) -> "GenericTypeInterfaceItem": name = GetNameOfNode(genericNode) + documentation = GetDocumentationOfNode(genericNode) - return cls(genericNode, name) + return cls(genericNode, name, documentation) @export @@ -115,15 +111,17 @@ class GenericPackageInterfaceItem(VHDLModel_GenericPackageInterfaceItem, DOMMixi self, node: Iir, name: str, + documentation: str = None ): - super().__init__(name) + super().__init__(name, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, genericNode: Iir) -> "GenericPackageInterfaceItem": name = GetNameOfNode(genericNode) + documentation = GetDocumentationOfNode(genericNode) - return cls(genericNode, name) + return cls(genericNode, name, documentation) @export @@ -132,15 +130,17 @@ class GenericProcedureInterfaceItem(VHDLModel_GenericProcedureInterfaceItem, DOM self, node: Iir, identifier: str, + documentation: str = None ): - super().__init__(identifier) + super().__init__(identifier, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, genericNode: Iir) -> "GenericProcedureInterfaceItem": name = GetNameOfNode(genericNode) + documentation = GetDocumentationOfNode(genericNode) - return cls(genericNode, name) + return cls(genericNode, name, documentation) @export @@ -149,15 +149,17 @@ class GenericFunctionInterfaceItem(VHDLModel_GenericFunctionInterfaceItem, DOMMi self, node: Iir, identifier: str, + documentation: str = None ): - super().__init__(identifier) + super().__init__(identifier, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, genericNode: Iir) -> "GenericFunctionInterfaceItem": name = GetNameOfNode(genericNode) + documentation = GetDocumentationOfNode(genericNode) - return cls(genericNode, name) + return cls(genericNode, name, documentation) @export @@ -169,28 +171,22 @@ class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem, DOMMixin): mode: Mode, subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion = None, + documentation: str = None ): - super().__init__(identifiers, mode, subtype, defaultExpression) + super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, portNode: Iir) -> "PortSignalInterfaceItem": name = GetNameOfNode(portNode) + documentation = GetDocumentationOfNode(portNode) mode = GetModeOfNode(portNode) subtypeIndication = GetSubtypeIndicationFromNode(portNode, "port", name) defaultValue = nodes.Get_Default_Value(portNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None - return cls( - portNode, - [ - name, - ], - mode, - subtypeIndication, - value, - ) + return cls(portNode, [name], mode, subtypeIndication, value, documentation) @export @@ -202,28 +198,22 @@ class ParameterConstantInterfaceItem(VHDLModel_ParameterConstantInterfaceItem, D mode: Mode, subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion = None, + documentation: str = None ): - super().__init__(identifiers, mode, subtype, defaultExpression) + super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterConstantInterfaceItem": name = GetNameOfNode(parameterNode) + documentation = GetDocumentationOfNode(parameterNode) mode = GetModeOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) defaultValue = nodes.Get_Default_Value(parameterNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None - return cls( - parameterNode, - [ - name, - ], - mode, - subtypeIndication, - value, - ) + return cls(parameterNode, [name], mode, subtypeIndication, value, documentation) @export @@ -235,28 +225,22 @@ class ParameterVariableInterfaceItem(VHDLModel_ParameterVariableInterfaceItem, D mode: Mode, subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion = None, + documentation: str = None ): - super().__init__(identifiers, mode, subtype, defaultExpression) + super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterVariableInterfaceItem": name = GetNameOfNode(parameterNode) + documentation = GetDocumentationOfNode(parameterNode) mode = GetModeOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) defaultValue = nodes.Get_Default_Value(parameterNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None - return cls( - parameterNode, - [ - name, - ], - mode, - subtypeIndication, - value, - ) + return cls(parameterNode, [name], mode, subtypeIndication, value, documentation) @export @@ -268,28 +252,22 @@ class ParameterSignalInterfaceItem(VHDLModel_ParameterSignalInterfaceItem, DOMMi mode: Mode, subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion = None, + documentation: str = None ): - super().__init__(identifiers, mode, subtype, defaultExpression) + super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterSignalInterfaceItem": name = GetNameOfNode(parameterNode) + documentation = GetDocumentationOfNode(parameterNode) mode = GetModeOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) defaultValue = nodes.Get_Default_Value(parameterNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None - return cls( - parameterNode, - [ - name, - ], - mode, - subtypeIndication, - value, - ) + return cls(parameterNode, [name], mode, subtypeIndication, value, documentation) @export @@ -299,19 +277,15 @@ class ParameterFileInterfaceItem(VHDLModel_ParameterFileInterfaceItem, DOMMixin) node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol, + documentation: str = None ): - super().__init__(identifiers, subtype) + super().__init__(identifiers, subtype, documentation) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterFileInterfaceItem": name = GetNameOfNode(parameterNode) + documentation = GetDocumentationOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) - return cls( - parameterNode, - [ - name, - ], - subtypeIndication, - ) + return cls(parameterNode, [name], subtypeIndication, documentation) diff --git a/pyGHDL/dom/Misc.py b/pyGHDL/dom/Misc.py index d6fc08524..8f85db222 100644 --- a/pyGHDL/dom/Misc.py +++ b/pyGHDL/dom/Misc.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 @@ -42,22 +42,22 @@ from pyVHDLModel.SyntaxModel import ( ) from pyGHDL.libghdl._types import Iir from pyGHDL.dom import DOMMixin -from pyGHDL.dom._Utils import GetNameOfNode - +from pyGHDL.dom._Utils import GetNameOfNode, GetDocumentationOfNode __all__ = [] @export class Alias(VHDLModel_Alias, DOMMixin): - def __init__(self, node: Iir, aliasName: str): - super().__init__(aliasName) + def __init__(self, node: Iir, aliasName: str, documentation: str = None): + super().__init__(aliasName, documentation) DOMMixin.__init__(self, node) @classmethod - def parse(cls, node: Iir): - aliasName = GetNameOfNode(node) + def parse(cls, aliasNode: Iir): + aliasName = GetNameOfNode(aliasNode) + documentation = GetDocumentationOfNode(aliasNode) # FIXME: add an implementation - return cls(node, aliasName) + return cls(aliasNode, aliasName) diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index c55786d54..7a38d60ce 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.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 @@ -42,7 +42,6 @@ from typing import Any from pyTooling.Decorators import export -from pyGHDL.dom.Names import SimpleName from pyVHDLModel.SyntaxModel import ( Design as VHDLModel_Design, Library as VHDLModel_Library, @@ -61,9 +60,12 @@ from pyGHDL.libghdl import ( utils, files_map_editor, ) -from pyGHDL.libghdl.vhdl import nodes, sem_lib, parse +from pyGHDL.libghdl.flags import Flag_Gather_Comments +from pyGHDL.libghdl.vhdl import nodes, sem_lib +from pyGHDL.libghdl.vhdl.parse import Flag_Parse_Parenthesis from pyGHDL.dom import DOMException, Position from pyGHDL.dom._Utils import GetIirKindOfNode, CheckForErrors, GetNameOfNode +from pyGHDL.dom.Names import SimpleName from pyGHDL.dom.DesignUnit import ( Entity, Architecture, @@ -100,7 +102,8 @@ class Design(VHDLModel_Design): libghdl_set_option("--std=08") libghdl_set_option("--ams") - parse.Flag_Parse_Parenthesis.value = True + Flag_Gather_Comments.value = True + Flag_Parse_Parenthesis.value = True # Finish initialization. This will load the standard package. if libghdl_analyze_init_status() != 0: diff --git a/pyGHDL/dom/Object.py b/pyGHDL/dom/Object.py index 6d3472a6f..162bc8bef 100644 --- a/pyGHDL/dom/Object.py +++ b/pyGHDL/dom/Object.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 @@ -48,7 +48,7 @@ from pyVHDLModel.SyntaxModel import ( from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import DOMMixin -from pyGHDL.dom._Utils import GetNameOfNode +from pyGHDL.dom._Utils import GetNameOfNode, GetDocumentationOfNode __all__ = [] @@ -61,8 +61,9 @@ class Constant(VHDLModel_Constant, DOMMixin): identifiers: List[str], subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion, + documentation: str = None ): - super().__init__(identifiers, subtype, defaultExpression) + super().__init__(identifiers, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod @@ -73,33 +74,21 @@ class Constant(VHDLModel_Constant, DOMMixin): ) name = GetNameOfNode(constantNode) + 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, - ) + return cls(constantNode, [name], subtypeIndication, defaultExpression, documentation) else: - return DeferredConstant( - constantNode, - [ - name, - ], - subtypeIndication, - ) + return DeferredConstant(constantNode, [name], subtypeIndication, documentation) @export class DeferredConstant(VHDLModel_DeferredConstant, DOMMixin): - def __init__(self, node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol): - super().__init__(identifiers, subtype) + def __init__(self, node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol, documentation: str = None): + super().__init__(identifiers, subtype, documentation) DOMMixin.__init__(self, node) @classmethod @@ -107,15 +96,10 @@ class DeferredConstant(VHDLModel_DeferredConstant, DOMMixin): from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode name = GetNameOfNode(constantNode) + documentation = GetDocumentationOfNode(constantNode) subtypeIndication = GetSubtypeIndicationFromNode(constantNode, "deferred constant", name) - return cls( - constantNode, - [ - name, - ], - subtypeIndication, - ) + return cls(constantNode, [name], subtypeIndication, documentation) @export @@ -126,8 +110,9 @@ class Variable(VHDLModel_Variable, DOMMixin): identifiers: List[str], subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion, + documentation: str = None ): - super().__init__(identifiers, subtype, defaultExpression) + super().__init__(identifiers, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod @@ -138,26 +123,20 @@ class Variable(VHDLModel_Variable, DOMMixin): ) name = GetNameOfNode(variableNode) + documentation = GetDocumentationOfNode(variableNode) subtypeIndication = GetSubtypeIndicationFromNode(variableNode, "variable", name) defaultValue = nodes.Get_Default_Value(variableNode) defaultExpression = None if defaultValue != nodes.Null_Iir: defaultExpression = GetExpressionFromNode(defaultValue) - return cls( - variableNode, - [ - name, - ], - subtypeIndication, - defaultExpression, - ) + return cls(variableNode, [name], subtypeIndication, defaultExpression, documentation) @export class SharedVariable(VHDLModel_SharedVariable, DOMMixin): - def __init__(self, node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol): - super().__init__(identifiers, subtype) + def __init__(self, node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol, documentation: str = None): + super().__init__(identifiers, subtype, documentation) DOMMixin.__init__(self, node) @classmethod @@ -165,15 +144,10 @@ class SharedVariable(VHDLModel_SharedVariable, DOMMixin): from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode name = GetNameOfNode(variableNode) + documentation = GetDocumentationOfNode(variableNode) subtypeIndication = GetSubtypeIndicationFromNode(variableNode, "variable", name) - return cls( - variableNode, - [ - name, - ], - subtypeIndication, - ) + return cls(variableNode, [name], subtypeIndication, documentation) @export @@ -184,8 +158,9 @@ class Signal(VHDLModel_Signal, DOMMixin): identifiers: List[str], subtype: SubtypeOrSymbol, defaultExpression: ExpressionUnion, + documentation: str = None ): - super().__init__(identifiers, subtype, defaultExpression) + super().__init__(identifiers, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node) @classmethod @@ -196,24 +171,18 @@ class Signal(VHDLModel_Signal, DOMMixin): ) name = GetNameOfNode(signalNode) + 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, - ) + return cls(signalNode, [name], subtypeIndication, defaultExpression, documentation) @export class File(VHDLModel_File, DOMMixin): - def __init__(self, node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol): - super().__init__(identifiers, subtype) + def __init__(self, node: Iir, identifiers: List[str], subtype: SubtypeOrSymbol, documentation: str = None): + super().__init__(identifiers, subtype, documentation) DOMMixin.__init__(self, node) @classmethod @@ -221,14 +190,9 @@ class File(VHDLModel_File, DOMMixin): from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode name = GetNameOfNode(fileNode) + documentation = GetDocumentationOfNode(fileNode) subtypeIndication = GetSubtypeIndicationFromNode(fileNode, "file", name) # FIXME: handle file open stuff - return cls( - fileNode, - [ - name, - ], - subtypeIndication, - ) + return cls(fileNode, [name], subtypeIndication, documentation) diff --git a/pyGHDL/dom/Subprogram.py b/pyGHDL/dom/Subprogram.py index 2e9c0116f..ba7ee035a 100644 --- a/pyGHDL/dom/Subprogram.py +++ b/pyGHDL/dom/Subprogram.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 @@ -44,7 +44,7 @@ from pyVHDLModel.SyntaxModel import ( from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import DOMMixin -from pyGHDL.dom._Utils import GetNameOfNode +from pyGHDL.dom._Utils import GetNameOfNode, GetDocumentationOfNode from pyGHDL.dom.Symbol import SimpleSubtypeSymbol @@ -57,8 +57,9 @@ class Function(VHDLModel_Function, DOMMixin): returnType: SubtypeOrSymbol, genericItems: List[GenericInterfaceItem] = None, parameterItems: List[ParameterInterfaceItem] = None, + documentation: str = None ): - super().__init__(functionName) + super().__init__(functionName, documentation) DOMMixin.__init__(self, node) # TODO: move to model @@ -74,6 +75,7 @@ class Function(VHDLModel_Function, DOMMixin): ) functionName = GetNameOfNode(functionNode) + documentation = GetDocumentationOfNode(functionNode) generics = GetGenericsFromChainedNodes(nodes.Get_Generic_Chain(functionNode)) parameters = GetParameterFromChainedNodes(nodes.Get_Interface_Declaration_Chain(functionNode)) @@ -82,7 +84,7 @@ class Function(VHDLModel_Function, DOMMixin): returnTypeName = GetNameOfNode(returnType) returnTypeSymbol = SimpleSubtypeSymbol(returnType, returnTypeName) - return cls(functionNode, functionName, returnTypeSymbol, generics, parameters) + return cls(functionNode, functionName, returnTypeSymbol, generics, parameters, documentation) @export @@ -93,8 +95,9 @@ class Procedure(VHDLModel_Procedure, DOMMixin): procedureName: str, genericItems: List[GenericInterfaceItem] = None, parameterItems: List[ParameterInterfaceItem] = None, + documentation: str = None ): - super().__init__(procedureName) + super().__init__(procedureName, documentation) DOMMixin.__init__(self, node) # TODO: move to model @@ -109,8 +112,9 @@ class Procedure(VHDLModel_Procedure, DOMMixin): ) procedureName = GetNameOfNode(procedureNode) + documentation = GetDocumentationOfNode(procedureNode) generics = GetGenericsFromChainedNodes(nodes.Get_Generic_Chain(procedureNode)) parameters = GetParameterFromChainedNodes(nodes.Get_Interface_Declaration_Chain(procedureNode)) - return cls(procedureNode, procedureName, generics, parameters) + return cls(procedureNode, procedureName, generics, parameters, documentation) diff --git a/pyGHDL/dom/Type.py b/pyGHDL/dom/Type.py index b0f2d1311..555a4b1ae 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 @@ -192,13 +192,7 @@ class RecordTypeElement(VHDLModel_RecordTypeElement, DOMMixin): elementName = GetNameOfNode(elementDeclarationNode) elementType = GetSubtypeIndicationFromNode(elementDeclarationNode, "record element", elementName) - return cls( - elementDeclarationNode, - [ - elementName, - ], - elementType, - ) + return cls(elementDeclarationNode, [elementName], elementType,) @export |