*** empty log message ***
This commit is contained in:
parent
62799e02fd
commit
c76d2d29b8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: bootstrp.c,v 1.8 2005-05-26 15:39:32 bacon Exp $
|
||||
* $Id: bootstrp.c,v 1.9 2005-05-29 16:51:16 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/bootstrp.h>
|
||||
@ -19,6 +19,8 @@ static void __set_names (
|
||||
static xp_stx_word_t __count_subclasses (const xp_stx_char_t* str);
|
||||
static void __set_subclasses (
|
||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
||||
static void __set_metaclass_subclasses (
|
||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
||||
|
||||
struct class_info_t
|
||||
{
|
||||
@ -207,10 +209,18 @@ int xp_stx_bootstrap (xp_stx_t* stx)
|
||||
|
||||
/* (Object class) setSuperclass: Class */
|
||||
object_meta = XP_STX_CLASS(stx,stx->class_object);
|
||||
XP_STX_AT(stx,object_meta,XP_STX_METACLASS_SUPERCLASS) = stx->class_class;
|
||||
XP_STX_WORDAT(stx,object_meta,XP_STX_METACLASS_SUPERCLASS) = stx->class_class;
|
||||
/* instance class for Object is set here as it is not
|
||||
* set in __create_builtin_classes */
|
||||
XP_STX_AT(stx,object_meta,XP_STX_METACLASS_INSTANCE_CLASS) = stx->class_object;
|
||||
XP_STX_WORDAT(stx,object_meta,XP_STX_METACLASS_INSTANCE_CLASS) = stx->class_object;
|
||||
|
||||
/* for some fun here */
|
||||
{
|
||||
xp_stx_word_t array;
|
||||
array = xp_stx_new_array (stx, 1);
|
||||
XP_STX_WORDAT(stx,array,0) = object_meta;
|
||||
XP_STX_WORDAT(stx,stx->class_class,XP_STX_CLASS_SUBCLASSES) = array;
|
||||
}
|
||||
|
||||
/* more initialization */
|
||||
XP_STX_CLASS(stx,stx->symbol_table) =
|
||||
@ -308,16 +318,16 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
||||
XP_STX_CLASS(stx,stx->class_pairlink) = class_PairlinkMeta;
|
||||
|
||||
/* (Symlink class) setSpec: XP_STX_CLASS_SIZE */
|
||||
XP_STX_AT(stx,class_SymlinkMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_WORDAT(stx,class_SymlinkMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
|
||||
/* (Symbol class) setSpec: CLASS_SIZE */
|
||||
XP_STX_AT(stx,class_SymbolMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_WORDAT(stx,class_SymbolMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
|
||||
/* (Metaclass class) setSpec: CLASS_SIZE */
|
||||
XP_STX_AT(stx,class_MetaclassMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_WORDAT(stx,class_MetaclassMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
|
||||
/* (Pairlink class) setSpec: CLASS_SIZE */
|
||||
XP_STX_AT(stx,class_PairlinkMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_WORDAT(stx,class_PairlinkMeta,XP_STX_CLASS_SPEC) =
|
||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
|
||||
|
||||
/* specs for class_metaclass, class_pairlink,
|
||||
@ -334,13 +344,13 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
||||
symbol_Pairlink = xp_stx_new_symbol (stx, XP_STX_TEXT("Pairlink"));
|
||||
|
||||
/* Symlink setName: #Symlink */
|
||||
XP_STX_AT(stx,stx->class_symlink,XP_STX_CLASS_NAME) = symbol_Symlink;
|
||||
XP_STX_WORDAT(stx,stx->class_symlink,XP_STX_CLASS_NAME) = symbol_Symlink;
|
||||
/* Symbol setName: #Symbol */
|
||||
XP_STX_AT(stx,stx->class_symbol,XP_STX_CLASS_NAME) = symbol_Symbol;
|
||||
XP_STX_WORDAT(stx,stx->class_symbol,XP_STX_CLASS_NAME) = symbol_Symbol;
|
||||
/* Metaclass setName: #Metaclass */
|
||||
XP_STX_AT(stx,stx->class_metaclass,XP_STX_CLASS_NAME) = symbol_Metaclass;
|
||||
XP_STX_WORDAT(stx,stx->class_metaclass,XP_STX_CLASS_NAME) = symbol_Metaclass;
|
||||
/* Pairlink setName: #Pairlink */
|
||||
XP_STX_AT(stx,stx->class_pairlink,XP_STX_CLASS_NAME) = symbol_Pairlink;
|
||||
XP_STX_WORDAT(stx,stx->class_pairlink,XP_STX_CLASS_NAME) = symbol_Pairlink;
|
||||
|
||||
/* register class names into the system dictionary */
|
||||
xp_stx_hash_insert (stx, stx->smalltalk,
|
||||
@ -362,6 +372,8 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
||||
class_info_t* p;
|
||||
xp_stx_word_t class, superclass, array;
|
||||
xp_stx_class_t* class_obj, * superclass_obj;
|
||||
xp_stx_word_t metaclass;
|
||||
xp_stx_metaclass_t* metaclass_obj;
|
||||
xp_stx_word_t n, spec;
|
||||
|
||||
xp_stx_assert (stx->class_array != stx->nil);
|
||||
@ -433,6 +445,19 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
||||
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
|
||||
class_obj->subclasses = array;
|
||||
}
|
||||
|
||||
/* fill subclasses for metaclasses */
|
||||
for (p = class_info; p->name != XP_NULL; p++) {
|
||||
n = __count_subclasses (p->name);
|
||||
array = xp_stx_new_array (stx, n);
|
||||
__set_metaclass_subclasses (stx, XP_STX_DATA(stx,array), p->name);
|
||||
|
||||
class = xp_stx_lookup_class(stx, p->name);
|
||||
xp_stx_assert (class != stx->nil);
|
||||
metaclass = XP_STX_CLASS(stx,class);
|
||||
metaclass_obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx, metaclass);
|
||||
metaclass_obj->subclasses = array;
|
||||
}
|
||||
}
|
||||
|
||||
static xp_stx_word_t __count_names (const xp_stx_char_t* str)
|
||||
@ -502,3 +527,18 @@ static void __set_subclasses (
|
||||
array[n++] = class;
|
||||
}
|
||||
}
|
||||
|
||||
static void __set_metaclass_subclasses (
|
||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str)
|
||||
{
|
||||
class_info_t* p;
|
||||
xp_stx_word_t n = 0, class;
|
||||
|
||||
for (p = class_info; p->name != XP_NULL; p++) {
|
||||
if (p->superclass == XP_NULL) continue;
|
||||
if (xp_stx_strcmp (str, p->superclass) != 0) continue;
|
||||
class = xp_stx_lookup_class (stx, p->name);
|
||||
xp_stx_assert (class != stx->nil);
|
||||
array[n++] = XP_STX_CLASS(stx,class);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: class.c,v 1.7 2005-05-25 16:44:05 bacon Exp $
|
||||
* $Id: class.c,v 1.8 2005-05-29 16:51:16 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/class.h>
|
||||
@ -17,14 +17,14 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name)
|
||||
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
|
||||
/* the spec of the metaclass must be the spec of its
|
||||
* instance. so the XP_STX_CLASS_SIZE is set */
|
||||
XP_STX_AT(stx,meta,XP_STX_METACLASS_SPEC) =
|
||||
XP_STX_WORDAT(stx,meta,XP_STX_METACLASS_SPEC) =
|
||||
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
|
||||
|
||||
/* the spec of the class is set later in __create_builtin_classes */
|
||||
class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE);
|
||||
XP_STX_CLASS(stx,class) = meta;
|
||||
class_name = xp_stx_new_symbol (stx, name);
|
||||
XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
||||
XP_STX_WORDAT(stx,class,XP_STX_CLASS_NAME) = class_name;
|
||||
|
||||
xp_stx_hash_insert (stx, stx->smalltalk,
|
||||
xp_stx_hash_char_object(stx, class_name),
|
||||
@ -40,7 +40,7 @@ xp_stx_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_stx_char_t* name)
|
||||
link = xp_stx_hash_lookup_symbol (stx, stx->smalltalk, name);
|
||||
if (link == stx->nil) return stx->nil;
|
||||
|
||||
value = XP_STX_AT(stx,link,XP_STX_PAIRLINK_VALUE);
|
||||
value = XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_VALUE);
|
||||
|
||||
meta = XP_STX_CLASS(stx,value);
|
||||
if (XP_STX_CLASS(stx,meta) != stx->class_metaclass) return stx->nil;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: hash.c,v 1.17 2005-05-22 15:03:20 bacon Exp $
|
||||
* $Id: hash.c,v 1.18 2005-05-29 16:51:16 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/hash.h>
|
||||
@ -16,9 +16,9 @@ xp_stx_word_t xp_stx_new_pairlink (
|
||||
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx, x);
|
||||
/*
|
||||
XP_STX_CLASS(stx,x) = stx->class_pairlink;
|
||||
XP_STX_AT(stx,x,XP_STX_PAIRLINK_LINK) = stx->nil;
|
||||
XP_STX_AT(stx,x,XP_STX_PAIRLINK_KEY) = key;
|
||||
XP_STX_AT(stx,x,XP_STX_PAIRLINK_VALUE) = value;
|
||||
XP_STX_WORDAT(stx,x,XP_STX_PAIRLINK_LINK) = stx->nil;
|
||||
XP_STX_WORDAT(stx,x,XP_STX_PAIRLINK_KEY) = key;
|
||||
XP_STX_WORDAT(stx,x,XP_STX_PAIRLINK_VALUE) = value;
|
||||
*/
|
||||
obj->header.class = stx->class_pairlink;
|
||||
obj->link = stx->nil;
|
||||
@ -39,12 +39,12 @@ xp_stx_word_t xp_stx_hash_lookup (
|
||||
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED);
|
||||
|
||||
hash = hash % XP_STX_SIZE(stx,table);
|
||||
link = XP_STX_AT(stx,table,hash);
|
||||
link = XP_STX_WORDAT(stx,table,hash);
|
||||
|
||||
while (link != stx->nil) {
|
||||
/*
|
||||
if (XP_STX_AT(stx,link,XP_STX_PAIRLINK_KEY) == key) return link;
|
||||
link = XP_STX_AT(stx,link,XP_STX_PAIRLINK_LINK);
|
||||
if (XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_KEY) == key) return link;
|
||||
link = XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_LINK);
|
||||
*/
|
||||
|
||||
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx,link);
|
||||
@ -65,7 +65,7 @@ xp_stx_word_t xp_stx_hash_lookup_symbol (
|
||||
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED);
|
||||
|
||||
hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table);
|
||||
link = XP_STX_AT(stx,table,hash);
|
||||
link = XP_STX_WORDAT(stx,table,hash);
|
||||
|
||||
while (link != stx->nil) {
|
||||
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx,link);
|
||||
@ -87,22 +87,22 @@ void xp_stx_hash_insert (
|
||||
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED);
|
||||
|
||||
hash = hash % XP_STX_SIZE(stx,table);
|
||||
link = XP_STX_AT(stx,table,hash);
|
||||
link = XP_STX_WORDAT(stx,table,hash);
|
||||
|
||||
if (link == stx->nil) {
|
||||
XP_STX_AT(stx,table,hash) =
|
||||
XP_STX_WORDAT(stx,table,hash) =
|
||||
xp_stx_new_pairlink (stx, key, value);
|
||||
}
|
||||
else {
|
||||
for (;;) {
|
||||
if (XP_STX_AT(stx,link,1) == key) {
|
||||
XP_STX_AT(stx,link,XP_STX_PAIRLINK_VALUE) = value;
|
||||
if (XP_STX_WORDAT(stx,link,1) == key) {
|
||||
XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_VALUE) = value;
|
||||
break;
|
||||
}
|
||||
|
||||
next = XP_STX_AT(stx,link,XP_STX_PAIRLINK_LINK);
|
||||
next = XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_LINK);
|
||||
if (next == stx->nil) {
|
||||
XP_STX_AT(stx,link,XP_STX_PAIRLINK_LINK) =
|
||||
XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_LINK) =
|
||||
xp_stx_new_pairlink (stx, key, value);
|
||||
break;
|
||||
}
|
||||
@ -120,11 +120,11 @@ void xp_stx_hash_traverse (
|
||||
xp_stx_word_t size = XP_STX_SIZE(stx,table);
|
||||
|
||||
while (size-- > 0) {
|
||||
link = XP_STX_AT(stx,table,size);
|
||||
link = XP_STX_WORDAT(stx,table,size);
|
||||
|
||||
while (link != stx->nil) {
|
||||
func (stx,link);
|
||||
link = XP_STX_AT(stx,link,XP_STX_PAIRLINK_LINK);
|
||||
link = XP_STX_WORDAT(stx,link,XP_STX_PAIRLINK_LINK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stx.h,v 1.22 2005-05-25 16:44:05 bacon Exp $
|
||||
* $Id: stx.h,v 1.23 2005-05-29 16:51:16 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_STX_H_
|
||||
@ -113,7 +113,7 @@ typedef xp_stx_cint_t (*xp_stx_getc_t) (void*);
|
||||
#define XP_STX_CHAR_OBJECT(stx,idx) \
|
||||
((xp_stx_char_object_t*)XP_STX_OBJECT(stx,idx))
|
||||
|
||||
#define XP_STX_AT(stx,idx,n) \
|
||||
#define XP_STX_WORDAT(stx,idx,n) \
|
||||
(((xp_stx_word_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
|
||||
#define XP_STX_BYTEAT(stx,idx,n) \
|
||||
(((xp_stx_byte_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: symbol.c,v 1.7 2005-05-23 15:51:03 bacon Exp $
|
||||
* $Id: symbol.c,v 1.8 2005-05-29 16:51:16 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/symbol.h>
|
||||
@ -12,8 +12,8 @@ xp_stx_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_stx_word_t sym)
|
||||
|
||||
x = xp_stx_alloc_word_object (stx, XP_STX_SYMLINK_SIZE);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symlink;
|
||||
XP_STX_AT(stx,x,XP_STX_SYMLINK_LINK) = stx->nil;
|
||||
XP_STX_AT(stx,x,XP_STX_SYMLINK_SYMBOL) = sym;
|
||||
XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_LINK) = stx->nil;
|
||||
XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_SYMBOL) = sym;
|
||||
|
||||
return x;
|
||||
}
|
||||
@ -24,27 +24,27 @@ xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name)
|
||||
|
||||
table = stx->symbol_table;
|
||||
hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table);
|
||||
link = XP_STX_AT(stx,table,hash);
|
||||
link = XP_STX_WORDAT(stx,table,hash);
|
||||
|
||||
if (link == stx->nil) {
|
||||
x = xp_stx_alloc_char_object (stx, name);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symbol;
|
||||
XP_STX_AT(stx,table,hash) = xp_stx_new_symlink(stx,x);
|
||||
XP_STX_WORDAT(stx,table,hash) = xp_stx_new_symlink(stx,x);
|
||||
}
|
||||
else {
|
||||
do {
|
||||
x = XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||
x = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||
xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol);
|
||||
|
||||
if (xp_stx_strxcmp (
|
||||
&XP_STX_CHARAT(stx,x,0),
|
||||
XP_STX_SIZE(stx,x), name) == 0) return x;
|
||||
|
||||
next = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
next = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
if (next == stx->nil) {
|
||||
x = xp_stx_alloc_char_object (stx, name);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symbol;
|
||||
XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK) =
|
||||
XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK) =
|
||||
xp_stx_new_symlink(stx,x);
|
||||
break;
|
||||
}
|
||||
@ -63,27 +63,27 @@ xp_stx_word_t xp_stx_new_symbolx (
|
||||
|
||||
table = stx->symbol_table;
|
||||
hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table);
|
||||
link = XP_STX_AT(stx,table,hash);
|
||||
link = XP_STX_WORDAT(stx,table,hash);
|
||||
|
||||
if (link == stx->nil) {
|
||||
x = xp_stx_alloc_char_objectx (stx, name, len);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symbol;
|
||||
XP_STX_AT(stx,table,hash) = xp_stx_new_symlink(stx,x);
|
||||
XP_STX_WORDAT(stx,table,hash) = xp_stx_new_symlink(stx,x);
|
||||
}
|
||||
else {
|
||||
do {
|
||||
x = XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||
x = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||
xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol);
|
||||
|
||||
if (xp_stx_strxcmp (
|
||||
&XP_STX_CHARAT(stx,x,0),
|
||||
XP_STX_SIZE(stx,x), name) == 0) return x;
|
||||
|
||||
next = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
next = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
if (next == stx->nil) {
|
||||
x = xp_stx_alloc_char_objectx (stx, name, len);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symbol;
|
||||
XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK) =
|
||||
XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK) =
|
||||
xp_stx_new_symlink(stx,x);
|
||||
break;
|
||||
}
|
||||
@ -103,27 +103,27 @@ xp_stx_word_t xp_stx_new_symbol_pp (
|
||||
|
||||
table = stx->symbol_table;
|
||||
hash = xp_stx_strhash(name) % XP_STX_SIZE(stx,table);
|
||||
link = XP_STX_AT(stx,table,hash);
|
||||
link = XP_STX_WORDAT(stx,table,hash);
|
||||
|
||||
if (link == stx->nil) {
|
||||
x = xp_stx_allocn_char_object (stx, prefix, name, postfix);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symbol;
|
||||
XP_STX_AT(stx,table,hash) = xp_stx_new_symlink(stx,x);
|
||||
XP_STX_WORDAT(stx,table,hash) = xp_stx_new_symlink(stx,x);
|
||||
}
|
||||
else {
|
||||
do {
|
||||
x = XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||
x = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL);
|
||||
xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol);
|
||||
|
||||
if (xp_stx_strxcmp (
|
||||
&XP_STX_CHARAT(stx,x,0),
|
||||
XP_STX_SIZE(stx,x), name) == 0) return x;
|
||||
|
||||
next = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
next = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
if (next == stx->nil) {
|
||||
x = xp_stx_allocn_char_object (stx, prefix, name, postfix);
|
||||
XP_STX_CLASS(stx,x) = stx->class_symbol;
|
||||
XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK) =
|
||||
XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK) =
|
||||
xp_stx_new_symlink(stx,x);
|
||||
break;
|
||||
}
|
||||
@ -147,11 +147,11 @@ void xp_stx_traverse_symbol_table (
|
||||
size = XP_STX_SIZE(stx,table);
|
||||
|
||||
while (size-- > 0) {
|
||||
link = XP_STX_AT(stx,table,size);
|
||||
link = XP_STX_WORDAT(stx,table,size);
|
||||
|
||||
while (link != stx->nil) {
|
||||
func (stx,XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL));
|
||||
link = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
func (stx,XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_SYMBOL));
|
||||
link = XP_STX_WORDAT(stx,link,XP_STX_SYMLINK_LINK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ void print_symbol_names (xp_stx_t* stx, xp_stx_word_t sym)
|
||||
|
||||
void print_symbol_names_2 (xp_stx_t* stx, xp_stx_word_t idx)
|
||||
{
|
||||
xp_stx_word_t key = XP_STX_AT(stx,idx,XP_STX_PAIRLINK_KEY);
|
||||
xp_stx_word_t value = XP_STX_AT(stx,idx,XP_STX_PAIRLINK_VALUE);
|
||||
xp_stx_word_t key = XP_STX_WORDAT(stx,idx,XP_STX_PAIRLINK_KEY);
|
||||
xp_stx_word_t value = XP_STX_WORDAT(stx,idx,XP_STX_PAIRLINK_VALUE);
|
||||
xp_printf (XP_TEXT("%lu [%s] %lu\n"),
|
||||
(unsigned long)key, &XP_STX_CHARAT(stx,key,0), (unsigned long)value);
|
||||
}
|
||||
|
||||
void print_class_hierachy (xp_stx_t* stx, const xp_char_t* name)
|
||||
void print_superclasses (xp_stx_t* stx, const xp_char_t* name)
|
||||
{
|
||||
xp_stx_word_t n;
|
||||
xp_stx_class_t* obj;
|
||||
@ -45,7 +45,7 @@ void print_class_hierachy (xp_stx_t* stx, const xp_char_t* name)
|
||||
}
|
||||
}
|
||||
|
||||
void print_metaclass_hierachy (xp_stx_t* stx, const xp_char_t* name)
|
||||
void print_metaclass_superclasses (xp_stx_t* stx, const xp_char_t* name)
|
||||
{
|
||||
xp_stx_word_t n, x;
|
||||
xp_stx_metaclass_t* obj;
|
||||
@ -85,7 +85,22 @@ void print_class_name (xp_stx_t* stx, xp_stx_word_t class, int tabs)
|
||||
|
||||
xp_printf (XP_TEXT("%s [%lu]\n"),
|
||||
XP_STX_DATA(stx, xobj->name),
|
||||
(unsigned long)xobj->name);
|
||||
(unsigned long)class);
|
||||
}
|
||||
|
||||
void print_metaclass_name (xp_stx_t* stx, xp_stx_word_t class, int tabs)
|
||||
{
|
||||
xp_stx_metaclass_t* obj;
|
||||
xp_stx_class_t* xobj;
|
||||
|
||||
obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,class);
|
||||
xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,obj->instance_class);
|
||||
|
||||
while (tabs-- > 0) xp_printf (XP_TEXT(" "));
|
||||
|
||||
xp_printf (XP_TEXT("%s class [%lu]\n"),
|
||||
XP_STX_DATA(stx, xobj->name),
|
||||
(unsigned long)class);
|
||||
}
|
||||
|
||||
void print_subclass_names (xp_stx_t* stx, xp_stx_word_t class, int tabs)
|
||||
@ -93,13 +108,18 @@ void print_subclass_names (xp_stx_t* stx, xp_stx_word_t class, int tabs)
|
||||
xp_stx_class_t* obj;
|
||||
|
||||
obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class);
|
||||
print_class_name (stx, class, tabs);
|
||||
if (obj->header.class == stx->class_metaclass) {
|
||||
print_metaclass_name (stx, class, tabs);
|
||||
}
|
||||
else {
|
||||
print_class_name (stx, class, tabs);
|
||||
}
|
||||
|
||||
if (obj->subclasses != stx->nil) {
|
||||
xp_stx_word_t count = XP_STX_SIZE(stx, obj->subclasses);
|
||||
while (count-- > 0) {
|
||||
print_subclass_names (stx,
|
||||
XP_STX_AT(stx,obj->subclasses,count), tabs + 1);
|
||||
XP_STX_WORDAT(stx,obj->subclasses,count), tabs + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,10 +128,12 @@ void print_subclasses (xp_stx_t* stx, const xp_char_t* name)
|
||||
{
|
||||
xp_stx_word_t class;
|
||||
class = xp_stx_lookup_class (stx, name);
|
||||
xp_printf (XP_TEXT("== NORMAL == \n"));
|
||||
print_subclass_names (stx, class, 0);
|
||||
xp_printf (XP_TEXT("== META == \n"));
|
||||
print_subclass_names (stx, XP_STX_CLASS(stx,class), 0);
|
||||
}
|
||||
|
||||
|
||||
int xp_main (int argc, xp_char_t* argv[])
|
||||
{
|
||||
xp_stx_t stx;
|
||||
@ -151,21 +173,21 @@ int xp_main (int argc, xp_char_t* argv[])
|
||||
xp_stx_hash_traverse (&stx, stx.smalltalk, print_symbol_names_2);
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
|
||||
print_class_hierachy (&stx, XP_STX_TEXT("Array"));
|
||||
print_superclasses (&stx, XP_STX_TEXT("Array"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_metaclass_hierachy (&stx, XP_STX_TEXT("Array"));
|
||||
print_metaclass_superclasses (&stx, XP_STX_TEXT("Array"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_class_hierachy (&stx, XP_STX_TEXT("False"));
|
||||
print_superclasses (&stx, XP_STX_TEXT("False"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_metaclass_hierachy (&stx, XP_STX_TEXT("False"));
|
||||
print_metaclass_superclasses (&stx, XP_STX_TEXT("False"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_class_hierachy (&stx, XP_STX_TEXT("Metaclass"));
|
||||
print_superclasses (&stx, XP_STX_TEXT("Metaclass"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_metaclass_hierachy (&stx, XP_STX_TEXT("Metaclass"));
|
||||
print_metaclass_superclasses (&stx, XP_STX_TEXT("Metaclass"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_class_hierachy (&stx, XP_STX_TEXT("Class"));
|
||||
print_superclasses (&stx, XP_STX_TEXT("Class"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
print_metaclass_hierachy (&stx, XP_STX_TEXT("Class"));
|
||||
print_metaclass_superclasses (&stx, XP_STX_TEXT("Class"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
|
||||
print_subclasses (&stx, XP_STX_TEXT("Object"));
|
||||
|
Loading…
Reference in New Issue
Block a user