diff options
Diffstat (limited to 'pyGHDL/dom/Object.py')
-rw-r--r-- | pyGHDL/dom/Object.py | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/pyGHDL/dom/Object.py b/pyGHDL/dom/Object.py index 1f1f8f6d9..a5ea4b1ff 100644 --- a/pyGHDL/dom/Object.py +++ b/pyGHDL/dom/Object.py @@ -33,11 +33,13 @@ 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, + DeferredConstant as VHDLModel_DeferredConstant, Variable as VHDLModel_Variable, + SharedVariable as VHDLModel_SharedVariable, Signal as VHDLModel_Signal, Expression, SubTypeOrSymbol, @@ -60,12 +62,28 @@ 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)) - constant = cls(name, subTypeIndication, defaultExpression) + return cls(name, subTypeIndication, defaultExpression) - return constant + +@export +class DeferredConstant(VHDLModel_DeferredConstant): + def __init__(self, name: str, subType: SubTypeOrSymbol): + super().__init__(name) + + self._name = name + self._subType = subType + + @classmethod + def parse(cls, node): + name = GetNameOfNode(node) + subTypeIndication = GetSubTypeIndicationFromNode( + node, "deferred constant", name + ) + + return cls(name, subTypeIndication) @export @@ -82,12 +100,26 @@ 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)) - variable = cls(name, subTypeIndication, defaultExpression) + return cls(name, subTypeIndication, defaultExpression) - return variable + +@export +class SharedVariable(VHDLModel_SharedVariable): + def __init__(self, name: str, subType: SubTypeOrSymbol): + super().__init__(name) + + self._name = name + self._subType = subType + + @classmethod + def parse(cls, node): + name = GetNameOfNode(node) + subTypeIndication = GetSubTypeIndicationFromNode(node, "variable", name) + + return cls(name, subTypeIndication) @export @@ -104,10 +136,8 @@ 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 - signal = cls(name, subTypeIndication, defaultExpression) - - return signal + return cls(name, subTypeIndication, defaultExpression) |