diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-13 19:49:58 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-13 19:49:58 -0800 |
commit | 0455b347c64dd177036fc79544f3cfb5b3f3118a (patch) | |
tree | 6516ad1eae40df9aa2f197ddec2f3447b757dd77 /parser.c | |
parent | 2e4dc6906a37a2506379fc2abac5508851b7fa16 (diff) | |
download | txr-0455b347c64dd177036fc79544f3cfb5b3f3118a.tar.gz txr-0455b347c64dd177036fc79544f3cfb5b3f3118a.tar.bz2 txr-0455b347c64dd177036fc79544f3cfb5b3f3118a.zip |
Deferred warnings.
Warnings about undefined functions and variables are now
deferred during loading, so forward references do not generate
nuisance diagnostics.
* eval.c (load_recursive_s): New symbol variable.
(eval_defr_warn): New static function.
(op_defvarl, op_defun): Purge any deferred warning about the
given function or variable not being defined.
(load): Rebind the sys:*load-recursive* special var to true
around the load. After the load, dump deferred warnings
if the prior binding of sys:*load-recursive* is false.
Discard deferred warnings in the case of termination by
a nonlocal control transfer.
(do_expand): Treat unbound vars and functions as deferrable
warnings, specially tagged for individual purging frkm
the deferred list.
(eval_init): Intern sys:*load-recursive* and initialize
load_recursive_s variable.
* eval.h (load_recursive_s): Declared.
* parse.c (repl_warning): Accept variable arguments.
Check whether we are loading and if so, defer deferrable
(repl): Adjustment for altered signature of repl_warning.
warnings.
* txr.c (txr_main): dump deferred warnings after
evaluating Lisp stream.
* unwind.c (deferred_warnings): New static variable.
(uw_throw): When a deferrable warning is caught,
suppress the usual message and add it to the
deferred_warnings list.
(uw_defer_warning, uw_dump_deferred_warnings,
uw_dump_deferred_warnings, uw_purge_deferred_warnings): New
functions.
(uw_late_init): gc-protect deferred_warnings.
* unwind.h (uw_defer_warning, uw_dump_deferred_warnings,
uw_dump_deferred_warnings, uw_purge_deferred_warnings): New
functions declared.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -45,6 +45,7 @@ #include "signal.h" #include "unwind.h" #include "gc.h" +#include "args.h" #include "utf8.h" #include "hash.h" #include "eval.h" @@ -906,9 +907,16 @@ static val get_home_path(void) return getenv_wrap(lit("HOME")); } -static val repl_warning(val out_stream, val exc, val arg) +static val repl_warning(val out_stream, val exc, struct args *rest) { - format(out_stream, lit("** warning: ~!~a\n"), arg, nao); + val args = args_get_list(rest); + val loading = cdr(lookup_var(dyn_env, load_recursive_s)); + + if (loading && cdr(args)) + uw_defer_warning(args); + else + format(out_stream, lit("** warning: ~!~a\n"), car(args), nao); + uw_throw(continue_s, nil); } @@ -936,7 +944,7 @@ val repl(val bindings, val in_stream, val out_stream) val hist_len_var = lookup_global_var(listener_hist_len_s); val multi_line_var = lookup_global_var(listener_multi_line_p_s); val sel_inclusive_var = lookup_global_var(listener_sel_inclusive_p_s); - val rw_f = func_f2(out_stream, repl_warning); + val rw_f = func_f1v(out_stream, repl_warning); for (; bindings; bindings = cdr(bindings)) { val binding = car(bindings); |