From ecc500b1b343a8fc087236cc0b22a25322b6852e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Thu, 16 Feb 2012 05:51:49 -0800 Subject: TXR Lisp gets exception handling. * eval.c (op_catch, expand_catch_clause, expand_catch): New static functions. (expand): Handle catch operator. (eval_init): Added catch operator to op_table, and registered new functions throw, throwf and error. * txr.1: Documented catch operator and created stub section for throw, throwf and error. * txr.vim: Updated. * unwind.c (uw_throwfv, uw_errorfv): New functions. * unwind.h (uw_throwfv, uw_errorfv): Declared. --- unwind.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'unwind.c') diff --git a/unwind.c b/unwind.c index ac99665a..ac4bb79d 100644 --- a/unwind.c +++ b/unwind.c @@ -295,6 +295,14 @@ val uw_throwf(val sym, val fmt, ...) abort(); } +val uw_throwfv(val sym, val fmt, val args) +{ + val stream = make_string_output_stream(); + (void) formatv(stream, fmt, args); + uw_throw(sym, get_string_from_stream(stream)); + abort(); +} + val uw_errorf(val fmt, ...) { va_list vl; @@ -308,6 +316,14 @@ val uw_errorf(val fmt, ...) abort(); } +val uw_errorfv(val fmt, val args) +{ + val stream = make_string_output_stream(); + (void) formatv(stream, fmt, args); + uw_throw(error_s, get_string_from_stream(stream)); + abort(); +} + val type_mismatch(val fmt, ...) { va_list vl; -- cgit v1.2.3