mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-17 01:37:34 +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 'apply) "apply")
|
||||||
((eq? p '%halt) "__halt")
|
((eq? p '%halt) "__halt")
|
||||||
((eq? p 'exit) "__halt")
|
((eq? p 'exit) "__halt")
|
||||||
|
((eq? p 'raise) "Cyc_raise")
|
||||||
((eq? p 'error) "Cyc_error")
|
((eq? p 'error) "Cyc_error")
|
||||||
((eq? p 'current-input-port) "Cyc_io_current_input_port")
|
((eq? p 'current-input-port) "Cyc_io_current_input_port")
|
||||||
((eq? p 'open-input-file) "Cyc_io_open_input_file")
|
((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;
|
list exception_handler_stack = nil;
|
||||||
|
|
||||||
static void default_exception_handler(int argc, closure _, object k, object err) {
|
static void default_exception_handler(int argc, closure _, object k, object err) {
|
||||||
printf("default handler Error: ");
|
printf("Error: ");
|
||||||
Cyc_display(err);
|
Cyc_display(err);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -473,10 +473,12 @@ static void add_exception_handler(function_type handler) {
|
||||||
|
|
||||||
// TODO: remove ex handler, err if all are removed?
|
// TODO: remove ex handler, err if all are removed?
|
||||||
// TODO: raise - call current exception handler
|
// 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);
|
function_type fnc = (function_type) car(exception_handler_stack);
|
||||||
mclosure0(clo, fnc);
|
mclosure0(clo, fnc);
|
||||||
(fnc)(2, clo, clo, err);
|
(fnc)(2, &clo, &clo, err);
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_exception_handler(){
|
static void init_exception_handler(){
|
||||||
|
@ -1014,8 +1016,8 @@ static object Cyc_error_va(int count, object obj1, va_list ap) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//exit(1);
|
exit(1);
|
||||||
Cyc_raise(obj1);
|
// TODO: Cyc_raise(obj1);
|
||||||
return boolean_f;
|
return boolean_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
test.scm
2
test.scm
|
@ -23,10 +23,10 @@
|
||||||
;(eval '(a 1))
|
;(eval '(a 1))
|
||||||
;(eval '(begin (define (a z) z) (a 1) (a 1)))
|
;(eval '(begin (define (a z) z) (a 1) (a 1)))
|
||||||
|
|
||||||
(error 'test)
|
|
||||||
(define test '(a b))
|
(define test '(a b))
|
||||||
(set-car! test '(1 2 3))
|
(set-car! test '(1 2 3))
|
||||||
(write test)
|
(write test)
|
||||||
|
(raise 'done)
|
||||||
(define (loop n)
|
(define (loop n)
|
||||||
(cond
|
(cond
|
||||||
((= n 10000)
|
((= n 10000)
|
||||||
|
|
|
@ -518,6 +518,7 @@
|
||||||
%halt
|
%halt
|
||||||
error
|
error
|
||||||
exit
|
exit
|
||||||
|
raise
|
||||||
cons
|
cons
|
||||||
cell-get
|
cell-get
|
||||||
set-global!
|
set-global!
|
||||||
|
|
Loading…
Add table
Reference in a new issue