diff --git a/images/apple/DRAWL.po b/images/apple/DRAWL.po index 1770b99..843c569 100644 Binary files a/images/apple/DRAWL.po and b/images/apple/DRAWL.po differ diff --git a/src/lisp/drawl.pla b/src/lisp/drawl.pla index 3423e0c..ec7146f 100644 --- a/src/lisp/drawl.pla +++ b/src/lisp/drawl.pla @@ -47,6 +47,7 @@ import sexpr byte stringstr[1] end + var exception var hook_eval var assoc_list byte trace @@ -308,7 +309,7 @@ def hookfn(expr) fileio:close(fileref) readfn = @read_keybd fin - throw(@break_repl, FALSE) + throw(@break_repl, 0) fin return expr end @@ -337,7 +338,10 @@ new_sym("READFILE")=>natv = @natv_readfile parse_cmdline hook_eval = @hookfn -except(@break_repl) +exception = @break_repl +if except(@break_repl) == -1 + puts("Out of memory!\n") +fin while not quit putln; print_expr(eval_quote(readfn())) loop diff --git a/src/lisp/s-expr.pla b/src/lisp/s-expr.pla index 7538e91..36afd5d 100644 --- a/src/lisp/s-expr.pla +++ b/src/lisp/s-expr.pla @@ -1,6 +1,7 @@ include "inc/cmdsys.plh" include "inc/int32.plh" include "inc/fpstr.plh" +include "inc/longjmp.plh" const TYPE_MASK = $70 const NIL = $00 @@ -58,6 +59,7 @@ const fmt_fp = FPSTR_FIXED|FPSTR_STRIP|FPSTR_FLEX export var fmt_fpint = 6 export var fmt_fpfrac = 4 export byte trace = FALSE +export var exception = NULL export var hook_eval = NULL // Installable hook for eval_expr() export var assoc_list = NULL // SYM->value association list var cons_list = NULL @@ -234,6 +236,7 @@ export def new_cons#1 else gc_pull++ consptr = heapalloc(t_cons) + if !consptr; throw(exception, -1); fin fin consptr=>link = cons_list cons_list = consptr @@ -252,6 +255,7 @@ export def new_int(intlo, inthi)#1 else gc_pull++ intptr = heapalloc(t_numint) + if !intptr; throw(exception, -1); fin fin intptr=>link = int_list int_list = intptr @@ -270,6 +274,7 @@ export def new_float(extptr)#1 else gc_pull++ floatptr = heapalloc(t_numfloat) + if !floatptr; throw(exception, -1); fin fin floatptr=>link = float_list float_list = floatptr @@ -305,6 +310,7 @@ def new_array(dim0, dim1, dim2, dim3) fin memset(memptr, NULL, size) aptr = heapalloc(t_array) + if !aptr; throw(exception, -1); fin aptr=>link = NULL aptr->type = ARRAY_TYPE aptr=>dimension[0] = dim0 @@ -366,6 +372,7 @@ export def new_string(strptr)#1 if !stringptr // Nothing free gc_pull++ stringptr = heapalloc(t_string + alloclen) + if !stringptr; throw(exception, -1); fin fin stringptr=>link = string_list string_list = stringptr @@ -403,6 +410,7 @@ export def new_sym(symstr)#1 symptr = match_sym(symstr, hashtbl[index]) if symptr; return symptr; fin // Return already existing symbol symptr = heapalloc(t_sym + ^symstr) + if !symptr; throw(exception, -1); fin symptr=>link = hashtbl[index] hashtbl[index] = symptr symptr->type = ^symstr | SYM_TYPE