summaryrefslogtreecommitdiff
path: root/libguile/exceptions.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2019-11-08 15:31:00 +0100
committerAndy Wingo <wingo@pobox.com>2019-11-13 22:24:19 +0100
commitf4ca107f7fe0b6f1ca2c03b558f16077fc89db04 (patch)
tree2e444d63f7ecca2cb4ff5b52890e22aaea0810fe /libguile/exceptions.h
parentf2c8ff5a52eb7073b50151d5d14d2e6ab351fa4f (diff)
downloadguile-f4ca107f7fe0b6f1ca2c03b558f16077fc89db04.tar.gz
Rebase throw/catch on top of raise-exception/with-exception-handler
* libguile/exceptions.c: * libguile/exceptions.h: New files. * libguile.h: Add exceptions.h. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add exceptions.c and exceptions.h. * libguile/init.c (scm_i_init_guile): Initialize exceptions. * libguile/threads.c (scm_spawn_thread): Use new names for scm_i_make_catch_handler and scm_c_make_thunk. * libguile/throw.c: Rewrite to be implemented in terms of with-exception-handler / raise-exception. * libguile/throw.h: Use data types from exceptions.h. Move scm_report_stack_overflow and scm_report_out_of_memory to exceptions.[ch]. * module/ice-9/boot-9.scm (&error, &programming-error) (&non-continuable, make-exception-from-throw, raise-exception) (with-exception-handler): New top-level definitions. (throw, catch, with-throw-handler): Rewrite in terms of with-exception-handler and raise-exception. : New top-level definitions. * module/ice-9/exceptions.scm: Adapt to re-export &error, &programming-error, &non-continuable, raise-exception, and with-exception-handler from boot-9. (make-quit-exception, guile-quit-exception-converter): New exception converters. (make-exception-from-throw): Override core binding. * test-suite/tests/eval.test ("inner trim with prompt tag"): Adapt to "with-exception-handler" being the procedure on the stack. ("outer trim with prompt tag"): Likewise. * test-suite/tests/exceptions.test (throw-test): Use pass-if-equal. * module/srfi/srfi-34.scm: Reimplement in terms of core exceptions, and make "guard" actually re-raise continuations with the original "raise" continuation.
Diffstat (limited to 'libguile/exceptions.h')
-rw-r--r--libguile/exceptions.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/libguile/exceptions.h b/libguile/exceptions.h
new file mode 100644
index 000000000..5f3869bb4
--- /dev/null
+++ b/libguile/exceptions.h
@@ -0,0 +1,65 @@
+#ifndef SCM_EXCEPTIONS_H
+#define SCM_EXCEPTIONS_H
+
+/* Copyright 1995-1996,1998,2000,2006,2008,2010,2014,2017-2019
+ Free Software Foundation, Inc.
+
+ This file is part of Guile.
+
+ Guile is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Guile is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+
+
+#include "libguile/scm.h"
+
+
+
+typedef SCM (*scm_t_thunk) (void *data);
+typedef SCM (*scm_t_exception_handler) (void *data, SCM exn);
+
+SCM_INTERNAL SCM scm_c_make_thunk (scm_t_thunk body,
+ void *body_data);
+SCM_INTERNAL SCM scm_c_make_exception_handler (scm_t_exception_handler h,
+ void *handler_data);
+
+SCM_INTERNAL SCM scm_c_with_exception_handler (SCM type,
+ scm_t_exception_handler handler,
+ void *handler_data,
+ scm_t_thunk thunk,
+ void *thunk_data);
+
+SCM_INTERNAL SCM scm_c_with_default_exception_handler (scm_t_thunk thunk,
+ void *data);
+
+SCM_INTERNAL SCM scm_with_exception_handler (SCM type, SCM handler, SCM thunk);
+SCM_INTERNAL SCM scm_with_pre_unwind_exception_handler (SCM handler, SCM thunk);
+SCM_INTERNAL SCM scm_raise_exception (SCM exn) SCM_NORETURN;
+
+SCM_INTERNAL SCM scm_exception_kind (SCM exn);
+SCM_INTERNAL SCM scm_exception_args (SCM exn);
+
+SCM_INTERNAL void scm_dynwind_throw_handler (void);
+
+/* This raises a `stack-overflow' exception, without running pre-unwind
+ handlers. */
+SCM_API void scm_report_stack_overflow (void);
+
+/* This raises an `out-of-memory' exception, without running pre-unwind
+ handlers. */
+SCM_API void scm_report_out_of_memory (void);
+
+SCM_INTERNAL void scm_init_exceptions (void);
+
+#endif /* SCM_EXCEPTIONS_H */