From f6d7a2ebaad679ff8db23b3e9aa6f5a724259f1b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 19 Apr 2015 08:15:02 -0700 Subject: Improvement in error reporting. This fix prevents certain situations when an inappropriate form is reported, in the default unhandled exception handler, as pertaining to an error. * eval.c (do_eval): Save and restore the last_form_evaled, in an exception-unsafe way. If we successfully evaluate a form or subform, we can restore the previous one. (expand): Save and restore last_form_expanded similarly. We don't need the unwind block and counter. --- ChangeLog | 14 ++++++++++++++ eval.c | 25 ++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1945b2a5..12d4babb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2015-04-19 Kaz Kylheku + + Improvement in error reporting. + + This fix prevents certain situations when an inappropriate form + is reported, in the default unhandled exception handler, as pertaining + to an error. + + * eval.c (do_eval): Save and restore the last_form_evaled, + in an exception-unsafe way. If we successfully evaluate a form or + subform, we can restore the previous one. + (expand): Save and restore last_form_expanded similarly. We don't + need the unwind block and counter. + 2015-04-18 Kaz Kylheku Adding lcons macro. diff --git a/eval.c b/eval.c index e8eaa5a7..35b1c2cc 100644 --- a/eval.c +++ b/eval.c @@ -1031,8 +1031,10 @@ static val do_eval(val form, val env, val ctx_form, if (entry) { opfun_t fp = coerce(opfun_t, cptr_get(entry)); - last_form_evaled = form; - debug_return (fp(form, env)); + val ret, lfe_save = last_form_evaled; + ret = fp(form, env); + last_form_evaled = lfe_save; + debug_return (ret); } else { val fbinding = lookup_fun(env, oper); if (!fbinding) { @@ -1041,9 +1043,12 @@ static val do_eval(val form, val env, val ctx_form, abort(); } else { val args = do_eval_args(rest(form), env, form, &lookup_var); + val ret, lfe_save = last_form_evaled; debug_frame(oper, args, nil, env, nil, nil, nil); last_form_evaled = form; - debug_return (apply(cdr(fbinding), z(args), form)); + ret = apply(cdr(fbinding), z(args), form); + last_form_evaled = lfe_save; + debug_return (ret); debug_end; } } @@ -3129,21 +3134,11 @@ tail: val expand(val form, val menv) { val ret = nil; - static int reentry_count; - - uw_simple_catch_begin; - - reentry_count++; + val lfe_save = last_form_expanded; last_form_expanded = form; ret = do_expand(form, menv); - - uw_unwind { - if (--reentry_count == 0) - last_form_expanded = nil; - } - - uw_catch_end; + last_form_expanded = lfe_save; return ret; } -- cgit v1.2.3