klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit eb14a8efc89a104c32fc7feb4ca70c0dd8b67b4d
parent c3e06d98bde932ba603d499c63fb1b593ac91320
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sat,  9 Apr 2011 15:07:48 -0300

Changed representation for sign of bigints. Now it is in the added size field.

Diffstat:
Msrc/kobject.h | 16+++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/kobject.h b/src/kobject.h @@ -283,11 +283,19 @@ typedef struct __attribute__ ((__packed__)) { ((BigintNode *) ((cur)->next_xor_prev ^ (uintptr_t) (next))) typedef struct __attribute__ ((__packed__)) { - CommonHeader; /* here there is a flag for the sign */ + CommonHeader; BigintNode *first; BigintNode *last; + int32_t sign_size; } Bigint; +/* macros to access size/sign */ +#define kbigint_sign(b_) ((b_)->sign_size < 0) +#define kbigint_negp(b_) (kgigint_sign(b_)) +#define kbigint_posp(b_) (!kbigint_sign(b_)) +#define kbigint_size(b_) ({ int32_t ss = (b_)->sign_size; \ + ss < 0? -ss : ss;}) + typedef struct __attribute__ ((__packed__)) { CommonHeader; TValue mark; /* for cycle/sharing aware algorithms */ @@ -540,12 +548,6 @@ int32_t kmark_count; #define gch_get_flags(o_) (obj2gch(o_)->flags) #define tv_get_flags(o_) (gch_get_flags(tv2gch(o_))) -/* Flags for bigints */ -/* is negative */ -#define K_FLAG_NEG 0x01 -#define kbigint_is_pos(s_) ((tv_get_flags(s_) & K_FLAG_NEG) == 0) -#define kbigint_is_neg(s_) ((tv_get_flags(s_) & K_FLAG_NEG) != 0) - /* Flags for symbols */ /* has external representation (identifiers) */ #define K_FLAG_EXT_REP 0x01