1
0
forked from M-Labs/artiq

language: sync exception ids and names

This commit is contained in:
abdul124 2024-08-30 14:22:27 +08:00 committed by Sébastien Bourdeauducq
parent f913e2740f
commit bd9648d960
2 changed files with 50 additions and 22 deletions

View File

@ -1,6 +1,27 @@
import builtins
from numpy.linalg import LinAlgError
from artiq.language.core import nac3, UnwrapNoneError from artiq.language.core import nac3, UnwrapNoneError
from builtins import ZeroDivisionError, ValueError, IndexError, RuntimeError, AssertionError
"""
This file provides class definition for all the exceptions declared in `EmbeddingMap` in `artiq.language.embedding_map`
For Python builtin exceptions, use the `builtins` module
For ARTIQ specific exceptions, inherit from `Exception` class
"""
AssertionError = builtins.AssertionError
AttributeError = builtins.AttributeError
IndexError = builtins.IndexError
IOError = builtins.IOError
KeyError = builtins.KeyError
NotImplementedError = builtins.NotImplementedError
OverflowError = builtins.OverflowError
RuntimeError = builtins.RuntimeError
TimeoutError = builtins.TimeoutError
TypeError = builtins.TypeError
ValueError = builtins.ValueError
ZeroDivisionError = builtins.ZeroDivisionError
OSError = builtins.OSError
@nac3 @nac3
class RTIOUnderflow(Exception): class RTIOUnderflow(Exception):

View File

@ -7,10 +7,10 @@ class EmbeddingMap:
self.function_map = {} self.function_map = {}
self.attributes_writeback = [] self.attributes_writeback = []
# preallocate exception names # Keep this list of exceptions in sync with `EXCEPTION_ID_LOOKUP` in `artiq::firmware::ksupport::eh_artiq`
# must be kept in sync with EXCEPTION_ID_LOOKUP in artiq/firmware/ksupport/eh_artiq.rs, # The exceptions declared here must be defined in `artiq.coredevice.exceptions`
# and src/runtime/src/eh_artiq.rs (Zynq) # Verify synchronization by running the test cases in `artiq.test.coredevice.test_exceptions`
self.preallocate_runtime_exception_names(["RuntimeError", self.preallocate_runtime_exception_names([
"RTIOUnderflow", "RTIOUnderflow",
"RTIOOverflow", "RTIOOverflow",
"RTIODestinationUnreachable", "RTIODestinationUnreachable",
@ -18,16 +18,23 @@ class EmbeddingMap:
"I2CError", "I2CError",
"CacheError", "CacheError",
"SPIError", "SPIError",
"0:ZeroDivisionError", "SubkernelError",
"0:IndexError",
"0:ValueError",
"0:RuntimeError",
"0:AssertionError", "0:AssertionError",
"0:AttributeError",
"0:IndexError",
"0:IOError",
"0:KeyError", "0:KeyError",
"0:NotImplementedError", "0:NotImplementedError",
"0:OverflowError", "0:OverflowError",
"0:IOError", "0:RuntimeError",
"0:UnwrapNoneError"]) "0:TimeoutError",
"0:TypeError",
"0:ValueError",
"0:ZeroDivisionError",
"0:LinAlgError",
"UnwrapNoneError",
])
def preallocate_runtime_exception_names(self, names): def preallocate_runtime_exception_names(self, names):
for i, name in enumerate(names): for i, name in enumerate(names):