aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/Common.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyGHDL/dom/Common.py')
-rw-r--r--pyGHDL/dom/Common.py57
1 files changed, 19 insertions, 38 deletions
diff --git a/pyGHDL/dom/Common.py b/pyGHDL/dom/Common.py
index 646e074e5..88d0cdc8c 100644
--- a/pyGHDL/dom/Common.py
+++ b/pyGHDL/dom/Common.py
@@ -1,19 +1,19 @@
# =============================================================================
-# ____ _ _ ____ _ _
-# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
-# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
-# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
-# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
-# |_| |___/
+# ____ _ _ ____ _ _
+# _ __ _ _ / ___| | | | _ \| | __| | ___ _ __ ___
+# | '_ \| | | | | _| |_| | | | | | / _` |/ _ \| '_ ` _ \
+# | |_) | |_| | |_| | _ | |_| | |___ | (_| | (_) | | | | | |
+# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
+# |_| |___/
# =============================================================================
-# Authors:
-# Patrick Lehmann
+# Authors:
+# Patrick Lehmann
#
# Package module: DOM: Common classes for package pyGHDL.dom.
#
# License:
# ============================================================================
-# Copyright (C) 2019-2020 Tristan Gingold
+# Copyright (C) 2019-2021 Tristan Gingold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -37,21 +37,14 @@
"""
from pydecor import export
-from pyVHDLModel.VHDLModel import Mode
-
-from pyGHDL.libghdl import name_table
-from pyGHDL.libghdl.vhdl import nodes
+from pyGHDL import GHDLBaseException
+from pyGHDL.libghdl import LibGHDLException, errorout_memory
__all__ = []
@export
-class GHDLBaseException(Exception):
- pass
-
-
-@export
-class LibGHDLException(GHDLBaseException):
+class DOMException(GHDLBaseException):
pass
@@ -62,23 +55,11 @@ class GHDLException(GHDLBaseException):
@export
class GHDLMixin:
- _MODE_TRANSLATION = {
- nodes.Iir_Mode.In_Mode: Mode.In,
- nodes.Iir_Mode.Out_Mode: Mode.Out,
- nodes.Iir_Mode.Inout_Mode: Mode.InOut,
- nodes.Iir_Mode.Buffer_Mode: Mode.Buffer,
- nodes.Iir_Mode.Linkage_Mode: Mode.Linkage,
- }
-
- @classmethod
- def _ghdlNodeToName(cls, node) -> str:
- """Return the python string from node :obj:`node` identifier"""
- return name_table.Get_Name_Ptr(nodes.Get_Identifier(node))
+ def CheckForErrors(self) -> None:
+ errorCount = errorout_memory.Get_Nbr_Messages()
+ if errorCount != 0:
+ for i in range(errorCount):
+ print(errorout_memory.Get_Error_Message(i + 1))
- @classmethod
- def _ghdlPortToMode(cls, port):
- """Return the mode of a :obj:`port`."""
- try:
- return cls._MODE_TRANSLATION[nodes.Get_Mode(port)]
- except KeyError:
- raise LibGHDLException("Unknown mode.")
+ raise DOMException("Error in libghdl.") \
+ from LibGHDLException("libghdl: Internal error 2.")