aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-23 10:52:13 +0200
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-23 10:52:13 +0200
commit95d5cb9329ee335a64e444ed0fd93bb0950edc5a (patch)
treefa886ee3df41077ee25d393d81628964acfe6a02
parentd4e3bf7941e6826c0175f4768c31155bd5d98b0e (diff)
downloadghdl-95d5cb9329ee335a64e444ed0fd93bb0950edc5a.tar.gz
ghdl-95d5cb9329ee335a64e444ed0fd93bb0950edc5a.tar.bz2
ghdl-95d5cb9329ee335a64e444ed0fd93bb0950edc5a.zip
Removed duplicate function.
-rw-r--r--pyGHDL/dom/InterfaceItem.py12
-rw-r--r--pyGHDL/dom/Object.py12
-rw-r--r--pyGHDL/dom/Type.py14
-rw-r--r--pyGHDL/dom/_Translate.py55
4 files changed, 28 insertions, 65 deletions
diff --git a/pyGHDL/dom/InterfaceItem.py b/pyGHDL/dom/InterfaceItem.py
index e045899da..f720e69b4 100644
--- a/pyGHDL/dom/InterfaceItem.py
+++ b/pyGHDL/dom/InterfaceItem.py
@@ -46,7 +46,7 @@ from pyVHDLModel.VHDLModel import (
from pyGHDL.libghdl.vhdl import nodes
from pyGHDL.libghdl.vhdl.nodes import Null_Iir
from pyGHDL.dom._Utils import GetNameOfNode, GetModeOfNode
-from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFromNode
+from pyGHDL.dom._Translate import GetSubTypeIndicationFromNode, GetExpressionFromNode
__all__ = []
@@ -58,7 +58,7 @@ class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem):
def parse(cls, generic):
name = GetNameOfNode(generic)
mode = GetModeOfNode(generic)
- subTypeIndication = GetSubtypeIndicationFromNode(generic, "generic", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(generic, "generic", name)
default = nodes.Get_Default_Value(generic)
value = GetExpressionFromNode(default) if default else None
@@ -82,7 +82,7 @@ class PortSignalInterfaceItem(VHDLModel_PortSignalInterfaceItem):
def parse(cls, port):
name = GetNameOfNode(port)
mode = GetModeOfNode(port)
- subTypeIndication = GetSubtypeIndicationFromNode(port, "port", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(port, "port", name)
defaultValue = nodes.Get_Default_Value(port)
value = (
@@ -109,7 +109,7 @@ class ParameterConstantInterfaceItem(VHDLModel_ParameterConstantInterfaceItem):
def parse(cls, parameter):
name = GetNameOfNode(parameter)
mode = GetModeOfNode(parameter)
- subTypeIndication = GetSubtypeIndicationFromNode(parameter, "parameter", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(parameter, "parameter", name)
defaultValue = nodes.Get_Default_Value(parameter)
value = (
@@ -136,7 +136,7 @@ class ParameterVariableInterfaceItem(VHDLModel_ParameterVariableInterfaceItem):
def parse(cls, parameter):
name = GetNameOfNode(parameter)
mode = GetModeOfNode(parameter)
- subTypeIndication = GetSubtypeIndicationFromNode(parameter, "parameter", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(parameter, "parameter", name)
defaultValue = nodes.Get_Default_Value(parameter)
value = (
@@ -163,7 +163,7 @@ class ParameterSignalInterfaceItem(VHDLModel_ParameterSignalInterfaceItem):
def parse(cls, parameter):
name = GetNameOfNode(parameter)
mode = GetModeOfNode(parameter)
- subTypeIndication = GetSubtypeIndicationFromNode(parameter, "parameter", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(parameter, "parameter", name)
defaultValue = nodes.Get_Default_Value(parameter)
value = (
diff --git a/pyGHDL/dom/Object.py b/pyGHDL/dom/Object.py
index c8777f722..a5ea4b1ff 100644
--- a/pyGHDL/dom/Object.py
+++ b/pyGHDL/dom/Object.py
@@ -33,7 +33,7 @@
from pyGHDL.libghdl.vhdl import nodes
from pydecor import export
-from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFromNode
+from pyGHDL.dom._Translate import GetSubTypeIndicationFromNode, GetExpressionFromNode
from pyGHDL.dom._Utils import GetNameOfNode
from pyVHDLModel.VHDLModel import (
Constant as VHDLModel_Constant,
@@ -62,7 +62,7 @@ class Constant(VHDLModel_Constant):
@classmethod
def parse(cls, node):
name = GetNameOfNode(node)
- subTypeIndication = GetSubtypeIndicationFromNode(node, "constant", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(node, "constant", name)
defaultExpression = GetExpressionFromNode(nodes.Get_Default_Value(node))
return cls(name, subTypeIndication, defaultExpression)
@@ -79,7 +79,7 @@ class DeferredConstant(VHDLModel_DeferredConstant):
@classmethod
def parse(cls, node):
name = GetNameOfNode(node)
- subTypeIndication = GetSubtypeIndicationFromNode(
+ subTypeIndication = GetSubTypeIndicationFromNode(
node, "deferred constant", name
)
@@ -100,7 +100,7 @@ class Variable(VHDLModel_Variable):
@classmethod
def parse(cls, node):
name = GetNameOfNode(node)
- subTypeIndication = GetSubtypeIndicationFromNode(node, "variable", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(node, "variable", name)
defaultExpression = GetExpressionFromNode(nodes.Get_Default_Value(node))
return cls(name, subTypeIndication, defaultExpression)
@@ -117,7 +117,7 @@ class SharedVariable(VHDLModel_SharedVariable):
@classmethod
def parse(cls, node):
name = GetNameOfNode(node)
- subTypeIndication = GetSubtypeIndicationFromNode(node, "variable", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(node, "variable", name)
return cls(name, subTypeIndication)
@@ -136,7 +136,7 @@ class Signal(VHDLModel_Signal):
@classmethod
def parse(cls, node):
name = GetNameOfNode(node)
- subTypeIndication = GetSubtypeIndicationFromNode(node, "signal", name)
+ subTypeIndication = GetSubTypeIndicationFromNode(node, "signal", name)
default = nodes.Get_Default_Value(node)
defaultExpression = GetExpressionFromNode(default) if default else None
diff --git a/pyGHDL/dom/Type.py b/pyGHDL/dom/Type.py
index 3f43188a6..2875f1bc2 100644
--- a/pyGHDL/dom/Type.py
+++ b/pyGHDL/dom/Type.py
@@ -79,7 +79,7 @@ class ArrayType(VHDLModel_ArrayType):
def parse(cls, typeName: str, typeDefinitionNode: Iir) -> "ArrayType":
from pyGHDL.dom._Translate import (
GetSimpleTypeFromNode,
- GetSubTypeIndicationFromNode,
+ GetSubTypeIndicationFromIndicationNode,
)
indices = []
@@ -99,7 +99,7 @@ class ArrayType(VHDLModel_ArrayType):
elementSubTypeIndication = nodes.Get_Element_Subtype_Indication(
typeDefinitionNode
)
- elementSubType = GetSubTypeIndicationFromNode(
+ elementSubType = GetSubTypeIndicationFromIndicationNode(
elementSubTypeIndication, "array declaration", typeName
)
@@ -110,10 +110,10 @@ class ArrayType(VHDLModel_ArrayType):
class RecordTypeElement(VHDLModel_RecordTypeElement):
@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
)
@@ -137,13 +137,13 @@ class RecordType(VHDLModel_RecordType):
class AccessType(VHDLModel_AccessType):
@classmethod
def parse(cls, typeName: str, typeDefinitionNode: Iir) -> "AccessType":
- from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode
+ from pyGHDL.dom._Translate import GetSubTypeIndicationFromIndicationNode
designatedSubtypeIndication = nodes.Get_Designated_Subtype_Indication(
typeDefinitionNode
)
- designatedSubType = GetSubtypeIndicationFromNode(
- designatedSubtypeIndication, "access type", typeName, do=False
+ designatedSubType = GetSubTypeIndicationFromIndicationNode(
+ designatedSubtypeIndication, "access type", typeName
)
return cls(typeName, designatedSubType)
diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py
index 8627fd5cb..beb13a11c 100644
--- a/pyGHDL/dom/_Translate.py
+++ b/pyGHDL/dom/_Translate.py
@@ -117,51 +117,6 @@ __all__ = []
@export
-def GetSubtypeIndicationFromNode(
- node: Iir, entity: str, name: str, do=True
-) -> SubTypeOrSymbol:
- if do:
- subTypeIndication = nodes.Get_Subtype_Indication(node)
- else:
- subTypeIndication = node
- if subTypeIndication is nodes.Null_Iir:
- return None
- subTypeKind = GetIirKindOfNode(subTypeIndication)
-
- if subTypeKind == nodes.Iir_Kind.Simple_Name:
- subTypeName = GetNameOfNode(subTypeIndication)
-
- subType = SimpleSubTypeSymbol(subTypeName)
- elif subTypeKind == nodes.Iir_Kind.Array_Subtype_Definition:
- typeMark = nodes.Get_Subtype_Type_Mark(subTypeIndication)
- typeMarkName = GetNameOfNode(typeMark)
-
- constraints = GetArrayConstraintsFromSubtypeIndication(subTypeIndication)
- subType = ConstrainedSubTypeSymbol(typeMarkName, constraints)
- elif subTypeKind == nodes.Iir_Kind.Subtype_Definition:
- raise DOMException(
- "Unknown handling of subtype kind '{kind}' of subtype indication '{indication}' while parsing {entity} '{name}'.".format(
- kind=subTypeKind, indication=subTypeIndication, entity=entity, name=name
- )
- )
- else:
- position = GetPositionOfNode(node)
- raise DOMException(
- "Unknown subtype kind '{kind}' of subtype indication '{indication}' while parsing {entity} '{name}' at {file}:{line}:{column}.".format(
- kind=subTypeKind,
- indication=subTypeIndication,
- entity=entity,
- name=name,
- file=position.Filename,
- line=position.Line,
- column=position.Column,
- )
- )
-
- return subType
-
-
-@export
def GetArrayConstraintsFromSubtypeIndication(
subTypeIndication: Iir,
) -> List[Constraint]:
@@ -229,7 +184,15 @@ def GetTypeFromNode(node: Iir) -> BaseType:
@export
-def GetSubTypeIndicationFromNode(
+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)
+
+
+@export
+def GetSubTypeIndicationFromIndicationNode(
subTypeIndicationNode: Iir, entity: str, name: str
) -> SubTypeOrSymbol:
kind = GetIirKindOfNode(subTypeIndicationNode)