wrap uncaught non-exceptions (issue #664)

This commit is contained in:
Alex Shinn 2020-07-06 16:20:40 +09:00
parent f2d38e36c7
commit 2bdaebe8c7
3 changed files with 9 additions and 4 deletions

View file

@ -597,9 +597,10 @@ struct sexp_struct {
#define SEXP_RAWDOT SEXP_MAKE_IMMEDIATE(7) /* internal use */ #define SEXP_RAWDOT SEXP_MAKE_IMMEDIATE(7) /* internal use */
#define SEXP_STRING_OPORT SEXP_MAKE_IMMEDIATE(8) /* internal use */ #define SEXP_STRING_OPORT SEXP_MAKE_IMMEDIATE(8) /* internal use */
#define SEXP_TRAMPOLINE SEXP_MAKE_IMMEDIATE(9) /* internal use */ #define SEXP_TRAMPOLINE SEXP_MAKE_IMMEDIATE(9) /* internal use */
#define SEXP_ABI_ERROR SEXP_MAKE_IMMEDIATE(10) /* internal use */ #define SEXP_UNCAUGHT SEXP_MAKE_IMMEDIATE(10) /* internal use */
#define SEXP_ABI_ERROR SEXP_MAKE_IMMEDIATE(11) /* internal use */
#if SEXP_USE_OBJECT_BRACE_LITERALS #if SEXP_USE_OBJECT_BRACE_LITERALS
#define SEXP_CLOSE_BRACE SEXP_MAKE_IMMEDIATE(11) /* internal use */ #define SEXP_CLOSE_BRACE SEXP_MAKE_IMMEDIATE(12) /* internal use */
#endif #endif
#if SEXP_USE_LIMITED_MALLOC #if SEXP_USE_LIMITED_MALLOC

5
sexp.c
View file

@ -811,8 +811,9 @@ sexp sexp_print_exception_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn, sexp
sexp_gc_var2(ls, tmp); sexp_gc_var2(ls, tmp);
/* unwrap continuable exceptions */ /* unwrap continuable exceptions */
if (sexp_exceptionp(exn) if (sexp_exceptionp(exn)
&& sexp_exception_kind(exn) == sexp_global(ctx, SEXP_G_CONTINUABLE_SYMBOL) && ((sexp_exception_kind(exn) == sexp_global(ctx, SEXP_G_CONTINUABLE_SYMBOL)
&& sexp_exceptionp(sexp_exception_irritants(exn))) { && sexp_exceptionp(sexp_exception_irritants(exn)))
|| sexp_exception_kind(exn) == SEXP_UNCAUGHT)) {
return sexp_print_exception_op(ctx, self, n, sexp_exception_irritants(exn), out); return sexp_print_exception_op(ctx, self, n, sexp_exception_irritants(exn), out);
} }
sexp_gc_preserve2(ctx, ls, tmp); sexp_gc_preserve2(ctx, ls, tmp);

3
vm.c
View file

@ -1121,6 +1121,9 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) {
#if SEXP_USE_GREEN_THREADS #if SEXP_USE_GREEN_THREADS
sexp_context_errorp(ctx) = 1; sexp_context_errorp(ctx) = 1;
#endif #endif
if (!sexp_exceptionp(_ARG1)) {
_ARG1 = sexp_make_exception(ctx, SEXP_UNCAUGHT, SEXP_FALSE, _ARG1, self, SEXP_FALSE);
}
goto end_loop; goto end_loop;
} }
stack[top] = SEXP_ONE; stack[top] = SEXP_ONE;