From 4163fedf0ef6d4cd820438e5352537e520cb84b5 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 19 Jul 2005 16:10:16 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/bootstrp.c | 4 +- ase/stx/dict.c | 4 +- ase/stx/hash.c | 134 ------------------------------------------- ase/stx/hash.h | 48 ---------------- ase/stx/makefile.cl | 2 +- ase/stx/makefile.in | 2 +- ase/stx/makefile.tcc | 2 +- ase/stx/object.c | 3 +- 8 files changed, 9 insertions(+), 190 deletions(-) delete mode 100644 ase/stx/hash.c delete mode 100644 ase/stx/hash.h diff --git a/ase/stx/bootstrp.c b/ase/stx/bootstrp.c index 814d8313..c3415314 100644 --- a/ase/stx/bootstrp.c +++ b/ase/stx/bootstrp.c @@ -1,5 +1,5 @@ /* - * $Id: bootstrp.c,v 1.28 2005-07-19 15:52:19 bacon Exp $ + * $Id: bootstrp.c,v 1.29 2005-07-19 16:09:34 bacon Exp $ */ #include @@ -402,7 +402,7 @@ static void __create_bootstrapping_objects (xp_stx_t* stx) stx->symbol_table = xp_stx_alloc_word_object ( stx, XP_NULL, 0, XP_NULL, 1000); stx->smalltalk = xp_stx_alloc_word_object ( - stx, XP_NULL, 1, XP_NULL, 512); + stx, XP_NULL, 1, XP_NULL, 256); /* set tally */ XP_STX_WORD_AT(stx,stx->smalltalk,0) = XP_STX_TO_SMALLINT(0); diff --git a/ase/stx/dict.c b/ase/stx/dict.c index 9aa4ca18..1ebc643e 100644 --- a/ase/stx/dict.c +++ b/ase/stx/dict.c @@ -1,5 +1,5 @@ /* - * $Id: dict.c,v 1.4 2005-07-19 15:52:19 bacon Exp $ + * $Id: dict.c,v 1.5 2005-07-19 16:09:34 bacon Exp $ */ #include @@ -92,6 +92,8 @@ static void __dict_grow (xp_stx_t* stx, xp_word_t dict) XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE)); } + /* TODO: explore if dict can be immediately destroyed. + */ XP_SWAP ((xp_uint_t)XP_STX_OBJECT(stx,dict), (xp_uint_t)XP_STX_OBJECT(stx,new)); } diff --git a/ase/stx/hash.c b/ase/stx/hash.c deleted file mode 100644 index 4f496ed3..00000000 --- a/ase/stx/hash.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $Id: hash.c,v 1.26 2005-07-19 12:08:04 bacon Exp $ - */ - -#include -#include -#include - -xp_word_t xp_stx_new_pairlink ( - xp_stx_t* stx, xp_word_t key, xp_word_t value) -{ - xp_word_t x; - xp_stx_pairlink_t* obj; - - x = xp_stx_alloc_word_object ( - stx, XP_NULL, XP_STX_PAIRLINK_SIZE, XP_NULL, 0); - obj = (xp_stx_pairlink_t*)XP_STX_OBJECT(stx, x); - obj->header.class = stx->class_pairlink; - obj->link = stx->nil; - obj->key = key; - obj->value = value; - - return x; -} - -/* returns the entire link */ -xp_word_t xp_stx_hash_lookup ( - xp_stx_t* stx, xp_word_t table, - xp_word_t hash, xp_word_t key) -{ - xp_word_t link; - xp_stx_pairlink_t* obj; - - xp_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED); - - //hash = hash % XP_STX_SIZE(stx,table); - hash = hash % (XP_STX_SIZE(stx,table) - 1) + 1; - link = XP_STX_WORD_AT(stx,table,hash); - - while (link != stx->nil) { - /* - if (XP_STX_WORD_AT(stx,link,XP_STX_PAIRLINK_KEY) == key) return link; - link = XP_STX_WORD_AT(stx,link,XP_STX_PAIRLINK_LINK); - */ - - obj = (xp_stx_pairlink_t*)XP_STX_OBJECT(stx,link); - if (obj->key == key) return link; - link = obj->link; - } - - return stx->nil; /* not found */ -} - -xp_word_t xp_stx_hash_lookup_symbol ( - xp_stx_t* stx, xp_word_t table, const xp_char_t* name) -{ - xp_word_t link, hash; - xp_stx_pairlink_t* obj; - xp_stx_char_object_t* tmp; - - xp_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED); - - //hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table); - hash = xp_stx_strhash(name) % (XP_STX_SIZE(stx,table) - 1) + 1; - link = XP_STX_WORD_AT(stx,table,hash); - - while (link != stx->nil) { - obj = (xp_stx_pairlink_t*)XP_STX_OBJECT(stx,link); - tmp = XP_STX_CHAR_OBJECT(stx,obj->key); - if (tmp->header.class == stx->class_symbol && - xp_strcmp (tmp->data, name) == 0) return link; - link = obj->link; - } - - return stx->nil; /* not found */ -} - -void xp_stx_hash_insert ( - xp_stx_t* stx, xp_word_t table, - xp_word_t hash, xp_word_t key, xp_word_t value) -{ - xp_word_t link, next; - - xp_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED); - - hash = hash % (XP_STX_SIZE(stx,table) - 1) + 1; - link = XP_STX_WORD_AT(stx,table,hash); - - if (link == stx->nil) { - XP_STX_WORD_AT(stx,table,hash) = - xp_stx_new_pairlink (stx, key, value); - XP_STX_WORD_AT(stx,table,0) = XP_STX_TO_SMALLINT( - XP_STX_FROM_SMALLINT(XP_STX_WORD_AT(stx,table,0)) + 1); - } - else { - for (;;) { - /* TODO: contents comparison */ - if (XP_STX_WORD_AT(stx,link,1) == key) { - XP_STX_WORD_AT(stx,link,XP_STX_PAIRLINK_VALUE) = value; - break; - } - - next = XP_STX_WORD_AT(stx,link,XP_STX_PAIRLINK_LINK); - if (next == stx->nil) { - XP_STX_WORD_AT(stx,link,XP_STX_PAIRLINK_LINK) = - xp_stx_new_pairlink (stx, key, value); - XP_STX_WORD_AT(stx,table,0) = XP_STX_TO_SMALLINT( - XP_STX_FROM_SMALLINT(XP_STX_WORD_AT(stx,table,0)) + 1); - break; - } - - link = next; - } - } -} - -void xp_stx_hash_traverse ( - xp_stx_t* stx, xp_word_t table, - void (*func) (xp_stx_t*,xp_word_t,void*), void* data) -{ - xp_word_t link; - xp_word_t size = XP_STX_SIZE(stx,table); - - //while (size-- > 0) { - while (size-- > 1) { - link = XP_STX_WORD_AT(stx,table,size); - - while (link != stx->nil) { - func (stx, link, data); - link = XP_STX_WORD_AT(stx,link,XP_STX_PAIRLINK_LINK); - } - } -} - diff --git a/ase/stx/hash.h b/ase/stx/hash.h deleted file mode 100644 index a971be1f..00000000 --- a/ase/stx/hash.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id: hash.h,v 1.11 2005-07-18 11:53:01 bacon Exp $ - */ - -#ifndef _XP_STX_HASH_H_ -#define _XP_STX_HASH_H_ - -#include - -#define XP_STX_PAIRLINK_SIZE 3 -#define XP_STX_PAIRLINK_LINK 0 -#define XP_STX_PAIRLINK_KEY 1 -#define XP_STX_PAIRLINK_VALUE 2 - -struct xp_stx_pairlink_t -{ - xp_stx_objhdr_t header; - xp_word_t link; - xp_word_t key; - xp_word_t value; -}; - -typedef struct xp_stx_pairlink_t xp_stx_pairlink_t; - -#ifdef __cplusplus -extern "C" -#endif - -/* hash table manipulation */ -xp_word_t xp_stx_new_pairlink ( - xp_stx_t* stx, xp_word_t key, xp_word_t value); -xp_word_t xp_stx_hash_lookup ( - xp_stx_t* stx, xp_word_t table, - xp_word_t hash, xp_word_t key); -xp_word_t xp_stx_hash_lookup_symbol ( - xp_stx_t* stx, xp_word_t table, const xp_char_t* name); -void xp_stx_hash_insert ( - xp_stx_t* stx, xp_word_t table, - xp_word_t hash, xp_word_t key, xp_word_t value); -void xp_stx_hash_traverse ( - xp_stx_t* stx, xp_word_t table, - void (*func) (xp_stx_t*,xp_word_t,void*), void* data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ase/stx/makefile.cl b/ase/stx/makefile.cl index b14d37ce..24d949cd 100644 --- a/ase/stx/makefile.cl +++ b/ase/stx/makefile.cl @@ -1,6 +1,6 @@ SRCS = \ stx.c memory.c object.c symbol.c class.c \ - hash.c misc.c context.c name.c token.c parser.c bootstrp.c + dict.c misc.c context.c name.c token.c parser.c bootstrp.c OBJS = $(SRCS:.c=.obj) OUT = xpstx.lib diff --git a/ase/stx/makefile.in b/ase/stx/makefile.in index 8cefcc24..8fceb67b 100644 --- a/ase/stx/makefile.in +++ b/ase/stx/makefile.in @@ -1,5 +1,5 @@ SRCS = stx.c memory.c object.c symbol.c class.c \ - hash.c dict.c misc.c context.c name.c token.c parser.c bootstrp.c bytecode.c + dict.c misc.c context.c name.c token.c parser.c bootstrp.c bytecode.c OBJS = $(SRCS:.c=.o) OUT = libxpstx.a diff --git a/ase/stx/makefile.tcc b/ase/stx/makefile.tcc index 950eff5a..85f31683 100644 --- a/ase/stx/makefile.tcc +++ b/ase/stx/makefile.tcc @@ -1,5 +1,5 @@ SRCS = \ - stx.c memory.c object.c symbol.c hash.c misc.c context.c + stx.c memory.c object.c symbol.c dict.c misc.c context.c OBJS = $(SRCS:.c=.obj) OUT = xpstx.lib diff --git a/ase/stx/object.c b/ase/stx/object.c index c5420a7d..7602ed3b 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,12 +1,11 @@ /* - * $Id: object.c,v 1.39 2005-07-19 15:52:19 bacon Exp $ + * $Id: object.c,v 1.40 2005-07-19 16:09:34 bacon Exp $ */ #include #include #include #include -#include #include /* n: number of instance variables */