aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-08-18 08:20:17 +0200
committerumarcor <unai.martinezcorral@ehu.eus>2021-08-23 16:35:37 +0200
commit89aee29e92c09f9bfa7b01f39233636bbc938915 (patch)
tree7ec8cb60bce4c209fc34c47e3b11f19d09f776ef /pyGHDL/dom
parent324d56b5ab4b1cdd1c43f412d4139a38dcb90eb9 (diff)
downloadghdl-89aee29e92c09f9bfa7b01f39233636bbc938915.tar.gz
ghdl-89aee29e92c09f9bfa7b01f39233636bbc938915.tar.bz2
ghdl-89aee29e92c09f9bfa7b01f39233636bbc938915.zip
Handle subprogram vs. subprogram body.
Diffstat (limited to 'pyGHDL/dom')
-rw-r--r--pyGHDL/dom/_Translate.py52
1 files changed, 45 insertions, 7 deletions
diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py
index ed2e32ce3..6231d93dd 100644
--- a/pyGHDL/dom/_Translate.py
+++ b/pyGHDL/dom/_Translate.py
@@ -712,6 +712,7 @@ def GetDeclaredItemsFromChainedNodes(
nodeChain: Iir, entity: str, name: str
) -> Generator[ModelEntity, None, None]:
item = nodeChain
+ lastKind = None
while item != nodes.Null_Iir:
kind = GetIirKindOfNode(item)
if kind == nodes.Iir_Kind.Constant_Declaration:
@@ -726,7 +727,6 @@ def GetDeclaredItemsFromChainedNodes(
obj = SharedVariable.parse(item)
else:
obj = Variable.parse(item)
- # raise DOMException("Found non-shared variable.")
elif kind == nodes.Iir_Kind.Signal_Declaration:
from pyGHDL.dom.Object import Signal
@@ -746,16 +746,53 @@ def GetDeclaredItemsFromChainedNodes(
yield GetSubtypeFromNode(item)
elif kind == nodes.Iir_Kind.Function_Declaration:
- yield Function.parse(item)
+ if nodes.Get_Has_Body(item):
+ yield Function.parse(item)
+ else:
+ print("[NOT IMPLEMENTED] function declaration without body")
+ lastKind = kind
+ item = nodes.Get_Chain(item)
+ continue
elif kind == nodes.Iir_Kind.Function_Body:
- # procedureName = NodeToName(item)
- print("found function body '{name}'".format(name="????"))
+ if lastKind is nodes.Iir_Kind.Function_Declaration:
+ pass
+ else:
+ position = Position.parse(item)
+ raise DOMException(
+ "Found unexpected function body '{functionName}' in {entity} '{name}' at {file}:{line}:{column}.".format(
+ functionName=GetNameOfNode(item),
+ entity=entity,
+ name=name,
+ file=position.Filename,
+ line=position.Line,
+ column=position.Column,
+ )
+ )
elif kind == nodes.Iir_Kind.Procedure_Declaration:
- yield Procedure.parse(item)
+ if nodes.Get_Has_Body(item):
+ yield Procedure.parse(item)
+ else:
+ print("[NOT IMPLEMENTED] procedure declaration without body")
+
+ lastKind = kind
+ item = nodes.Get_Chain(item)
+ continue
elif kind == nodes.Iir_Kind.Procedure_Body:
- # procedureName = NodeToName(item)
- print("found procedure body '{name}'".format(name="????"))
+ if lastKind is nodes.Iir_Kind.Procedure_Declaration:
+ pass
+ else:
+ position = Position.parse(item)
+ raise DOMException(
+ "Found unexpected procedure body '{functionName}' in {entity} '{name}' at {file}:{line}:{column}.".format(
+ functionName=GetNameOfNode(item),
+ entity=entity,
+ name=name,
+ file=position.Filename,
+ line=position.Line,
+ column=position.Column,
+ )
+ )
elif kind == nodes.Iir_Kind.Protected_Type_Body:
yield ProtectedTypeBody.parse(item)
elif kind == nodes.Iir_Kind.Object_Alias_Declaration:
@@ -819,6 +856,7 @@ def GetDeclaredItemsFromChainedNodes(
)
)
+ lastKind = None
item = nodes.Get_Chain(item)
continue