From 060d256f4a03a6cad17a64da84ae528cd5121d8f Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 16 Apr 2015 22:39:04 -0400 Subject: [PATCH] Properly handle rt errors --- icyc.scm | 12 +++++++----- runtime.h | 32 ++++++++++---------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/icyc.scm b/icyc.scm index 691c2ce2..26525a05 100644 --- a/icyc.scm +++ b/icyc.scm @@ -15,11 +15,13 @@ (with-exception-handler (lambda (obj) (display "Error: ") - (for-each - (lambda (o) - (display o) - (display " ")) - obj) + (display obj) + ; TODO: if list, do this instead: + ;(for-each + ; (lambda (o) + ; (display o) + ; (display " ")) + ; obj) (display "\n") (k #t)) (lambda () diff --git a/runtime.h b/runtime.h index f352d6e0..47550f5c 100644 --- a/runtime.h +++ b/runtime.h @@ -1258,37 +1258,25 @@ object Cyc_current_exception_handler() { /* Raise an exception from the runtime code */ void Cyc_rt_raise(object err) { + //printf("DEBUG err = "); + //Cyc_display(err); + //printf("\n"); make_cons(c2, err, nil); make_cons(c1, boolean_f, &c2); - apply(nil, Cyc_current_exception_handler(), &c1); + make_cons(c0, &c1, nil); + //printf("sending to apply => "); + //Cyc_display(&c0); + //printf("\n"); + apply(nil, Cyc_current_exception_handler(), &c0); // Should never get here fprintf(stderr, "Internal error in Cyc_rt_raise\n"); exit(1); } void Cyc_rt_raise_msg(const char *err) { - printf("TODO: %s", err); - exit(1); - //make_string(s, err); - //Cyc_rt_raise(&s); + make_string(s, err); + Cyc_rt_raise(&s); } -/* Provide the ability to raise an exception from the C runtime. - Other runtime functions should call this as needed - - TODO: consolidate this with (raise) in trans.scm ???? - * / -TODO: -object Cyc_raise(object err) { - // TODO: probably best to re-arrange things to not rely on a global here - object ehs = (object) __glo__85exception_91handler_91stack_85; - if (boolean_f == ehs) { - Cyc_default_exception_handler(1, (closure)err, err); - } else { - // TODO: call into just like (raise) car(ehs) - } - return nil; -} */ - /* END exception handler */ /*