From eca4b4145cb5346eed4900d6d84568b327a27300 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 5 Jul 2005 10:22:35 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/object.c | 20 ++++++++++++++------ ase/stx/object.h | 6 +----- ase/stx/stx.h | 18 +++++++++++++----- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/ase/stx/object.c b/ase/stx/object.c index ebbc030f..1bfec5b2 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.33 2005-07-05 09:52:00 bacon Exp $ + * $Id: object.c,v 1.34 2005-07-05 10:22:35 bacon Exp $ */ #include @@ -26,14 +26,19 @@ xp_word_t xp_stx_alloc_word_object ( n = nfields + variable_nfields; idx = xp_stx_memory_alloc (&stx->memory, n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t)); - if (idx >= stx->memory.capacity) return idx; /* failed */ + if (idx >= stx->memory.capacity) return idx; /* failed TODO: return a difference value OINDEX_INVALID */ + idx = XP_STX_TO_OINDEX(idx); obj = XP_STX_WORD_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | XP_STX_WORD_INDEXED; if (variable_data == XP_NULL) { - while (n > nfields) obj->data[--n] = stx->nil; + while (n > nfields) { + n--; + xp_printf (XP_TEXT("%d\n"), n); + obj->data[n] = stx->nil; + } } else { while (n > nfields) { @@ -66,6 +71,7 @@ xp_word_t xp_stx_alloc_byte_object ( &stx->memory, n + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ + idx = XP_STX_TO_OINDEX(idx); obj = XP_STX_BYTE_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | XP_STX_BYTE_INDEXED; @@ -101,6 +107,7 @@ xp_word_t xp_stx_alloc_char_objectx ( (n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ + idx = XP_STX_TO_OINDEX(idx); obj = XP_STX_CHAR_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED; @@ -123,6 +130,8 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...) xp_va_list ap; xp_stx_char_object_t* obj; + xp_assert (stx->nil == XP_STX_NIL); + xp_va_start (ap, stx); while ((p = xp_va_arg(ap, const xp_char_t*)) != XP_NULL) { n += xp_strlen(p); @@ -133,8 +142,7 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...) (n + 1) * xp_sizeof(xp_char_t) + xp_sizeof(xp_stx_object_t)); if (idx >= stx->memory.capacity) return idx; /* failed */ - xp_assert (stx->nil == XP_STX_NIL); - + idx = XP_STX_TO_OINDEX(idx); obj = XP_STX_CHAR_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED; @@ -155,7 +163,7 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...) xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx) { - xp_assert (XP_STX_TYPE(stx,idx) == XP_STX_CHAR_INDEXED); + xp_assert (!XP_STX_IS_SMALLINT(idx) && XP_STX_IS_CHAR_OBJECT(stx, idx)); return xp_stx_strxhash ( XP_STX_DATA(stx,idx), XP_STX_SIZE(stx,idx)); } diff --git a/ase/stx/object.h b/ase/stx/object.h index f6c7f8d4..75dd674c 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.23 2005-07-05 09:52:00 bacon Exp $ + * $Id: object.h,v 1.24 2005-07-05 10:22:35 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -7,10 +7,6 @@ #include -#define XP_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01) -#define XP_STX_TO_SMALLINT(x) (((x) << 1) | 0x01) -#define XP_STX_FROM_SMALLINT(x) ((x) >> 1) - #ifdef __cplusplus extern "C" { #endif diff --git a/ase/stx/stx.h b/ase/stx/stx.h index 1c54aa7e..1e2e9664 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.33 2005-07-05 09:52:00 bacon Exp $ + * $Id: stx.h,v 1.34 2005-07-05 10:22:35 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -85,11 +85,19 @@ struct xp_stx_t xp_bool_t __wantabort; /* TODO: make it a function pointer */ }; -#define XP_STX_NIL 0 -#define XP_STX_TRUE 1 -#define XP_STX_FALSE 2 +#define XP_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01) +#define XP_STX_TO_SMALLINT(x) (((x) << 1) | 0x01) +#define XP_STX_FROM_SMALLINT(x) ((x) >> 1) -#define XP_STX_OBJECT(stx,idx) (((stx)->memory).slots[idx]) +#define XP_STX_IS_OINDEX(x) (((x) & 0x01) == 0x00) +#define XP_STX_TO_OINDEX(x) (((x) << 1) | 0x00) +#define XP_STX_FROM_OINDEX(x) ((x) >> 1) + +#define XP_STX_NIL XP_STX_TO_OINDEX(0) +#define XP_STX_TRUE XP_STX_TO_OINDEX(1) +#define XP_STX_FALSE XP_STX_TO_OINDEX(2) + +#define XP_STX_OBJECT(stx,idx) (((stx)->memory).slots[XP_STX_FROM_OINDEX(idx)]) #define XP_STX_CLASS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.class) #define XP_STX_ACCESS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.access) #define XP_STX_DATA(stx,idx) ((void*)(XP_STX_OBJECT(stx,idx) + 1))