mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
Properly handle rt errors
This commit is contained in:
parent
13c9d44500
commit
060d256f4a
2 changed files with 17 additions and 27 deletions
12
icyc.scm
12
icyc.scm
|
@ -15,11 +15,13 @@
|
||||||
(with-exception-handler
|
(with-exception-handler
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(display "Error: ")
|
(display "Error: ")
|
||||||
(for-each
|
(display obj)
|
||||||
(lambda (o)
|
; TODO: if list, do this instead:
|
||||||
(display o)
|
;(for-each
|
||||||
(display " "))
|
; (lambda (o)
|
||||||
obj)
|
; (display o)
|
||||||
|
; (display " "))
|
||||||
|
; obj)
|
||||||
(display "\n")
|
(display "\n")
|
||||||
(k #t))
|
(k #t))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
32
runtime.h
32
runtime.h
|
@ -1258,37 +1258,25 @@ object Cyc_current_exception_handler() {
|
||||||
|
|
||||||
/* Raise an exception from the runtime code */
|
/* Raise an exception from the runtime code */
|
||||||
void Cyc_rt_raise(object err) {
|
void Cyc_rt_raise(object err) {
|
||||||
|
//printf("DEBUG err = ");
|
||||||
|
//Cyc_display(err);
|
||||||
|
//printf("\n");
|
||||||
make_cons(c2, err, nil);
|
make_cons(c2, err, nil);
|
||||||
make_cons(c1, boolean_f, &c2);
|
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
|
// Should never get here
|
||||||
fprintf(stderr, "Internal error in Cyc_rt_raise\n");
|
fprintf(stderr, "Internal error in Cyc_rt_raise\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
void Cyc_rt_raise_msg(const char *err) {
|
void Cyc_rt_raise_msg(const char *err) {
|
||||||
printf("TODO: %s", err);
|
make_string(s, err);
|
||||||
exit(1);
|
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 */
|
/* END exception handler */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue