diff options
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | lib.c | 41 | ||||
-rw-r--r-- | match.c | 1 | ||||
-rw-r--r-- | unwind.c | 5 |
4 files changed, 44 insertions, 23 deletions
@@ -1,5 +1,25 @@ 2009-11-20 Kaz Kylheku <kkylheku@gmail.com> + * unwind.c (uw_throw): If streams are not initialized, + we have an unhandled exception too early in initialization. + Use C stream to print an error message and abort. + Using the nil stream variable will just cause a recursion bomb. + +2009-11-20 Kaz Kylheku <kkylheku@gmail.com> + + * lib.c (intern): Symbol interning to hash tables. + (obj_init): interned_syms must be created as a hash + table. Rearranged the order of some initializations so + the vector code called by hash works. + +2009-11-20 Kaz Kylheku <kkylheku@gmail.com> + + * lib.c (dest_bind): Fix breakage from two commits ago; + was falling through to unsuccessful return in the + consp case. + +2009-11-20 Kaz Kylheku <kkylheku@gmail.com> + * parser.y (grammar): Fix error actions that do not assign a value to $$. @@ -36,6 +36,7 @@ #include <wchar.h> #include "lib.h" #include "gc.h" +#include "hash.h" #include "unwind.h" #include "stream.h" #include "utf8.h" @@ -1068,16 +1069,10 @@ val make_sym(val name) val intern(val str) { - val iter; - - for (iter = interned_syms; iter != nil; iter = cdr(iter)) { - val sym = car(iter); - if (equal(symbol_name(sym), str)) - return sym; - } - - interned_syms = cons(make_sym(str), interned_syms); - return car(interned_syms); + val *place = gethash_l(interned_syms, str); + if (*place) + return *place; + return *place = make_sym(str); } val symbolp(val sym) @@ -1759,6 +1754,19 @@ static void obj_init(void) (val *) 0); nil_string = lit("nil"); + null_string = lit(""); + null_list = cons(nil, nil); + + zero = num(0); + one = num(1); + two = num(2); + negone = num(-1); + maxint = num(NUM_MAX); + minint = num(NUM_MIN); + + interned_syms = make_hash(nil, nil); + + *gethash_l(interned_syms, nil_string) = nil; null = intern(lit("null")); t = intern(lit("t")); @@ -1830,19 +1838,6 @@ static void obj_init(void) file_error = intern(lit("file_error")); process_error = intern(lit("process_error")); - interned_syms = cons(nil, interned_syms); - - zero = num(0); - one = num(1); - two = num(2); - negone = num(-1); - maxint = num(NUM_MAX); - minint = num(NUM_MIN); - - null_string = lit(""); - - null_list = cons(nil, nil); - equal_f = func_f2(nil, equal_tramp); identity_f = func_f1(nil, identity_tramp); prog_string = string(progname); @@ -259,6 +259,7 @@ val dest_bind(val bindings, val pattern, val value) if (bindings == t) return t; } + return bindings; } else if (tree_find(value, pattern)) { return bindings; } @@ -215,6 +215,11 @@ val uw_throw(val sym, val exception) } if (ex == 0) { + if (std_error == 0) { + fprintf(stderr, "unhandled exception in early initialization\n"); + abort(); + } + if (opt_loglevel >= 1) { val s = stringp(exception); format(std_error, lit("~a: unhandled exception of type ~a:\n"), |