diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-06-29 14:43:00 +0200 |
---|---|---|
committer | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-07-01 06:39:46 +0200 |
commit | 7f4ed5db5e0e9c0967000d50a4f3f14e88bf9dd7 (patch) | |
tree | daab40c0705985c4b9f723183dfaee90fbaa14e0 /pyGHDL/dom | |
parent | 520f541c3a476bd91e0506c5fa9a3c5eaca5a842 (diff) | |
download | ghdl-7f4ed5db5e0e9c0967000d50a4f3f14e88bf9dd7.tar.gz ghdl-7f4ed5db5e0e9c0967000d50a4f3f14e88bf9dd7.tar.bz2 ghdl-7f4ed5db5e0e9c0967000d50a4f3f14e88bf9dd7.zip |
Renamed '[sS]ubType' to '[sS]ubtype'.
Diffstat (limited to 'pyGHDL/dom')
-rw-r--r-- | pyGHDL/dom/Attribute.py | 16 | ||||
-rw-r--r-- | pyGHDL/dom/Expression.py | 10 | ||||
-rw-r--r-- | pyGHDL/dom/InterfaceItem.py | 52 | ||||
-rw-r--r-- | pyGHDL/dom/Object.py | 64 | ||||
-rw-r--r-- | pyGHDL/dom/Subprogram.py | 8 | ||||
-rw-r--r-- | pyGHDL/dom/Symbol.py | 32 | ||||
-rw-r--r-- | pyGHDL/dom/Type.py | 62 | ||||
-rw-r--r-- | pyGHDL/dom/_Translate.py | 80 | ||||
-rw-r--r-- | pyGHDL/dom/formatting/prettyprint.py | 60 |
9 files changed, 200 insertions, 184 deletions
diff --git a/pyGHDL/dom/Attribute.py b/pyGHDL/dom/Attribute.py index 3fef7494c..62708da43 100644 --- a/pyGHDL/dom/Attribute.py +++ b/pyGHDL/dom/Attribute.py @@ -36,30 +36,30 @@ from pyVHDLModel.VHDLModel import ( Attribute as VHDLModel_Attribute, AttributeSpecification as VHDLModel_AttributeSpecification, Name, - SubTypeOrSymbol, + SubtypeOrSymbol, ) from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import DOMMixin from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode from pyGHDL.dom._Translate import GetNameFromNode -from pyGHDL.dom.Symbol import SimpleSubTypeSymbol +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): + super().__init__(identifier, subtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, attributeNode: Iir) -> "Attribute": name = GetNameOfNode(attributeNode) - subTypeMark = nodes.Get_Type_Mark(attributeNode) - subTypeName = GetNameOfNode(subTypeMark) + subtypeMark = nodes.Get_Type_Mark(attributeNode) + subtypeName = GetNameOfNode(subtypeMark) - subType = SimpleSubTypeSymbol(subTypeMark, subTypeName) - return cls(attributeNode, name, subType) + subtype = SimpleSubtypeSymbol(subtypeMark, subtypeName) + return cls(attributeNode, name, subtype) @export diff --git a/pyGHDL/dom/Expression.py b/pyGHDL/dom/Expression.py index a5af9afc4..972b86ced 100644 --- a/pyGHDL/dom/Expression.py +++ b/pyGHDL/dom/Expression.py @@ -86,7 +86,7 @@ from pyVHDLModel.VHDLModel import ( Aggregate as VHDLModel_Aggregate, Expression, AggregateElement, - SubTypeOrSymbol, + SubtypeOrSymbol, Symbol, ) @@ -94,7 +94,7 @@ from pyGHDL.libghdl import utils from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom._Utils import GetIirKindOfNode -from pyGHDL.dom.Symbol import SimpleSubTypeSymbol +from pyGHDL.dom.Symbol import SimpleSubtypeSymbol from pyGHDL.dom.Aggregates import ( OthersAggregateElement, SimpleAggregateElement, @@ -499,8 +499,8 @@ class RotateLeftExpression( @export class QualifiedExpression(VHDLModel_QualifiedExpression, DOMMixin): - def __init__(self, node: Iir, subType: SubTypeOrSymbol, operand: Expression): - super().__init__(subType, operand) + def __init__(self, node: Iir, subtype: SubtypeOrSymbol, operand: Expression): + super().__init__(subtype, operand) DOMMixin.__init__(self, node) @classmethod @@ -508,7 +508,7 @@ class QualifiedExpression(VHDLModel_QualifiedExpression, DOMMixin): from pyGHDL.dom._Translate import GetExpressionFromNode, GetNameOfNode typeMarkName = GetNameOfNode(nodes.Get_Type_Mark(node)) - subType = SimpleSubTypeSymbol(node, typeMarkName) + subtype = SimpleSubtypeSymbol(node, typeMarkName) operand = GetExpressionFromNode(nodes.Get_Expression(node)) return cls(node, subtype, operand) diff --git a/pyGHDL/dom/InterfaceItem.py b/pyGHDL/dom/InterfaceItem.py index 72f79d694..4ebea735a 100644 --- a/pyGHDL/dom/InterfaceItem.py +++ b/pyGHDL/dom/InterfaceItem.py @@ -44,7 +44,7 @@ from pyVHDLModel.VHDLModel import ( ParameterSignalInterfaceItem as VHDLModel_ParameterSignalInterfaceItem, ParameterFileInterfaceItem as VHDLModel_ParameterFileInterfaceItem, Mode, - SubTypeOrSymbol, + SubtypeOrSymbol, Expression, ) @@ -52,7 +52,7 @@ 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._Translate import GetSubTypeIndicationFromNode, GetExpressionFromNode +from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFromNode __all__ = [] @@ -65,21 +65,21 @@ class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem, DOMMi node: Iir, identifier: str, mode: Mode, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression, ): - super().__init__(identifier, mode, subType, defaultExpression) + super().__init__(identifier, mode, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, genericNode: Iir) -> "GenericConstantInterfaceItem": name = GetNameOfNode(genericNode) mode = GetModeOfNode(genericNode) - subTypeIndication = GetSubTypeIndicationFromNode(genericNode, "generic", name) + 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) @export @@ -157,17 +157,17 @@ class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem, DOMMixin): node: Iir, identifier: str, mode: Mode, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression = None, ): - super().__init__(identifier, mode, subType, defaultExpression) + super().__init__(identifier, mode, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, portNode: Iir) -> "PortSignalInterfaceItem": name = GetNameOfNode(portNode) mode = GetModeOfNode(portNode) - subTypeIndication = GetSubTypeIndicationFromNode(portNode, "port", name) + subtypeIndication = GetSubtypeIndicationFromNode(portNode, "port", name) defaultValue = nodes.Get_Default_Value(portNode) value = ( @@ -176,7 +176,7 @@ class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem, DOMMixin): else None ) - return cls(portNode, name, mode, subTypeIndication, value) + return cls(portNode, name, mode, subtypeIndication, value) @export @@ -188,17 +188,17 @@ class ParameterConstantInterfaceItem( node: Iir, identifier: str, mode: Mode, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression = None, ): - super().__init__(identifier, mode, subType, defaultExpression) + super().__init__(identifier, mode, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterConstantInterfaceItem": name = GetNameOfNode(parameterNode) mode = GetModeOfNode(parameterNode) - subTypeIndication = GetSubTypeIndicationFromNode( + subtypeIndication = GetSubtypeIndicationFromNode( parameterNode, "parameter", name ) @@ -209,7 +209,7 @@ class ParameterConstantInterfaceItem( else None ) - return cls(parameterNode, name, mode, subTypeIndication, value) + return cls(parameterNode, name, mode, subtypeIndication, value) @export @@ -221,17 +221,17 @@ class ParameterVariableInterfaceItem( node: Iir, identifier: str, mode: Mode, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression = None, ): - super().__init__(identifier, mode, subType, defaultExpression) + super().__init__(identifier, mode, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterVariableInterfaceItem": name = GetNameOfNode(parameterNode) mode = GetModeOfNode(parameterNode) - subTypeIndication = GetSubTypeIndicationFromNode( + subtypeIndication = GetSubtypeIndicationFromNode( parameterNode, "parameter", name ) @@ -242,7 +242,7 @@ class ParameterVariableInterfaceItem( else None ) - return cls(parameterNode, name, mode, subTypeIndication, value) + return cls(parameterNode, name, mode, subtypeIndication, value) @export @@ -252,17 +252,17 @@ class ParameterSignalInterfaceItem(VHDLModel_ParameterSignalInterfaceItem, DOMMi node: Iir, identifier: str, mode: Mode, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression = None, ): - super().__init__(identifier, mode, subType, defaultExpression) + super().__init__(identifier, mode, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterSignalInterfaceItem": name = GetNameOfNode(parameterNode) mode = GetModeOfNode(parameterNode) - subTypeIndication = GetSubTypeIndicationFromNode( + subtypeIndication = GetSubtypeIndicationFromNode( parameterNode, "parameter", name ) @@ -273,7 +273,7 @@ class ParameterSignalInterfaceItem(VHDLModel_ParameterSignalInterfaceItem, DOMMi else None ) - return cls(parameterNode, name, mode, subTypeIndication, value) + return cls(parameterNode, name, mode, subtypeIndication, value) @export @@ -282,16 +282,16 @@ class ParameterFileInterfaceItem(VHDLModel_ParameterFileInterfaceItem, DOMMixin) self, node: Iir, identifier: str, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, ): - super().__init__(identifier, subType) + super().__init__(identifier, subtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, parameterNode: Iir) -> "ParameterFileInterfaceItem": name = GetNameOfNode(parameterNode) - subTypeIndication = GetSubTypeIndicationFromNode( + subtypeIndication = GetSubtypeIndicationFromNode( parameterNode, "parameter", name ) - return cls(parameterNode, name, subTypeIndication) + return cls(parameterNode, name, subtypeIndication) diff --git a/pyGHDL/dom/Object.py b/pyGHDL/dom/Object.py index 97bfdaa82..d25acb587 100644 --- a/pyGHDL/dom/Object.py +++ b/pyGHDL/dom/Object.py @@ -43,7 +43,7 @@ from pyVHDLModel.VHDLModel import ( Signal as VHDLModel_Signal, File as VHDLModel_File, Expression, - SubTypeOrSymbol, + SubtypeOrSymbol, ) from pyGHDL.libghdl.vhdl import nodes @@ -59,46 +59,46 @@ class Constant(VHDLModel_Constant, DOMMixin): self, node: Iir, identifier: str, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression, ): - super().__init__(identifier, subType, defaultExpression) + super().__init__(identifier, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, constantNode: Iir) -> Union["Constant", "DeferredConstant"]: from pyGHDL.dom._Translate import ( - GetSubTypeIndicationFromNode, + GetSubtypeIndicationFromNode, GetExpressionFromNode, ) name = GetNameOfNode(constantNode) - subTypeIndication = GetSubTypeIndicationFromNode(constantNode, "constant", name) + 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) else: - return DeferredConstant(constantNode, name, subTypeIndication) + return DeferredConstant(constantNode, name, subtypeIndication) @export class DeferredConstant(VHDLModel_DeferredConstant, DOMMixin): - def __init__(self, node: Iir, identifier: str, subType: SubTypeOrSymbol): - super().__init__(identifier, subType) + def __init__(self, node: Iir, identifier: str, subtype: SubtypeOrSymbol): + super().__init__(identifier, subtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, constantNode: Iir) -> "DeferredConstant": - from pyGHDL.dom._Translate import GetSubTypeIndicationFromNode + from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode name = GetNameOfNode(constantNode) - subTypeIndication = GetSubTypeIndicationFromNode( + subtypeIndication = GetSubtypeIndicationFromNode( constantNode, "deferred constant", name ) - return cls(constantNode, name, subTypeIndication) + return cls(constantNode, name, subtypeIndication) @export @@ -107,43 +107,43 @@ class Variable(VHDLModel_Variable, DOMMixin): self, node: Iir, identifier: str, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression, ): - super().__init__(identifier, subType, defaultExpression) + super().__init__(identifier, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, variableNode: Iir) -> "Variable": from pyGHDL.dom._Translate import ( - GetSubTypeIndicationFromNode, + GetSubtypeIndicationFromNode, GetExpressionFromNode, ) name = GetNameOfNode(variableNode) - subTypeIndication = GetSubTypeIndicationFromNode(variableNode, "variable", name) + 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) @export class SharedVariable(VHDLModel_SharedVariable, DOMMixin): - def __init__(self, node: Iir, identifier: str, subType: SubTypeOrSymbol): - super().__init__(identifier, subType) + def __init__(self, node: Iir, identifier: str, subtype: SubtypeOrSymbol): + super().__init__(identifier, subtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, variableNode: Iir) -> "SharedVariable": - from pyGHDL.dom._Translate import GetSubTypeIndicationFromNode + from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode name = GetNameOfNode(variableNode) - subTypeIndication = GetSubTypeIndicationFromNode(variableNode, "variable", name) + subtypeIndication = GetSubtypeIndicationFromNode(variableNode, "variable", name) - return cls(variableNode, name, subTypeIndication) + return cls(variableNode, name, subtypeIndication) @export @@ -152,40 +152,40 @@ class Signal(VHDLModel_Signal, DOMMixin): self, node: Iir, identifier: str, - subType: SubTypeOrSymbol, + subtype: SubtypeOrSymbol, defaultExpression: Expression, ): - super().__init__(identifier, subType, defaultExpression) + super().__init__(identifier, subtype, defaultExpression) DOMMixin.__init__(self, node) @classmethod def parse(cls, signalNode: Iir) -> "Signal": from pyGHDL.dom._Translate import ( - GetSubTypeIndicationFromNode, + GetSubtypeIndicationFromNode, GetExpressionFromNode, ) name = GetNameOfNode(signalNode) - subTypeIndication = GetSubTypeIndicationFromNode(signalNode, "signal", name) + 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) @export class File(VHDLModel_File, DOMMixin): - def __init__(self, node: Iir, identifier: str, subType: SubTypeOrSymbol): - super().__init__(identifier, subType) + def __init__(self, node: Iir, identifier: str, subtype: SubtypeOrSymbol): + super().__init__(identifier, subtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, fileNode: Iir) -> "File": - from pyGHDL.dom._Translate import GetSubTypeIndicationFromNode + from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode name = GetNameOfNode(fileNode) - subTypeIndication = GetSubTypeIndicationFromNode(fileNode, "file", name) + subtypeIndication = GetSubtypeIndicationFromNode(fileNode, "file", name) # FIXME: handle file open stuff - return cls(fileNode, name, subTypeIndication) + return cls(fileNode, name, subtypeIndication) diff --git a/pyGHDL/dom/Subprogram.py b/pyGHDL/dom/Subprogram.py index 42e3c7d79..e8e5ebbb4 100644 --- a/pyGHDL/dom/Subprogram.py +++ b/pyGHDL/dom/Subprogram.py @@ -37,7 +37,7 @@ from pydecor import export from pyVHDLModel.VHDLModel import ( Function as VHDLModel_Function, Procedure as VHDLModel_Procedure, - SubTypeOrSymbol, + SubtypeOrSymbol, GenericInterfaceItem, ParameterInterfaceItem, ) @@ -45,7 +45,7 @@ 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.Symbol import SimpleSubTypeSymbol +from pyGHDL.dom.Symbol import SimpleSubtypeSymbol @export @@ -54,7 +54,7 @@ class Function(VHDLModel_Function, DOMMixin): self, node: Iir, functionName: str, - returnType: SubTypeOrSymbol, + returnType: SubtypeOrSymbol, genericItems: List[GenericInterfaceItem] = None, parameterItems: List[ParameterInterfaceItem] = None, ): @@ -84,7 +84,7 @@ class Function(VHDLModel_Function, DOMMixin): returnType = nodes.Get_Return_Type_Mark(functionNode) returnTypeName = GetNameOfNode(returnType) - returnTypeSymbol = SimpleSubTypeSymbol(returnType, returnTypeName) + returnTypeSymbol = SimpleSubtypeSymbol(returnType, returnTypeName) return cls(functionNode, functionName, returnTypeSymbol, generics, parameters) diff --git a/pyGHDL/dom/Symbol.py b/pyGHDL/dom/Symbol.py index be8dd362e..3597f2572 100644 --- a/pyGHDL/dom/Symbol.py +++ b/pyGHDL/dom/Symbol.py @@ -36,9 +36,9 @@ from pydecor import export from pyVHDLModel.VHDLModel import ( EntitySymbol as VHDLModel_EntitySymbol, - SimpleSubTypeSymbol as VHDLModel_SimpleSubTypeSymbol, - ConstrainedScalarSubTypeSymbol as VHDLModel_ConstrainedScalarSubTypeSymbol, - ConstrainedCompositeSubTypeSymbol as VHDLModel_ConstrainedCompositeSubTypeSymbol, + SimpleSubtypeSymbol as VHDLModel_SimpleSubtypeSymbol, + ConstrainedScalarSubtypeSymbol as VHDLModel_ConstrainedScalarSubtypeSymbol, + ConstrainedCompositeSubtypeSymbol as VHDLModel_ConstrainedCompositeSubtypeSymbol, SimpleObjectOrFunctionCallSymbol as VHDLModel_SimpleObjectOrFunctionCallSymbol, IndexedObjectOrFunctionCallSymbol as VHDLModel_IndexedObjectOrFunctionCallSymbol, Constraint, @@ -60,21 +60,21 @@ class EntitySymbol(VHDLModel_EntitySymbol, DOMMixin): @export -class SimpleSubTypeSymbol(VHDLModel_SimpleSubTypeSymbol, DOMMixin): - def __init__(self, node: Iir, subTypeName: Name): - if isinstance(subTypeName, (List, Iterator)): - subTypeName = ".".join(subTypeName) +class SimpleSubtypeSymbol(VHDLModel_SimpleSubtypeSymbol, DOMMixin): + def __init__(self, node: Iir, subtypeName: Name): + if isinstance(subtypeName, (List, Iterator)): + subtypeName = ".".join(subtypeName) - super().__init__(subTypeName=subTypeName) + super().__init__(subtypeName=subtypeName) DOMMixin.__init__(self, node) @export -class ConstrainedScalarSubTypeSymbol( - VHDLModel_ConstrainedScalarSubTypeSymbol, DOMMixin +class ConstrainedScalarSubtypeSymbol( + VHDLModel_ConstrainedScalarSubtypeSymbol, DOMMixin ): - def __init__(self, node: Iir, subTypeName: Name, rng: Range = None): - super().__init__(subTypeName, rng) + def __init__(self, node: Iir, subtypeName: Name, rng: Range = None): + super().__init__(subtypeName, rng) DOMMixin.__init__(self, node) @classmethod @@ -83,13 +83,13 @@ class ConstrainedScalarSubTypeSymbol( @export -class ConstrainedCompositeSubTypeSymbol( - VHDLModel_ConstrainedCompositeSubTypeSymbol, DOMMixin +class ConstrainedCompositeSubtypeSymbol( + VHDLModel_ConstrainedCompositeSubtypeSymbol, DOMMixin ): def __init__( - self, node: Iir, subTypeName: Name, constraints: List[Constraint] = None + self, node: Iir, subtypeName: Name, constraints: List[Constraint] = None ): - super().__init__(subTypeName, constraints) + super().__init__(subtypeName, constraints) DOMMixin.__init__(self, node) @classmethod diff --git a/pyGHDL/dom/Type.py b/pyGHDL/dom/Type.py index 3d388956b..efe32afc2 100644 --- a/pyGHDL/dom/Type.py +++ b/pyGHDL/dom/Type.py @@ -55,7 +55,7 @@ from pyGHDL.libghdl._types import Iir from pyGHDL.libghdl.vhdl import nodes from pyGHDL.dom import DOMMixin, DOMException from pyGHDL.dom._Utils import GetNameOfNode, GetIirKindOfNode -from pyGHDL.dom.Symbol import SimpleSubTypeSymbol +from pyGHDL.dom.Symbol import SimpleSubtypeSymbol from pyGHDL.dom.Literal import EnumerationLiteral, PhysicalIntegerLiteral from pyGHDL.dom.Range import Range from pyGHDL.dom.Subprogram import Function, Procedure @@ -138,16 +138,16 @@ class PhysicalType(VHDLModel_PhysicalType, DOMMixin): @export class ArrayType(VHDLModel_ArrayType, DOMMixin): def __init__( - self, node: Iir, identifier: str, indices: List, elementSubType: SubTypeOrSymbol + self, node: Iir, identifier: str, indices: List, elementSubtype: SubtypeOrSymbol ): - super().__init__(identifier, indices, elementSubType) + super().__init__(identifier, indices, elementSubtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, typeName: str, typeDefinitionNode: Iir) -> "ArrayType": from pyGHDL.dom._Translate import ( GetSimpleTypeFromNode, - GetSubTypeIndicationFromIndicationNode, + GetSubtypeIndicationFromIndicationNode, ) indices = [] @@ -155,8 +155,8 @@ class ArrayType(VHDLModel_ArrayType, DOMMixin): for index in utils.flist_iter(indexDefinitions): indexKind = GetIirKindOfNode(index) if indexKind == nodes.Iir_Kind.Simple_Name: - indexSubType = GetSimpleTypeFromNode(index) - indices.append(indexSubType) + indexSubtype = GetSimpleTypeFromNode(index) + indices.append(indexSubtype) else: raise DOMException( "Unknown kind '{kind}' for an index in the array definition of `{typeName}`.".format( @@ -164,28 +164,28 @@ class ArrayType(VHDLModel_ArrayType, DOMMixin): ) ) - elementSubTypeIndication = nodes.Get_Element_Subtype_Indication( + elementSubtypeIndication = nodes.Get_Element_Subtype_Indication( typeDefinitionNode ) - elementSubType = GetSubTypeIndicationFromIndicationNode( - elementSubTypeIndication, "array declaration", typeName + elementSubtype = GetSubtypeIndicationFromIndicationNode( + elementSubtypeIndication, "array declaration", typeName ) - return cls(typeDefinitionNode, typeName, indices, elementSubType) + return cls(typeDefinitionNode, typeName, indices, elementSubtype) @export class RecordTypeElement(VHDLModel_RecordTypeElement, DOMMixin): - def __init__(self, node: Iir, identifier: str, subType: SubTypeOrSymbol): - super().__init__(identifier, subType) + def __init__(self, node: Iir, identifier: str, subtype: SubtypeOrSymbol): + super().__init__(identifier, subtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, elementDeclarationNode: Iir) -> "RecordTypeElement": - from pyGHDL.dom._Translate import GetSubTypeIndicationFromNode + from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode elementName = GetNameOfNode(elementDeclarationNode) - elementType = GetSubTypeIndicationFromNode( + elementType = GetSubtypeIndicationFromNode( elementDeclarationNode, "record element", elementName ) @@ -194,7 +194,9 @@ class RecordTypeElement(VHDLModel_RecordTypeElement, DOMMixin): @export class RecordType(VHDLModel_RecordType, DOMMixin): - def __init__(self, node: Iir, identifier: str, elements: List[RecordTypeElement] = None): + def __init__( + self, node: Iir, identifier: str, elements: List[RecordTypeElement] = None + ): super().__init__(identifier, elements) DOMMixin.__init__(self, node) @@ -211,7 +213,9 @@ class RecordType(VHDLModel_RecordType, DOMMixin): @export class ProtectedType(VHDLModel_ProtectedType, DOMMixin): - def __init__(self, node: Iir, identifier: str, methods: Union[List, Iterator] = None): + def __init__( + self, node: Iir, identifier: str, methods: Union[List, Iterator] = None + ): super().__init__(identifier, methods) DOMMixin.__init__(self, node) @@ -253,44 +257,44 @@ class ProtectedTypeBody(VHDLModel_ProtectedTypeBody, DOMMixin): @export class AccessType(VHDLModel_AccessType, DOMMixin): - def __init__(self, node: Iir, identifier: str, designatedSubType: SubTypeOrSymbol): - super().__init__(identifier, designatedSubType) + def __init__(self, node: Iir, identifier: str, designatedSubtype: SubtypeOrSymbol): + super().__init__(identifier, designatedSubtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, typeName: str, typeDefinitionNode: Iir) -> "AccessType": - from pyGHDL.dom._Translate import GetSubTypeIndicationFromIndicationNode + from pyGHDL.dom._Translate import GetSubtypeIndicationFromIndicationNode designatedSubtypeIndication = nodes.Get_Designated_Subtype_Indication( typeDefinitionNode ) - designatedSubType = GetSubTypeIndicationFromIndicationNode( + designatedSubtype = GetSubtypeIndicationFromIndicationNode( designatedSubtypeIndication, "access type", typeName ) - return cls(typeDefinitionNode, typeName, designatedSubType) + return cls(typeDefinitionNode, typeName, designatedSubtype) @export class FileType(VHDLModel_FileType, DOMMixin): - def __init__(self, node: Iir, identifier: str, designatedSubType: SubTypeOrSymbol): - super().__init__(identifier, designatedSubType) + def __init__(self, node: Iir, identifier: str, designatedSubtype: SubtypeOrSymbol): + super().__init__(identifier, designatedSubtype) DOMMixin.__init__(self, node) @classmethod def parse(cls, typeName: str, typeDefinitionNode: Iir) -> "FileType": - designatedSubTypeMark = nodes.Get_File_Type_Mark(typeDefinitionNode) - designatedSubTypeName = GetNameOfNode(designatedSubTypeMark) - designatedSubType = SimpleSubTypeSymbol( - typeDefinitionNode, designatedSubTypeName + designatedSubtypeMark = nodes.Get_File_Type_Mark(typeDefinitionNode) + designatedSubtypeName = GetNameOfNode(designatedSubtypeMark) + designatedSubtype = SimpleSubtypeSymbol( + typeDefinitionNode, designatedSubtypeName ) - return cls(typeDefinitionNode, typeName, designatedSubType) + return cls(typeDefinitionNode, typeName, designatedSubtype) @export -class SubType(VHDLModel_SubType, DOMMixin): +class Subtype(VHDLModel_Subtype, DOMMixin): def __init__(self, node: Iir, subtypeName: str): super().__init__(subtypeName) DOMMixin.__init__(self, node) diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index 1c97d403e..8229755f3 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -40,7 +40,7 @@ from pyVHDLModel.VHDLModel import ( Constraint, Direction, Expression, - SubTypeOrSymbol, + SubtypeOrSymbol, BaseType, GenericInterfaceItem, PortInterfaceItem, @@ -65,14 +65,14 @@ from pyGHDL.dom.Names import ( ) from pyGHDL.dom.Symbol import ( SimpleObjectOrFunctionCallSymbol, - SimpleSubTypeSymbol, - ConstrainedCompositeSubTypeSymbol, + SimpleSubtypeSymbol, + ConstrainedCompositeSubtypeSymbol, IndexedObjectOrFunctionCallSymbol, - ConstrainedScalarSubTypeSymbol, + ConstrainedScalarSubtypeSymbol, ) from pyGHDL.dom.Type import ( IntegerType, - SubType, + Subtype, ArrayType, RecordType, EnumeratedType, @@ -192,11 +192,11 @@ def GetAssociations(node: Iir) -> List: @export def GetArrayConstraintsFromSubtypeIndication( - subTypeIndication: Iir, + subtypeIndication: Iir, ) -> List[Constraint]: constraints = [] for constraint in utils.flist_iter( - nodes.Get_Index_Constraint_List(subTypeIndication) + nodes.Get_Index_Constraint_List(subtypeIndication) ): constraintKind = GetIirKindOfNode(constraint) if constraintKind == nodes.Iir_Kind.Range_Expression: @@ -214,7 +214,7 @@ def GetArrayConstraintsFromSubtypeIndication( "Unknown constraint kind '{kind}' for constraint '{constraint}' in subtype indication '{indication}' at {file}:{line}:{column}.".format( kind=constraintKind.name, constraint=constraint, - indication=subTypeIndication, + indication=subtypeIndication, file=position.Filename, line=position.Line, column=position.Column, @@ -295,35 +295,35 @@ def GetAnonymousTypeFromNode(node: Iir) -> BaseType: @export -def GetSubTypeIndicationFromNode(node: Iir, entity: str, name: str) -> SubTypeOrSymbol: - subTypeIndicationNode = nodes.Get_Subtype_Indication(node) - # if subTypeIndicationNode is nodes.Null_Iir: +def GetSubtypeIndicationFromNode(node: Iir, entity: str, name: str) -> SubtypeOrSymbol: + subtypeIndicationNode = nodes.Get_Subtype_Indication(node) + # if subtypeIndicationNode is nodes.Null_Iir: # return None - return GetSubTypeIndicationFromIndicationNode(subTypeIndicationNode, entity, name) + return GetSubtypeIndicationFromIndicationNode(subtypeIndicationNode, entity, name) @export -def GetSubTypeIndicationFromIndicationNode( - subTypeIndicationNode: Iir, entity: str, name: str -) -> SubTypeOrSymbol: - if subTypeIndicationNode is nodes.Null_Iir: +def GetSubtypeIndicationFromIndicationNode( + subtypeIndicationNode: Iir, entity: str, name: str +) -> SubtypeOrSymbol: + if subtypeIndicationNode is nodes.Null_Iir: print( "[NOT IMPLEMENTED]: Unhandled multiple declarations for {entity} '{name}'.".format( entity=entity, name=name ) ) return None - kind = GetIirKindOfNode(subTypeIndicationNode) + kind = GetIirKindOfNode(subtypeIndicationNode) if kind in ( nodes.Iir_Kind.Simple_Name, nodes.Iir_Kind.Selected_Name, nodes.Iir_Kind.Attribute_Name, ): - return GetSimpleTypeFromNode(subTypeIndicationNode) + return GetSimpleTypeFromNode(subtypeIndicationNode) elif kind == nodes.Iir_Kind.Subtype_Definition: - return GetScalarConstrainedSubTypeFromNode(subTypeIndicationNode) + return GetScalarConstrainedSubtypeFromNode(subtypeIndicationNode) elif kind == nodes.Iir_Kind.Array_Subtype_Definition: - return GetCompositeConstrainedSubTypeFromNode(subTypeIndicationNode) + return GetCompositeConstrainedSubtypeFromNode(subtypeIndicationNode) else: raise DOMException( "Unknown kind '{kind}' for an subtype indication in a {entity} of `{name}`.".format( @@ -333,40 +333,40 @@ def GetSubTypeIndicationFromIndicationNode( @export -def GetSimpleTypeFromNode(subTypeIndicationNode: Iir) -> SimpleSubTypeSymbol: - subTypeName = GetNameFromNode(subTypeIndicationNode) - return SimpleSubTypeSymbol(subTypeIndicationNode, subTypeName) +def GetSimpleTypeFromNode(subtypeIndicationNode: Iir) -> SimpleSubtypeSymbol: + subtypeName = GetNameFromNode(subtypeIndicationNode) + return SimpleSubtypeSymbol(subtypeIndicationNode, subtypeName) @export -def GetScalarConstrainedSubTypeFromNode( - subTypeIndicationNode: Iir, -) -> ConstrainedScalarSubTypeSymbol: - typeMark = nodes.Get_Subtype_Type_Mark(subTypeIndicationNode) +def GetScalarConstrainedSubtypeFromNode( + subtypeIndicationNode: Iir, +) -> ConstrainedScalarSubtypeSymbol: + typeMark = nodes.Get_Subtype_Type_Mark(subtypeIndicationNode) typeMarkName = GetNameOfNode(typeMark) - rangeConstraint = nodes.Get_Range_Constraint(subTypeIndicationNode) + rangeConstraint = nodes.Get_Range_Constraint(subtypeIndicationNode) r = GetRangeFromNode(rangeConstraint) - return ConstrainedScalarSubTypeSymbol(subTypeIndicationNode, typeMarkName, r) + return ConstrainedScalarSubtypeSymbol(subtypeIndicationNode, typeMarkName, r) @export -def GetCompositeConstrainedSubTypeFromNode( - subTypeIndicationNode: Iir, -) -> ConstrainedCompositeSubTypeSymbol: - typeMark = nodes.Get_Subtype_Type_Mark(subTypeIndicationNode) +def GetCompositeConstrainedSubtypeFromNode( + subtypeIndicationNode: Iir, +) -> ConstrainedCompositeSubtypeSymbol: + typeMark = nodes.Get_Subtype_Type_Mark(subtypeIndicationNode) typeMarkName = GetNameOfNode(typeMark) - constraints = GetArrayConstraintsFromSubtypeIndication(subTypeIndicationNode) - return ConstrainedCompositeSubTypeSymbol( - subTypeIndicationNode, typeMarkName, constraints + constraints = GetArrayConstraintsFromSubtypeIndication(subtypeIndicationNode) + return ConstrainedCompositeSubtypeSymbol( + subtypeIndicationNode, typeMarkName, constraints ) @export -def GetSubTypeFromNode(subTypeNode: Iir) -> SubTypeOrSymbol: - subTypeName = GetNameOfNode(subTypeNode) +def GetSubtypeFromNode(subtypeNode: Iir) -> SubtypeOrSymbol: + subtypeName = GetNameOfNode(subtypeNode) - return SubType(subTypeNode, subTypeName) + return Subtype(subtypeNode, subtypeName) @export @@ -595,7 +595,7 @@ def GetDeclaredItemsFromChainedNodes( yield GetAnonymousTypeFromNode(item) elif kind == nodes.Iir_Kind.Subtype_Declaration: - yield GetSubTypeFromNode(item) + yield GetSubtypeFromNode(item) elif kind == nodes.Iir_Kind.Function_Declaration: yield Function.parse(item) diff --git a/pyGHDL/dom/formatting/prettyprint.py b/pyGHDL/dom/formatting/prettyprint.py index 9fb412d09..4eef043f5 100644 --- a/pyGHDL/dom/formatting/prettyprint.py +++ b/pyGHDL/dom/formatting/prettyprint.py @@ -7,7 +7,7 @@ from pyGHDL.dom.Misc import Alias from pyGHDL.dom.Subprogram import Procedure from pyGHDL.dom.Type import ( IntegerType, - SubType, + Subtype, ArrayType, RecordType, AccessType, @@ -48,8 +48,8 @@ from pyGHDL.dom.InterfaceItem import ( GenericTypeInterfaceItem, ) from pyGHDL.dom.Symbol import ( - SimpleSubTypeSymbol, - ConstrainedCompositeSubTypeSymbol, + SimpleSubtypeSymbol, + ConstrainedCompositeSubtypeSymbol, ) @@ -212,7 +212,9 @@ class PrettyPrint: buffer = [] prefix = " " * level buffer.append( - "{prefix}- Component: {name}".format(name=component.Identifier, prefix=prefix) + "{prefix}- Component: {name}".format( + name=component.Identifier, prefix=prefix + ) ) buffer.append("{prefix} Generics:".format(prefix=prefix)) for generic in component.GenericItems: @@ -228,7 +230,9 @@ class PrettyPrint: def formatPackage(self, package: Package, level: int = 0) -> StringBuffer: buffer = [] prefix = " " * level - buffer.append("{prefix}- Name: {name}".format(name=package.Identifier, prefix=prefix)) + buffer.append( + "{prefix}- Name: {name}".format(name=package.Identifier, prefix=prefix) + ) buffer.append("{prefix} Declared:".format(prefix=prefix)) for item in package.DeclaredItems: for line in self.formatDeclaredItems(item, level + 1): @@ -241,7 +245,9 @@ class PrettyPrint: ) -> StringBuffer: buffer = [] prefix = " " * level - buffer.append("{prefix}- Name: {name}".format(name=package.Identifier, prefix=prefix)) + buffer.append( + "{prefix}- Name: {name}".format(name=package.Identifier, prefix=prefix) + ) buffer.append( "{prefix} Package: {name!s}".format( prefix=prefix, name=package.PackageReference @@ -275,7 +281,9 @@ class PrettyPrint: buffer = [] prefix = " " * level buffer.append( - "{prefix}- Name: {name}".format(name=configuration.Identifier, prefix=prefix) + "{prefix}- Name: {name}".format( + name=configuration.Identifier, prefix=prefix + ) ) return buffer @@ -283,7 +291,9 @@ class PrettyPrint: def formatContext(self, context: Context, level: int = 0) -> StringBuffer: buffer = [] prefix = " " * level - buffer.append("{prefix}- Name: {name}".format(name=context.Identifier, prefix=prefix)) + buffer.append( + "{prefix}- Name: {name}".format(name=context.Identifier, prefix=prefix) + ) return buffer @@ -296,7 +306,9 @@ class PrettyPrint: return self.formatGenericType(generic, level) else: raise PrettyPrintException( - "Unhandled generic kind for generic '{name}'.".format(name=generic.Identifier) + "Unhandled generic kind for generic '{name}'.".format( + name=generic.Identifier + ) ) def formatPort( @@ -321,7 +333,7 @@ class PrettyPrint: name=generic.Identifier, mode=generic.Mode, subtypeindication=self.formatSubtypeIndication( - generic.SubType, "generic", generic.Identifier + generic.Subtype, "generic", generic.Identifier ), initialValue=self.formatInitialValue(generic), ) @@ -356,7 +368,7 @@ class PrettyPrint: name=port.Identifier, mode=port.Mode, subtypeindication=self.formatSubtypeIndication( - port.SubType, "port", port.Identifier + port.Subtype, "port", port.Identifier ), initialValue=self.formatInitialValue(port), ) @@ -374,7 +386,7 @@ class PrettyPrint: prefix=prefix, name=item.Identifier, subtype=self.formatSubtypeIndication( - item.SubType, "constant", item.Identifier + item.Subtype, "constant", item.Identifier ), expr=str(item.DefaultExpression), ) @@ -385,7 +397,7 @@ class PrettyPrint: prefix=prefix, name=item.Identifier, subtype=self.formatSubtypeIndication( - item.SubType, "shared variable", item.Identifier + item.Subtype, "shared variable", item.Identifier ), ) ) @@ -395,7 +407,7 @@ class PrettyPrint: prefix=prefix, name=item.Identifier, subtype=self.formatSubtypeIndication( - item.SubType, "signal", item.Identifier + item.Subtype, "signal", item.Identifier ), initValue=" := {expr}".format(expr=str(item.DefaultExpression)) if item.DefaultExpression is not None @@ -408,7 +420,7 @@ class PrettyPrint: prefix=prefix, name=item.Identifier, subtype=self.formatSubtypeIndication( - item.SubType, "file", item.Identifier + item.Subtype, "file", item.Identifier ), ) ) @@ -416,7 +428,7 @@ class PrettyPrint: buffer.append( "{prefix}- {type}".format(prefix=prefix, type=self.formatType(item)) ) - elif isinstance(item, SubType): + elif isinstance(item, Subtype): buffer.append( "{prefix}- subtype {name} is ?????".format( prefix=prefix, @@ -449,7 +461,7 @@ class PrettyPrint: elif isinstance(item, Attribute): buffer.append( "{prefix}- attribute {name} : {type!s}".format( - prefix=prefix, name=item.Identifier, type=item.SubType + prefix=prefix, name=item.Identifier, type=item.Subtype ) ) elif isinstance(item, AttributeSpecification): @@ -510,21 +522,21 @@ class PrettyPrint: return result - def formatSubtypeIndication(self, subTypeIndication, entity: str, name: str) -> str: - if isinstance(subTypeIndication, SimpleSubTypeSymbol): - return "{type}".format(type=subTypeIndication.SymbolName) - elif isinstance(subTypeIndication, ConstrainedCompositeSubTypeSymbol): + def formatSubtypeIndication(self, subtypeIndication, entity: str, name: str) -> str: + if isinstance(subtypeIndication, SimpleSubtypeSymbol): + return "{type}".format(type=subtypeIndication.SymbolName) + elif isinstance(subtypeIndication, ConstrainedCompositeSubtypeSymbol): constraints = [] - for constraint in subTypeIndication.Constraints: + for constraint in subtypeIndication.Constraints: constraints.append(str(constraint)) return "{type}({constraints})".format( - type=subTypeIndication.SymbolName, constraints=", ".join(constraints) + type=subtypeIndication.SymbolName, constraints=", ".join(constraints) ) else: raise PrettyPrintException( "Unhandled subtype kind '{type}' for {entity} '{name}'.".format( - type=subTypeIndication.__class__.__name__, entity=entity, name=name + type=subtypeIndication.__class__.__name__, entity=entity, name=name ) ) |