mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
WIP - raise
This commit is contained in:
parent
deff3e910d
commit
6a27bd44ad
4 changed files with 10 additions and 6 deletions
1
cgen.scm
1
cgen.scm
|
@ -434,6 +434,7 @@
|
|||
((eq? p 'apply) "apply")
|
||||
((eq? p '%halt) "__halt")
|
||||
((eq? p 'exit) "__halt")
|
||||
((eq? p 'raise) "Cyc_raise")
|
||||
((eq? p 'error) "Cyc_error")
|
||||
((eq? p 'current-input-port) "Cyc_io_current_input_port")
|
||||
((eq? p 'open-input-file) "Cyc_io_open_input_file")
|
||||
|
|
12
runtime.h
12
runtime.h
|
@ -460,7 +460,7 @@ static void clear_mutations() {
|
|||
list exception_handler_stack = nil;
|
||||
|
||||
static void default_exception_handler(int argc, closure _, object k, object err) {
|
||||
printf("default handler Error: ");
|
||||
printf("Error: ");
|
||||
Cyc_display(err);
|
||||
printf("\n");
|
||||
exit(1);
|
||||
|
@ -473,10 +473,12 @@ static void add_exception_handler(function_type handler) {
|
|||
|
||||
// TODO: remove ex handler, err if all are removed?
|
||||
// TODO: raise - call current exception handler
|
||||
static void Cyc_raise(/*object cont,*/ object err) {
|
||||
//static void Cyc_raise(/*object cont,*/ object err) {
|
||||
static object Cyc_raise(object err) {
|
||||
function_type fnc = (function_type) car(exception_handler_stack);
|
||||
mclosure0(clo, fnc);
|
||||
(fnc)(2, clo, clo, err);
|
||||
(fnc)(2, &clo, &clo, err);
|
||||
return nil;
|
||||
}
|
||||
|
||||
static void init_exception_handler(){
|
||||
|
@ -1014,8 +1016,8 @@ static object Cyc_error_va(int count, object obj1, va_list ap) {
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
//exit(1);
|
||||
Cyc_raise(obj1);
|
||||
exit(1);
|
||||
// TODO: Cyc_raise(obj1);
|
||||
return boolean_f;
|
||||
}
|
||||
|
||||
|
|
2
test.scm
2
test.scm
|
@ -23,10 +23,10 @@
|
|||
;(eval '(a 1))
|
||||
;(eval '(begin (define (a z) z) (a 1) (a 1)))
|
||||
|
||||
(error 'test)
|
||||
(define test '(a b))
|
||||
(set-car! test '(1 2 3))
|
||||
(write test)
|
||||
(raise 'done)
|
||||
(define (loop n)
|
||||
(cond
|
||||
((= n 10000)
|
||||
|
|
|
@ -518,6 +518,7 @@
|
|||
%halt
|
||||
error
|
||||
exit
|
||||
raise
|
||||
cons
|
||||
cell-get
|
||||
set-global!
|
||||
|
|
Loading…
Add table
Reference in a new issue