diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-06-17 13:11:32 +0200 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-06-17 21:34:16 +0200 |
commit | 4ec5cdcd77aa1b6fc384197e1208061d62f16ba2 (patch) | |
tree | 3c386d35b39b001db4e128abda379ddeb5ba7b2c /pyGHDL/dom/Common.py | |
parent | 1eea725dedae1fe3eee47c2b4bfc18c7ac35e806 (diff) | |
download | ghdl-4ec5cdcd77aa1b6fc384197e1208061d62f16ba2.tar.gz ghdl-4ec5cdcd77aa1b6fc384197e1208061d62f16ba2.tar.bz2 ghdl-4ec5cdcd77aa1b6fc384197e1208061d62f16ba2.zip |
Updates to the dom namespace in pyGHDL.
Diffstat (limited to 'pyGHDL/dom/Common.py')
-rw-r--r-- | pyGHDL/dom/Common.py | 57 |
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.") |