From 6a27bd44addb176080c7207d744ea6559cd482f7 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 17 Mar 2015 22:32:52 -0400 Subject: [PATCH] WIP - raise --- cgen.scm | 1 + runtime.h | 12 +++++++----- test.scm | 2 +- trans.scm | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cgen.scm b/cgen.scm index 8f4db262..322610a3 100644 --- a/cgen.scm +++ b/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") diff --git a/runtime.h b/runtime.h index 2f609f16..169b31da 100644 --- a/runtime.h +++ b/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; } diff --git a/test.scm b/test.scm index 8ac7582a..40fab36b 100644 --- a/test.scm +++ b/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) diff --git a/trans.scm b/trans.scm index ae794446..081622bf 100644 --- a/trans.scm +++ b/trans.scm @@ -518,6 +518,7 @@ %halt error exit + raise cons cell-get set-global!