*** empty log message ***
This commit is contained in:
parent
75a738b429
commit
4163fedf0e
@ -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 <xp/stx/bootstrp.h>
|
||||
@ -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);
|
||||
|
||||
|
@ -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 <xp/stx/dict.h>
|
||||
@ -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));
|
||||
}
|
||||
|
134
ase/stx/hash.c
134
ase/stx/hash.c
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* $Id: hash.c,v 1.26 2005-07-19 12:08:04 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/hash.h>
|
||||
#include <xp/stx/object.h>
|
||||
#include <xp/stx/misc.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 <xp/stx/stx.h>
|
||||
|
||||
#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
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 <xp/stx/object.h>
|
||||
#include <xp/stx/memory.h>
|
||||
#include <xp/stx/symbol.h>
|
||||
#include <xp/stx/class.h>
|
||||
#include <xp/stx/hash.h>
|
||||
#include <xp/stx/misc.h>
|
||||
|
||||
/* n: number of instance variables */
|
||||
|
Loading…
Reference in New Issue
Block a user