diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | lib.c | 21 | ||||
-rw-r--r-- | lib.h | 9 |
3 files changed, 28 insertions, 16 deletions
@@ -1,5 +1,19 @@ 2011-09-23 Kaz Kylheku <kaz@kylheku.com> + Numeric constants become real constants. + + Vector code cleanup. + + * lib.h (zero, one, two, negone, maxint, minint): Extern declarations + removed, macros introduced for these identifiers. + + * lib.c (zero, one, two, negone, maxint, minint): File scope + definitions removed. + (vector): Use vec_alloc and vec_fill enums instead of constants. + (obj_init): Remove references to removed definitions. + +2011-09-23 Kaz Kylheku <kaz@kylheku.com> + * LICENSE, Makefile, configure, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, regex.c, regex.h, stream.c, stream.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, @@ -66,7 +66,6 @@ val query_error_s, file_error_s, process_error_s; val nothrow_k, args_k; -val zero, one, two, negone, maxint, minint; val null_string; val nil_string; val null_list; @@ -1427,13 +1426,14 @@ val vector(val alloc) cnum alloc_plus = c_num(alloc) + 2; val vec = make_obj(); val *v = (val *) chk_malloc(alloc_plus * sizeof *v); - vec->v.type = VEC; - vec->v.vec = v + 2; #ifdef HAVE_VALGRIND vec->v.vec_true_start = v; #endif - v[0] = alloc; - v[1] = zero; + v += 2; + vec->v.type = VEC; + vec->v.vec = v; + v[vec_alloc] = alloc; + v[vec_fill] = zero; return vec; } @@ -1915,9 +1915,7 @@ static void obj_init(void) */ protect(&packages, &system_package, &keyword_package, - &user_package, &zero, &one, - &two, &negone, &maxint, &minint, - &null_string, &nil_string, + &user_package, &null_string, &nil_string, &null_list, &equal_f, &identity_f, &prog_string, (val *) 0); @@ -1926,13 +1924,6 @@ static void obj_init(void) 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); - system_package = make_package(lit("sys")); keyword_package = make_package(lit("keyword")); user_package = make_package(lit("usr")); @@ -222,7 +222,6 @@ extern val query_error_s, file_error_s, process_error_s; extern val nothrow_k, args_k; -extern val zero, one, two, negone, maxint, minint; extern val null_string; extern val null_list; /* (nil) */ @@ -428,3 +427,11 @@ val match(val spec, val data); obj_t *c_o_n_s ## CAR ## CDR = CONS; \ obj_t *CAR = car(c_o_n_s ## CAR ## CDR); \ obj_t *CDR = cdr(c_o_n_s ## CAR ## CDR) + +#define num_fast(n) ((val) ((n << TAG_SHIFT) | TAG_NUM)) +#define zero num_fast(0) +#define one num_fast(1) +#define two num_fast(2) +#define negone num_fast(-1) +#define maxint num_fast(NUM_MAX) +#define minint num_fast(NUM_MIN) |