aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/Object.py
diff options
context:
space:
mode:
authorUnai Martinez-Corral <38422348+umarcor@users.noreply.github.com>2021-06-23 16:07:10 +0100
committerGitHub <noreply@github.com>2021-06-23 16:07:10 +0100
commitc6283d9a9b40c3e9afeba912fcb13aa9d56b9c52 (patch)
treee1706cb19a2439e3d94657e54c688a36c703f048 /pyGHDL/dom/Object.py
parent983236ac3dfd0c455a0ac910a9a468ea2c81e5d9 (diff)
parent240b4fdd90a9f3ca04e8e168bffdc92bea2ca3f3 (diff)
downloadghdl-c6283d9a9b40c3e9afeba912fcb13aa9d56b9c52.tar.gz
ghdl-c6283d9a9b40c3e9afeba912fcb13aa9d56b9c52.tar.bz2
ghdl-c6283d9a9b40c3e9afeba912fcb13aa9d56b9c52.zip
DOM: Functions and types (#1804)
Diffstat (limited to 'pyGHDL/dom/Object.py')
-rw-r--r--pyGHDL/dom/Object.py52
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)