summaryrefslogtreecommitdiffstats
path: root/unwind.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-05-07 18:19:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-05-07 18:19:31 -0700
commit7a3280106d04624a00bddb5abdf74485b9d0dee7 (patch)
tree46769937aa27c60cbfa1164c709ee06406e00978 /unwind.h
parent8f1e467559024433853e6ec0a862752c9a546104 (diff)
downloadtxr-7a3280106d04624a00bddb5abdf74485b9d0dee7.tar.gz
txr-7a3280106d04624a00bddb5abdf74485b9d0dee7.tar.bz2
txr-7a3280106d04624a00bddb5abdf74485b9d0dee7.zip
Adding panic macro, which throws a panic exception.
* lib.c (panic_s): New symbol variable. (obj_init): Initialize panic_s. * lib.h (panic_s): Declared. * unwind.c (uw_init): Register panic exception. * unwind.h (panic): New macro.
Diffstat (limited to 'unwind.h')
-rw-r--r--unwind.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/unwind.h b/unwind.h
index fb353b15..615433e3 100644
--- a/unwind.h
+++ b/unwind.h
@@ -235,6 +235,16 @@ noreturn val type_mismatch(val, ...);
nao); \
} while (0)
+#define panic(STR) \
+ do { \
+ extern obj_t *num(cnum); \
+ uw_throwf(panic_s, \
+ lit("~a:~a ~a"), \
+ lit(__FILE__), \
+ num(__LINE__), lit(STR), \
+ nao); \
+ } while (0)
+
#define type_assert(EXPR, ARGS) \
if (!(EXPR)) type_mismatch ARGS