From 3dba6ca7c542fefb2124340f948a0b10eea94b91 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 7 Apr 2020 06:36:04 -0700 Subject: exceptions: use uw_rthrow for non-error exceptions. * eval.c (eval_exception): This function is shared by warnings and errors. Use uw_throw. The eval_error caller already has an abort() after its eval_exception call, which makes that code path continue to be equivalent to uw_throw. The behavior changes for the other caller, eval_warn, which will now return if the warning is not handled. (eval_defr_warn, gather_free_refs, gather_free_refs_nw): Throw non-error exception with uw_rthrow. * match.c (v_throw, v_assert, h_assert): Use uw_rthrow for these directives, just like the throw function. * parser.c (repl_intr, repl_warning): Use uw_rthrow. * unwind.c (uw_muffle_warning, uw_release_deferred_warnings): Likewise. --- eval.c | 12 ++++++------ match.c | 6 +++--- parser.c | 4 ++-- unwind.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/eval.c b/eval.c index 997ddf08..b2954e91 100644 --- a/eval.c +++ b/eval.c @@ -283,7 +283,7 @@ val ctx_name(val obj) return nil; } -noreturn static void eval_exception(val sym, val ctx, val fmt, va_list vl) +static void eval_exception(val sym, val ctx, val fmt, va_list vl) { uses_or2; val form = ctx_form(ctx); @@ -298,7 +298,7 @@ noreturn static void eval_exception(val sym, val ctx, val fmt, va_list vl) uw_release_deferred_warnings(); - uw_throw(sym, get_string_from_stream(stream)); + uw_rthrow(sym, get_string_from_stream(stream)); } noreturn val eval_error(val ctx, val fmt, ...) @@ -349,8 +349,8 @@ static val eval_defr_warn(val ctx, val tag, val fmt, ...) (void) vformat(stream, fmt, vl); - uw_throw(defr_warning_s, - cons(get_string_from_stream(stream), cons(tag, nil))); + uw_rthrow(defr_warning_s, + cons(get_string_from_stream(stream), cons(tag, nil))); } uw_catch(exsym, exvals) { (void) exsym; (void) exvals; } @@ -5022,7 +5022,7 @@ static val gather_free_refs(val info_cons, val exc, struct args *args) if (!memq(sym, deref(dl))) mpush(sym, dl); } - uw_throw(continue_s, nil); + uw_rthrow(continue_s, nil); } return nil; @@ -5032,7 +5032,7 @@ static val gather_free_refs_nw(val info_cons, val exc, struct args *args) { gather_free_refs(info_cons, exc, args); - uw_throw(continue_s, nil); + return uw_rthrow(continue_s, nil); } static val expand_with_free_refs(val form, val menv_in, val upto_menv_in) diff --git a/match.c b/match.c index c3e71388..39e0dfa2 100644 --- a/match.c +++ b/match.c @@ -4092,7 +4092,7 @@ static val v_throw(match_files_ctx *c) { val values = mapcar(pa_123_2(func_n3(txeval_allow_ub), specline, c->bindings), args); - uw_throw(type, values); + return uw_rthrow(type, values); } } @@ -4311,7 +4311,7 @@ static val v_assert(match_files_ctx *c) } else if (type) { val values = mapcar(pa_123_2(func_n3(txeval_allow_ub), specline, c->bindings), args); - uw_throw(type, values); + uw_rthrow(type, values); } else { if (c->curfile) typed_error(assert_s, first_spec, lit("assertion (at ~a:~d)"), c->curfile, c->data_lineno, nao); @@ -4548,7 +4548,7 @@ static val h_assert(match_line_ctx *c) } else if (type) { val values = mapcar(pa_123_2(func_n3(txeval_allow_ub), c->specline, c->bindings), elem); - uw_throw(type, values); + uw_rthrow(type, values); } else { if (c->file) typed_error(assert_s, elem, lit("assertion (at ~a:~d)"), c->file, c->data_lineno, nao); diff --git a/parser.c b/parser.c index 992e9719..7083353b 100644 --- a/parser.c +++ b/parser.c @@ -1093,7 +1093,7 @@ static val repl_intr(val signo, val async_p) { (void) signo; (void) async_p; - uw_throw(intr_s, lit("intr")); + return uw_rthrow(intr_s, lit("intr")); } static val read_eval_ret_last(val env, val counter, @@ -1158,7 +1158,7 @@ static val repl_warning(val out_stream, val exc, struct args *rest) else format(out_stream, lit("** warning: ~!~a\n"), car(args), nao); - uw_throw(continue_s, nil); + return uw_rthrow(continue_s, nil); } static int is_balanced_line(const wchar_t *line, void *ctx) diff --git a/unwind.c b/unwind.c index 9f0950da..408cb67c 100644 --- a/unwind.c +++ b/unwind.c @@ -501,7 +501,7 @@ val uw_muffle_warning(val exc, struct args *args) { (void) exc; (void) args; - uw_throw(continue_s, nil); + return uw_rthrow(continue_s, nil); } val uw_trace_error(val ctx, val exc, struct args *args) @@ -890,7 +890,7 @@ val uw_release_deferred_warnings(void) uw_catch_begin (cons(continue_s, nil), exsym, exvals); - uw_throw(warning_s, caar(wl)); + uw_rthrow(warning_s, caar(wl)); uw_catch(exsym, exvals) { (void) exsym; (void) exvals; } -- cgit v1.2.3