*** empty log message ***
This commit is contained in:
parent
01a16f87ac
commit
75a738b429
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bootstrp.c,v 1.27 2005-07-19 12:08:04 bacon Exp $
|
* $Id: bootstrp.c,v 1.28 2005-07-19 15:52:19 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/bootstrp.h>
|
#include <xp/stx/bootstrp.h>
|
||||||
@ -401,10 +401,8 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
|||||||
/* TODO: symbol table and dictionary size */
|
/* TODO: symbol table and dictionary size */
|
||||||
stx->symbol_table = xp_stx_alloc_word_object (
|
stx->symbol_table = xp_stx_alloc_word_object (
|
||||||
stx, XP_NULL, 0, XP_NULL, 1000);
|
stx, XP_NULL, 0, XP_NULL, 1000);
|
||||||
xp_printf (XP_TEXT("xxxxxxxxxxxxxxxxxx\n"));
|
|
||||||
stx->smalltalk = xp_stx_alloc_word_object (
|
stx->smalltalk = xp_stx_alloc_word_object (
|
||||||
stx, XP_NULL, 1, XP_NULL, 1024);
|
stx, XP_NULL, 1, XP_NULL, 512);
|
||||||
xp_printf (XP_TEXT("yyyyyyyyyyyyyyyyyyy\n"));
|
|
||||||
/* set tally */
|
/* set tally */
|
||||||
XP_STX_WORD_AT(stx,stx->smalltalk,0) = XP_STX_TO_SMALLINT(0);
|
XP_STX_WORD_AT(stx,stx->smalltalk,0) = XP_STX_TO_SMALLINT(0);
|
||||||
|
|
||||||
@ -713,11 +711,6 @@ static xp_word_t __make_classvar_dict (
|
|||||||
*p != XP_CHAR('\0')) p++;
|
*p != XP_CHAR('\0')) p++;
|
||||||
|
|
||||||
symbol = xp_stx_new_symbolx (stx, name, p - name);
|
symbol = xp_stx_new_symbolx (stx, name, p - name);
|
||||||
|
|
||||||
/*
|
|
||||||
xp_stx_hash_insert (stx, dict,
|
|
||||||
xp_stx_hash_object(stx, symbol), symbol, stx->nil);
|
|
||||||
*/
|
|
||||||
xp_stx_dict_put (stx, dict, symbol, stx->nil);
|
xp_stx_dict_put (stx, dict, symbol, stx->nil);
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: class.c,v 1.22 2005-07-19 12:08:04 bacon Exp $
|
* $Id: class.c,v 1.23 2005-07-19 15:52:19 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
@ -28,13 +28,7 @@ xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name)
|
|||||||
class_name = xp_stx_new_symbol (stx, name);
|
class_name = xp_stx_new_symbol (stx, name);
|
||||||
XP_STX_WORD_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
XP_STX_WORD_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
||||||
|
|
||||||
/*
|
|
||||||
xp_stx_hash_insert (stx, stx->smalltalk,
|
|
||||||
xp_stx_hash_object(stx, class_name),
|
|
||||||
class_name, class);
|
|
||||||
*/
|
|
||||||
xp_stx_dict_put (stx, stx->smalltalk, class_name, class);
|
xp_stx_dict_put (stx, stx->smalltalk, class_name, class);
|
||||||
|
|
||||||
return class;
|
return class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +37,9 @@ xp_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_char_t* name)
|
|||||||
xp_word_t assoc, meta, value;
|
xp_word_t assoc, meta, value;
|
||||||
|
|
||||||
assoc = xp_stx_dict_lookup (stx, stx->smalltalk, name);
|
assoc = xp_stx_dict_lookup (stx, stx->smalltalk, name);
|
||||||
if (assoc == stx->nil) return stx->nil;
|
if (assoc == stx->nil) {
|
||||||
|
return stx->nil;
|
||||||
|
}
|
||||||
|
|
||||||
value = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE);
|
value = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE);
|
||||||
meta = XP_STX_CLASS(stx,value);
|
meta = XP_STX_CLASS(stx,value);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: dict.c,v 1.3 2005-07-19 15:00:09 bacon Exp $
|
* $Id: dict.c,v 1.4 2005-07-19 15:52:19 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/dict.h>
|
#include <xp/stx/dict.h>
|
||||||
@ -30,14 +30,14 @@ static xp_word_t __dict_find_slot (
|
|||||||
xp_word_t size, hash, index, assoc, symbol;
|
xp_word_t size, hash, index, assoc, symbol;
|
||||||
xp_stx_word_object_t* dict_obj;
|
xp_stx_word_object_t* dict_obj;
|
||||||
|
|
||||||
xp_assert (XP_STX_IS_WORD_OBJECT(stx, dict));
|
xp_assert (!XP_STX_IS_SMALLINT(dict) &&
|
||||||
|
XP_STX_IS_WORD_OBJECT(stx, dict));
|
||||||
xp_assert (dict == stx->smalltalk ||
|
xp_assert (dict == stx->smalltalk ||
|
||||||
XP_STX_CLASS(stx,dict) == stx->class_system_dictionary);
|
xp_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||||
xp_assert (XP_STX_CLASS(stx,key) == stx->class_symbol);
|
xp_assert (xp_stx_classof(stx,key) == stx->class_symbol);
|
||||||
|
|
||||||
size = XP_STX_SIZE(stx,dict);
|
size = XP_STX_SIZE(stx,dict);
|
||||||
hash = xp_stx_hash_object(stx, key);
|
hash = xp_stx_hash_object(stx, key);
|
||||||
xp_printf (XP_TEXT("find_slot %s %u\n"), XP_STX_DATA(stx,key), hash);
|
|
||||||
|
|
||||||
/* consider tally, the only instance variable of a system dictionary */
|
/* consider tally, the only instance variable of a system dictionary */
|
||||||
index = hash % (size - 1) + 1;
|
index = hash % (size - 1) + 1;
|
||||||
@ -49,13 +49,15 @@ xp_printf (XP_TEXT("find_slot %s %u\n"), XP_STX_DATA(stx,key), hash);
|
|||||||
if (assoc == stx->nil) break;
|
if (assoc == stx->nil) break;
|
||||||
|
|
||||||
symbol = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY);
|
symbol = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY);
|
||||||
xp_assert (XP_STX_CLASS(stx,symbol) == stx->class_symbol);
|
xp_assert (xp_stx_classof(stx,symbol) == stx->class_symbol);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* shallow comparison is enough for identity check
|
* shallow comparison is enough for identity check
|
||||||
* because only a symbol can be a key of a system dictionary
|
* because only a symbol can be a key of a system dictionary
|
||||||
*/
|
*/
|
||||||
if (xp_stx_shallow_compare_object(stx, key, symbol) == 0) break;
|
if (xp_strxncmp(
|
||||||
|
XP_STX_DATA(stx,key), XP_STX_SIZE(stx,key),
|
||||||
|
XP_STX_DATA(stx,symbol), XP_STX_SIZE(stx,symbol)) == 0) break;
|
||||||
|
|
||||||
/* consider tally here too */
|
/* consider tally here too */
|
||||||
index = index % (size - 1) + 1;
|
index = index % (size - 1) + 1;
|
||||||
@ -74,7 +76,7 @@ static void __dict_grow (xp_stx_t* stx, xp_word_t dict)
|
|||||||
* during the bootstrapping.
|
* during the bootstrapping.
|
||||||
*/
|
*/
|
||||||
xp_assert (stx->class_system_dictionary != stx->nil);
|
xp_assert (stx->class_system_dictionary != stx->nil);
|
||||||
xp_assert (XP_STX_CLASS(stx,dict) == stx->class_system_dictionary);
|
xp_assert (xp_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||||
|
|
||||||
size = XP_STX_SIZE(stx,dict);
|
size = XP_STX_SIZE(stx,dict);
|
||||||
new = xp_stx_instantiate (stx,
|
new = xp_stx_instantiate (stx,
|
||||||
@ -90,7 +92,6 @@ static void __dict_grow (xp_stx_t* stx, xp_word_t dict)
|
|||||||
XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE));
|
XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_printf (XP_TEXT("dictionary grown. swapped the index\n"));
|
|
||||||
XP_SWAP ((xp_uint_t)XP_STX_OBJECT(stx,dict),
|
XP_SWAP ((xp_uint_t)XP_STX_OBJECT(stx,dict),
|
||||||
(xp_uint_t)XP_STX_OBJECT(stx,new));
|
(xp_uint_t)XP_STX_OBJECT(stx,new));
|
||||||
}
|
}
|
||||||
@ -101,14 +102,13 @@ xp_word_t xp_stx_dict_lookup (
|
|||||||
xp_word_t size, hash, index, assoc, symbol;
|
xp_word_t size, hash, index, assoc, symbol;
|
||||||
xp_stx_word_object_t* dict_obj;
|
xp_stx_word_object_t* dict_obj;
|
||||||
|
|
||||||
xp_assert (XP_STX_IS_WORD_OBJECT(stx, dict));
|
xp_assert (!XP_STX_IS_SMALLINT(dict) &&
|
||||||
|
XP_STX_IS_WORD_OBJECT(stx, dict));
|
||||||
xp_assert (dict == stx->smalltalk ||
|
xp_assert (dict == stx->smalltalk ||
|
||||||
XP_STX_CLASS(stx,dict) == stx->class_system_dictionary);
|
xp_stx_classof(stx,dict) == stx->class_system_dictionary);
|
||||||
|
|
||||||
size = XP_STX_SIZE(stx,dict);
|
size = XP_STX_SIZE(stx,dict);
|
||||||
/*hash = xp_stx_hash_object(stx, key);*/
|
|
||||||
hash = xp_stx_hash(key, xp_strlen(key) * xp_sizeof(xp_char_t));
|
hash = xp_stx_hash(key, xp_strlen(key) * xp_sizeof(xp_char_t));
|
||||||
xp_printf (XP_TEXT("lookup hash %s %u\n"), key, hash);
|
|
||||||
|
|
||||||
/* consider tally, the only instance variable of a system dictionary */
|
/* consider tally, the only instance variable of a system dictionary */
|
||||||
index = hash % (size - 1) + 1;
|
index = hash % (size - 1) + 1;
|
||||||
@ -116,24 +116,19 @@ xp_printf (XP_TEXT("lookup hash %s %u\n"), key, hash);
|
|||||||
dict_obj = XP_STX_WORD_OBJECT(stx,dict);
|
dict_obj = XP_STX_WORD_OBJECT(stx,dict);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
xp_printf (XP_TEXT("dict_lookup: %d\n"), index);
|
|
||||||
assoc = dict_obj->data[index];
|
assoc = dict_obj->data[index];
|
||||||
if (assoc == stx->nil) break;
|
if (assoc == stx->nil) break;
|
||||||
|
|
||||||
symbol = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY);
|
symbol = XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_KEY);
|
||||||
xp_assert (XP_STX_CLASS(stx,symbol) == stx->class_symbol);
|
xp_assert (xp_stx_classof(stx,symbol) == stx->class_symbol);
|
||||||
/*
|
|
||||||
* note that xp_strcmp should be compatible with
|
if (xp_strxcmp (XP_STX_DATA(stx,symbol),
|
||||||
* character object comparison in xp_stx_shallow_compare_object.
|
XP_STX_SIZE(stx,symbol), key) == 0) break;
|
||||||
* otherwise, you will be in trouble.
|
|
||||||
*/
|
|
||||||
if (xp_strcmp(key, XP_STX_DATA(stx,symbol)) == 0) break;
|
|
||||||
|
|
||||||
/* consider tally here too */
|
/* consider tally here too */
|
||||||
index = index % (size - 1) + 1;
|
index = index % (size - 1) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_printf (XP_TEXT("dict_lookup: %s, %d, %d\n"), key, index, XP_STX_WORD_AT(stx,dict,index));
|
|
||||||
return XP_STX_WORD_AT(stx,dict,index);
|
return XP_STX_WORD_AT(stx,dict,index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +163,6 @@ xp_word_t xp_stx_dict_put (
|
|||||||
}
|
}
|
||||||
else XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE) = value;
|
else XP_STX_WORD_AT(stx,assoc,XP_STX_ASSOCIATION_VALUE) = value;
|
||||||
|
|
||||||
xp_printf (XP_TEXT("dict_put %s %d\n"), XP_STX_DATA(stx,key),slot);
|
|
||||||
return XP_STX_WORD_AT(stx,dict,slot);
|
return XP_STX_WORD_AT(stx,dict,slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: object.c,v 1.38 2005-07-19 12:08:04 bacon Exp $
|
* $Id: object.c,v 1.39 2005-07-19 15:52:19 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/object.h>
|
#include <xp/stx/object.h>
|
||||||
@ -24,7 +24,6 @@ xp_word_t xp_stx_alloc_word_object (
|
|||||||
* number of variable instance variables) * word_size
|
* number of variable instance variables) * word_size
|
||||||
*/
|
*/
|
||||||
n = nfields + variable_nfields;
|
n = nfields + variable_nfields;
|
||||||
xp_printf (XP_TEXT(">> %d\n"), n);
|
|
||||||
idx = xp_stx_memory_alloc (&stx->memory,
|
idx = xp_stx_memory_alloc (&stx->memory,
|
||||||
n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t));
|
n * xp_sizeof(xp_word_t) + xp_sizeof(xp_stx_object_t));
|
||||||
if (idx >= stx->memory.capacity) return idx; /* failed TODO: return a difference value OINDEX_INVALID */
|
if (idx >= stx->memory.capacity) return idx; /* failed TODO: return a difference value OINDEX_INVALID */
|
||||||
@ -184,16 +183,6 @@ xp_word_t xp_stx_hash_object (xp_stx_t* stx, xp_word_t object)
|
|||||||
return hv;
|
return hv;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_bool_t xp_stx_shallow_compare_object (
|
|
||||||
xp_stx_t* stx, xp_word_t a, xp_word_t b)
|
|
||||||
{
|
|
||||||
if (XP_STX_TYPE(stx,a) != XP_STX_TYPE(stx,b)) return xp_false;
|
|
||||||
if (XP_STX_SIZE(stx,a) != XP_STX_SIZE(stx,b)) return xp_false;
|
|
||||||
if (XP_STX_CLASS(stx,a) != XP_STX_CLASS(stx,b)) return xp_false;
|
|
||||||
return xp_memcmp (XP_STX_DATA(stx,a),
|
|
||||||
XP_STX_DATA(stx,b), XP_STX_SIZE(stx,a)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
xp_word_t xp_stx_instantiate (
|
xp_word_t xp_stx_instantiate (
|
||||||
xp_stx_t* stx, xp_word_t class, const void* data,
|
xp_stx_t* stx, xp_word_t class, const void* data,
|
||||||
const void* variable_data, xp_word_t variable_nfields)
|
const void* variable_data, xp_word_t variable_nfields)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: object.h,v 1.27 2005-07-19 12:08:04 bacon Exp $
|
* $Id: object.h,v 1.28 2005-07-19 15:52:19 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_OBJECT_H_
|
#ifndef _XP_STX_OBJECT_H_
|
||||||
@ -25,8 +25,6 @@ xp_word_t xp_stx_alloc_char_objectx (
|
|||||||
xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...);
|
xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...);
|
||||||
|
|
||||||
xp_word_t xp_stx_hash_object (xp_stx_t* stx, xp_word_t object);
|
xp_word_t xp_stx_hash_object (xp_stx_t* stx, xp_word_t object);
|
||||||
xp_bool_t xp_stx_shallow_compare_object (
|
|
||||||
xp_stx_t* stx, xp_word_t a, xp_word_t b);
|
|
||||||
|
|
||||||
xp_word_t xp_stx_instantiate (
|
xp_word_t xp_stx_instantiate (
|
||||||
xp_stx_t* stx, xp_word_t class_index, const void* data,
|
xp_stx_t* stx, xp_word_t class_index, const void* data,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: symbol.c,v 1.17 2005-07-19 12:08:04 bacon Exp $
|
* $Id: symbol.c,v 1.18 2005-07-19 15:52:19 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/symbol.h>
|
#include <xp/stx/symbol.h>
|
||||||
@ -41,7 +41,7 @@ xp_word_t xp_stx_new_symbolx (
|
|||||||
else {
|
else {
|
||||||
do {
|
do {
|
||||||
x = XP_STX_WORD_AT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
x = XP_STX_WORD_AT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||||
xp_assert (XP_STX_CLASS(stx,x) == stx->class_symbol);
|
xp_assert (xp_stx_classof(stx,x) == stx->class_symbol);
|
||||||
|
|
||||||
if (xp_strxcmp (
|
if (xp_strxcmp (
|
||||||
XP_STX_DATA(stx,x),
|
XP_STX_DATA(stx,x),
|
||||||
|
Loading…
Reference in New Issue
Block a user