[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] pkl: Get rid of string literals as exception names
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] pkl: Get rid of string literals as exception names |
Date: |
Thu, 27 Jan 2022 11:55:59 +0330 |
2022-01-27 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pvm.h (PVM_EXCEPTIONS): New macro.
* libpoke/pvm.jitter (wrapped-globals): Add `pvm_exception_names`.
(PVM_RAISE_DFL): Use `pvm_exception_names` instead of string
literals.
(late-c): Define `pvm_exception_names`.
---
Hello, Jose.
With this patch, I declare ARMv7 as a "supported" platform :)
=== poke Summary ===
# of expected passes 6258
# of unsupported tests 7
Regards,
Mohammad-Reza
etc/pvm-wraps-static-whitelist | 1 +
libpoke/pvm.h | 21 +++++++++++++++++++++
libpoke/pvm.jitter | 9 ++++++++-
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/etc/pvm-wraps-static-whitelist b/etc/pvm-wraps-static-whitelist
index 8886c0a9..5f08f93e 100644
--- a/etc/pvm-wraps-static-whitelist
+++ b/etc/pvm-wraps-static-whitelist
@@ -12,6 +12,7 @@ pvm_literal_invalid_class
pvm_literal_eindex
pvm_literal_notmappable
pvm_literal_newline
+pvm_exception_names
pvm_memcpy
pvm_strlen
pvm_strcpy
diff --git a/libpoke/pvm.h b/libpoke/pvm.h
index 4baee433..0980675e 100644
--- a/libpoke/pvm.h
+++ b/libpoke/pvm.h
@@ -491,6 +491,27 @@ enum pvm_exit_code
/* Exceptions. These should be in sync with the exception code macros
in libpoke.h, and variables and exception names, declared in pkl-rt.pk */
+#define PVM_EXCEPTIONS(E) \
+ E(GENERIC) \
+ E(DIV_BY_ZERO) \
+ E(NO_IOS) \
+ E(NO_RETURN) \
+ E(OUT_OF_BOUNDS) \
+ E(MAP_BOUNDS) \
+ E(EOF) \
+ E(MAP) \
+ E(CONV) \
+ E(ELEM) \
+ E(CONSTRAINT) \
+ E(IO) \
+ E(SIGNAL) \
+ E(IOFLAGS) \
+ E(INVAL) \
+ E(EXIT) \
+ E(ASSERT) \
+ E(OVERFLOW) \
+ E(PERM)
+
#define PVM_E_GENERIC 0
#define PVM_E_GENERIC_NAME "generic"
#define PVM_E_GENERIC_ESTATUS 1
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index 0cb1cf7d..8d95a155 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -163,6 +163,7 @@ wrapped-globals
pvm_literal_notmappable
pvm_literal_newline
libpoke_term_if
+ pvm_exception_names
end
@@ -288,7 +289,7 @@ late-header-c
#define PVM_RAISE_DFL(BASE) \
do \
{ \
- PVM_RAISE (BASE,BASE##_NAME,BASE##_ESTATUS); \
+ PVM_RAISE (BASE,pvm_exception_names[BASE],BASE##_ESTATUS); \
} while (0)
/* Macros to implement different kind of instructions. These are to
@@ -909,6 +910,12 @@ late-c
static const char *pvm_literal_notmappable = "not mappable value";
static const char *pvm_literal_newline = "\n";
+#define E(key) [PVM_E_##key] = PVM_E_##key##_NAME,
+ static const char *pvm_exception_names[] = {
+ PVM_EXCEPTIONS(E)
+ };
+#undef E
+
static int
pvm_nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
{
--
2.34.1
- [PATCH] pkl: Get rid of string literals as exception names,
Mohammad-Reza Nabipoor <=