*** empty log message ***
This commit is contained in:
parent
ed2f88e00d
commit
f3dc7b12d6
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bootstrp.c,v 1.10 2005-05-30 07:27:29 bacon Exp $
|
* $Id: bootstrp.c,v 1.11 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/bootstrp.h>
|
#include <xp/stx/bootstrp.h>
|
||||||
@ -13,23 +13,23 @@ static void __create_bootstrapping_objects (xp_stx_t* stx);
|
|||||||
static void __create_builtin_classes (xp_stx_t* stx);
|
static void __create_builtin_classes (xp_stx_t* stx);
|
||||||
static void __filein_kernel (xp_stx_t* stx);
|
static void __filein_kernel (xp_stx_t* stx);
|
||||||
|
|
||||||
static xp_stx_word_t __count_names (const xp_stx_char_t* str);
|
static xp_word_t __count_names (const xp_char_t* str);
|
||||||
static void __set_names (
|
static void __set_names (
|
||||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
xp_stx_t* stx, xp_word_t* array, const xp_char_t* str);
|
||||||
|
|
||||||
static xp_stx_word_t __count_subclasses (const xp_stx_char_t* str);
|
static xp_word_t __count_subclasses (const xp_char_t* str);
|
||||||
static void __set_subclasses (
|
static void __set_subclasses (
|
||||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
xp_stx_t* stx, xp_word_t* array, const xp_char_t* str);
|
||||||
static void __set_metaclass_subclasses (
|
static void __set_metaclass_subclasses (
|
||||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
xp_stx_t* stx, xp_word_t* array, const xp_char_t* str);
|
||||||
|
|
||||||
struct class_info_t
|
struct class_info_t
|
||||||
{
|
{
|
||||||
const xp_stx_char_t* name;
|
const xp_char_t* name;
|
||||||
const xp_stx_char_t* superclass;
|
const xp_char_t* superclass;
|
||||||
const xp_stx_char_t* instance_variables;
|
const xp_char_t* instance_variables;
|
||||||
const xp_stx_char_t* class_variables;
|
const xp_char_t* class_variables;
|
||||||
const xp_stx_char_t* pool_dictionaries;
|
const xp_char_t* pool_dictionaries;
|
||||||
const int is_indexable;
|
const int is_indexable;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ typedef struct class_info_t class_info_t;
|
|||||||
static class_info_t class_info[] =
|
static class_info_t class_info[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
@ -46,128 +46,128 @@ static class_info_t class_info[] =
|
|||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("UndefinedObject"),
|
XP_TEXT("UndefinedObject"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Behavior"),
|
XP_TEXT("Behavior"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_STX_TEXT("spec methods superclass"),
|
XP_TEXT("spec methods superclass"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Class"),
|
XP_TEXT("Class"),
|
||||||
XP_STX_TEXT("Behavior"),
|
XP_TEXT("Behavior"),
|
||||||
XP_STX_TEXT("name variables classVariables poolDictionaries"),
|
XP_TEXT("name variables classVariables poolDictionaries"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Metaclass"),
|
XP_TEXT("Metaclass"),
|
||||||
XP_STX_TEXT("Behavior"),
|
XP_TEXT("Behavior"),
|
||||||
XP_STX_TEXT("instanceClass"),
|
XP_TEXT("instanceClass"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Block"),
|
XP_TEXT("Block"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_STX_TEXT("context argCount argLoc bytePointer"),
|
XP_TEXT("context argCount argLoc bytePointer"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Boolean"),
|
XP_TEXT("Boolean"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("True"),
|
XP_TEXT("True"),
|
||||||
XP_STX_TEXT("Boolean"),
|
XP_TEXT("Boolean"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("False"),
|
XP_TEXT("False"),
|
||||||
XP_STX_TEXT("Boolean"),
|
XP_TEXT("Boolean"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Context"),
|
XP_TEXT("Context"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Method"),
|
XP_TEXT("Method"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_STX_TEXT("text message bytecodes literals stackSize temporarySize class"),
|
XP_TEXT("text message bytecodes literals stackSize temporarySize class"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Magnitude"),
|
XP_TEXT("Magnitude"),
|
||||||
XP_STX_TEXT("Object"),
|
XP_TEXT("Object"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Collection"),
|
XP_TEXT("Collection"),
|
||||||
XP_STX_TEXT("Magnitude"),
|
XP_TEXT("Magnitude"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("IndexedCollection"),
|
XP_TEXT("IndexedCollection"),
|
||||||
XP_STX_TEXT("Collection"),
|
XP_TEXT("Collection"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("Array"),
|
XP_TEXT("Array"),
|
||||||
XP_STX_TEXT("IndexedCollection"),
|
XP_TEXT("IndexedCollection"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("SymbolTable"),
|
XP_TEXT("SymbolTable"),
|
||||||
XP_STX_TEXT("IndexedCollection"),
|
XP_TEXT("IndexedCollection"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_STX_TEXT("SystemDictionary"),
|
XP_TEXT("SystemDictionary"),
|
||||||
XP_STX_TEXT("IndexedCollection"),
|
XP_TEXT("IndexedCollection"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
@ -183,11 +183,11 @@ static class_info_t class_info[] =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_array (xp_stx_t* stx, xp_stx_word_t size)
|
xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size)
|
||||||
{
|
{
|
||||||
xp_stx_word_t x;
|
xp_word_t x;
|
||||||
|
|
||||||
xp_stx_assert (stx->class_array != stx->nil);
|
xp_assert (stx->class_array != stx->nil);
|
||||||
x = xp_stx_alloc_word_object (stx, size);
|
x = xp_stx_alloc_word_object (stx, size);
|
||||||
XP_STX_CLASS(stx,x) = stx->class_array;
|
XP_STX_CLASS(stx,x) = stx->class_array;
|
||||||
|
|
||||||
@ -196,16 +196,16 @@ xp_stx_word_t xp_stx_new_array (xp_stx_t* stx, xp_stx_word_t size)
|
|||||||
|
|
||||||
int xp_stx_bootstrap (xp_stx_t* stx)
|
int xp_stx_bootstrap (xp_stx_t* stx)
|
||||||
{
|
{
|
||||||
xp_stx_word_t symbol_Smalltalk;
|
xp_word_t symbol_Smalltalk;
|
||||||
xp_stx_word_t object_meta;
|
xp_word_t object_meta;
|
||||||
|
|
||||||
__create_bootstrapping_objects (stx);
|
__create_bootstrapping_objects (stx);
|
||||||
|
|
||||||
/* object, class, and array are precreated for easier instantiation
|
/* object, class, and array are precreated for easier instantiation
|
||||||
* of builtin classes */
|
* of builtin classes */
|
||||||
stx->class_object = xp_stx_new_class (stx, XP_STX_TEXT("Object"));
|
stx->class_object = xp_stx_new_class (stx, XP_TEXT("Object"));
|
||||||
stx->class_class = xp_stx_new_class (stx, XP_STX_TEXT("Class"));
|
stx->class_class = xp_stx_new_class (stx, XP_TEXT("Class"));
|
||||||
stx->class_array = xp_stx_new_class (stx, XP_STX_TEXT("Array"));
|
stx->class_array = xp_stx_new_class (stx, XP_TEXT("Array"));
|
||||||
|
|
||||||
__create_builtin_classes (stx);
|
__create_builtin_classes (stx);
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ int xp_stx_bootstrap (xp_stx_t* stx)
|
|||||||
|
|
||||||
/* for some fun here */
|
/* for some fun here */
|
||||||
{
|
{
|
||||||
xp_stx_word_t array;
|
xp_word_t array;
|
||||||
array = xp_stx_new_array (stx, 1);
|
array = xp_stx_new_array (stx, 1);
|
||||||
XP_STX_WORDAT(stx,array,0) = object_meta;
|
XP_STX_WORDAT(stx,array,0) = object_meta;
|
||||||
XP_STX_WORDAT(stx,stx->class_class,XP_STX_CLASS_SUBCLASSES) = array;
|
XP_STX_WORDAT(stx,stx->class_class,XP_STX_CLASS_SUBCLASSES) = array;
|
||||||
@ -226,30 +226,30 @@ int xp_stx_bootstrap (xp_stx_t* stx)
|
|||||||
|
|
||||||
/* more initialization */
|
/* more initialization */
|
||||||
XP_STX_CLASS(stx,stx->symbol_table) =
|
XP_STX_CLASS(stx,stx->symbol_table) =
|
||||||
xp_stx_lookup_class (stx, XP_STX_TEXT("SymbolTable"));
|
xp_stx_lookup_class (stx, XP_TEXT("SymbolTable"));
|
||||||
XP_STX_CLASS(stx,stx->smalltalk) =
|
XP_STX_CLASS(stx,stx->smalltalk) =
|
||||||
xp_stx_lookup_class (stx, XP_STX_TEXT("SystemDictionary"));
|
xp_stx_lookup_class (stx, XP_TEXT("SystemDictionary"));
|
||||||
|
|
||||||
symbol_Smalltalk =
|
symbol_Smalltalk =
|
||||||
xp_stx_new_symbol (stx, XP_STX_TEXT("Smalltalk"));
|
xp_stx_new_symbol (stx, XP_TEXT("Smalltalk"));
|
||||||
xp_stx_hash_insert (stx, stx->smalltalk,
|
xp_stx_hash_insert (stx, stx->smalltalk,
|
||||||
xp_stx_hash_char_object(stx,symbol_Smalltalk),
|
xp_stx_hash_char_object(stx,symbol_Smalltalk),
|
||||||
symbol_Smalltalk, stx->smalltalk);
|
symbol_Smalltalk, stx->smalltalk);
|
||||||
|
|
||||||
/* create #nil, #true, #false */
|
/* create #nil, #true, #false */
|
||||||
xp_stx_new_symbol (stx, XP_STX_TEXT("nil"));
|
xp_stx_new_symbol (stx, XP_TEXT("nil"));
|
||||||
xp_stx_new_symbol (stx, XP_STX_TEXT("true"));
|
xp_stx_new_symbol (stx, XP_TEXT("true"));
|
||||||
xp_stx_new_symbol (stx, XP_STX_TEXT("false"));
|
xp_stx_new_symbol (stx, XP_TEXT("false"));
|
||||||
|
|
||||||
/* nil setClass: UndefinedObject */
|
/* nil setClass: UndefinedObject */
|
||||||
XP_STX_CLASS(stx,stx->nil) =
|
XP_STX_CLASS(stx,stx->nil) =
|
||||||
xp_stx_lookup_class (stx, XP_STX_TEXT("UndefinedObject"));
|
xp_stx_lookup_class (stx, XP_TEXT("UndefinedObject"));
|
||||||
/* true setClass: True */
|
/* true setClass: True */
|
||||||
XP_STX_CLASS(stx,stx->true) =
|
XP_STX_CLASS(stx,stx->true) =
|
||||||
xp_stx_lookup_class (stx, XP_STX_TEXT("True"));
|
xp_stx_lookup_class (stx, XP_TEXT("True"));
|
||||||
/* fales setClass: False */
|
/* fales setClass: False */
|
||||||
XP_STX_CLASS(stx,stx->false) =
|
XP_STX_CLASS(stx,stx->false) =
|
||||||
xp_stx_lookup_class (stx, XP_STX_TEXT("False"));
|
xp_stx_lookup_class (stx, XP_TEXT("False"));
|
||||||
|
|
||||||
|
|
||||||
__filein_kernel (stx);
|
__filein_kernel (stx);
|
||||||
@ -258,23 +258,23 @@ int xp_stx_bootstrap (xp_stx_t* stx)
|
|||||||
|
|
||||||
static void __create_bootstrapping_objects (xp_stx_t* stx)
|
static void __create_bootstrapping_objects (xp_stx_t* stx)
|
||||||
{
|
{
|
||||||
xp_stx_word_t class_SymlinkMeta;
|
xp_word_t class_SymlinkMeta;
|
||||||
xp_stx_word_t class_SymbolMeta;
|
xp_word_t class_SymbolMeta;
|
||||||
xp_stx_word_t class_MetaclassMeta;
|
xp_word_t class_MetaclassMeta;
|
||||||
xp_stx_word_t class_PairlinkMeta;
|
xp_word_t class_PairlinkMeta;
|
||||||
xp_stx_word_t symbol_Symlink;
|
xp_word_t symbol_Symlink;
|
||||||
xp_stx_word_t symbol_Symbol;
|
xp_word_t symbol_Symbol;
|
||||||
xp_stx_word_t symbol_Metaclass;
|
xp_word_t symbol_Metaclass;
|
||||||
xp_stx_word_t symbol_Pairlink;
|
xp_word_t symbol_Pairlink;
|
||||||
|
|
||||||
/* allocate three keyword objects */
|
/* allocate three keyword objects */
|
||||||
stx->nil = xp_stx_alloc_word_object (stx, 0);
|
stx->nil = xp_stx_alloc_word_object (stx, 0);
|
||||||
stx->true = xp_stx_alloc_word_object (stx, 0);
|
stx->true = xp_stx_alloc_word_object (stx, 0);
|
||||||
stx->false = xp_stx_alloc_word_object (stx, 0);
|
stx->false = xp_stx_alloc_word_object (stx, 0);
|
||||||
|
|
||||||
xp_stx_assert (stx->nil == XP_STX_NIL);
|
xp_assert (stx->nil == XP_STX_NIL);
|
||||||
xp_stx_assert (stx->true == XP_STX_TRUE);
|
xp_assert (stx->true == XP_STX_TRUE);
|
||||||
xp_stx_assert (stx->false == XP_STX_FALSE);
|
xp_assert (stx->false == XP_STX_FALSE);
|
||||||
|
|
||||||
/* symbol table & system dictionary */
|
/* symbol table & system dictionary */
|
||||||
/* TODO: symbol table and dictionary size */
|
/* TODO: symbol table and dictionary size */
|
||||||
@ -339,13 +339,13 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
|||||||
* __create_builtin_classes */
|
* __create_builtin_classes */
|
||||||
|
|
||||||
/* #Symlink */
|
/* #Symlink */
|
||||||
symbol_Symlink = xp_stx_new_symbol (stx, XP_STX_TEXT("Symlink"));
|
symbol_Symlink = xp_stx_new_symbol (stx, XP_TEXT("Symlink"));
|
||||||
/* #Symbol */
|
/* #Symbol */
|
||||||
symbol_Symbol = xp_stx_new_symbol (stx, XP_STX_TEXT("Symbol"));
|
symbol_Symbol = xp_stx_new_symbol (stx, XP_TEXT("Symbol"));
|
||||||
/* #Metaclass */
|
/* #Metaclass */
|
||||||
symbol_Metaclass = xp_stx_new_symbol (stx, XP_STX_TEXT("Metaclass"));
|
symbol_Metaclass = xp_stx_new_symbol (stx, XP_TEXT("Metaclass"));
|
||||||
/* #Pairlink */
|
/* #Pairlink */
|
||||||
symbol_Pairlink = xp_stx_new_symbol (stx, XP_STX_TEXT("Pairlink"));
|
symbol_Pairlink = xp_stx_new_symbol (stx, XP_TEXT("Pairlink"));
|
||||||
|
|
||||||
/* Symlink setName: #Symlink */
|
/* Symlink setName: #Symlink */
|
||||||
XP_STX_WORDAT(stx,stx->class_symlink,XP_STX_CLASS_NAME) = symbol_Symlink;
|
XP_STX_WORDAT(stx,stx->class_symlink,XP_STX_CLASS_NAME) = symbol_Symlink;
|
||||||
@ -374,13 +374,13 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
|||||||
static void __create_builtin_classes (xp_stx_t* stx)
|
static void __create_builtin_classes (xp_stx_t* stx)
|
||||||
{
|
{
|
||||||
class_info_t* p;
|
class_info_t* p;
|
||||||
xp_stx_word_t class, superclass, array;
|
xp_word_t class, superclass, array;
|
||||||
xp_stx_class_t* class_obj, * superclass_obj;
|
xp_stx_class_t* class_obj, * superclass_obj;
|
||||||
xp_stx_word_t metaclass;
|
xp_word_t metaclass;
|
||||||
xp_stx_metaclass_t* metaclass_obj;
|
xp_stx_metaclass_t* metaclass_obj;
|
||||||
xp_stx_word_t n, spec;
|
xp_word_t n, spec;
|
||||||
|
|
||||||
xp_stx_assert (stx->class_array != stx->nil);
|
xp_assert (stx->class_array != stx->nil);
|
||||||
|
|
||||||
for (p = class_info; p->name != XP_NULL; p++) {
|
for (p = class_info; p->name != XP_NULL; p++) {
|
||||||
class = xp_stx_lookup_class(stx, p->name);
|
class = xp_stx_lookup_class(stx, p->name);
|
||||||
@ -388,18 +388,18 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
|||||||
class = xp_stx_new_class (stx, p->name);
|
class = xp_stx_new_class (stx, p->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_assert (class != stx->nil);
|
xp_assert (class != stx->nil);
|
||||||
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
|
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
|
||||||
class_obj->superclass = (p->superclass == XP_NULL)?
|
class_obj->superclass = (p->superclass == XP_NULL)?
|
||||||
stx->nil: xp_stx_lookup_class(stx,p->superclass);
|
stx->nil: xp_stx_lookup_class(stx,p->superclass);
|
||||||
|
|
||||||
spec = 0;
|
spec = 0;
|
||||||
if (p->superclass != XP_NULL) {
|
if (p->superclass != XP_NULL) {
|
||||||
xp_stx_word_t meta;
|
xp_word_t meta;
|
||||||
xp_stx_metaclass_t* meta_obj;
|
xp_stx_metaclass_t* meta_obj;
|
||||||
|
|
||||||
superclass = xp_stx_lookup_class(stx,p->superclass);
|
superclass = xp_stx_lookup_class(stx,p->superclass);
|
||||||
xp_stx_assert (superclass != stx->nil);
|
xp_assert (superclass != stx->nil);
|
||||||
|
|
||||||
meta = class_obj->header.class;
|
meta = class_obj->header.class;
|
||||||
meta_obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,meta);
|
meta_obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,meta);
|
||||||
@ -445,7 +445,7 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
|||||||
__set_subclasses (stx, XP_STX_DATA(stx,array), p->name);
|
__set_subclasses (stx, XP_STX_DATA(stx,array), p->name);
|
||||||
|
|
||||||
class = xp_stx_lookup_class(stx, p->name);
|
class = xp_stx_lookup_class(stx, p->name);
|
||||||
xp_stx_assert (class != stx->nil);
|
xp_assert (class != stx->nil);
|
||||||
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
|
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
|
||||||
class_obj->subclasses = array;
|
class_obj->subclasses = array;
|
||||||
}
|
}
|
||||||
@ -457,57 +457,57 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
|||||||
__set_metaclass_subclasses (stx, XP_STX_DATA(stx,array), p->name);
|
__set_metaclass_subclasses (stx, XP_STX_DATA(stx,array), p->name);
|
||||||
|
|
||||||
class = xp_stx_lookup_class(stx, p->name);
|
class = xp_stx_lookup_class(stx, p->name);
|
||||||
xp_stx_assert (class != stx->nil);
|
xp_assert (class != stx->nil);
|
||||||
metaclass = XP_STX_CLASS(stx,class);
|
metaclass = XP_STX_CLASS(stx,class);
|
||||||
metaclass_obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx, metaclass);
|
metaclass_obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx, metaclass);
|
||||||
metaclass_obj->subclasses = array;
|
metaclass_obj->subclasses = array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static xp_stx_word_t __count_names (const xp_stx_char_t* str)
|
static xp_word_t __count_names (const xp_char_t* str)
|
||||||
{
|
{
|
||||||
xp_stx_word_t n = 0;
|
xp_word_t n = 0;
|
||||||
const xp_stx_char_t* p = str;
|
const xp_char_t* p = str;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
while (*p == XP_STX_CHAR(' ') ||
|
while (*p == XP_CHAR(' ') ||
|
||||||
*p == XP_STX_CHAR('\t')) p++;
|
*p == XP_CHAR('\t')) p++;
|
||||||
if (*p == XP_STX_CHAR('\0')) break;
|
if (*p == XP_CHAR('\0')) break;
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
while (*p != XP_STX_CHAR(' ') &&
|
while (*p != XP_CHAR(' ') &&
|
||||||
*p != XP_STX_CHAR('\t') &&
|
*p != XP_CHAR('\t') &&
|
||||||
*p != XP_STX_CHAR('\0')) p++;
|
*p != XP_CHAR('\0')) p++;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __set_names (
|
static void __set_names (
|
||||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str)
|
xp_stx_t* stx, xp_word_t* array, const xp_char_t* str)
|
||||||
{
|
{
|
||||||
xp_stx_word_t n = 0;
|
xp_word_t n = 0;
|
||||||
const xp_stx_char_t* p = str;
|
const xp_char_t* p = str;
|
||||||
const xp_stx_char_t* name;
|
const xp_char_t* name;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
while (*p == XP_STX_CHAR(' ') ||
|
while (*p == XP_CHAR(' ') ||
|
||||||
*p == XP_STX_CHAR('\t')) p++;
|
*p == XP_CHAR('\t')) p++;
|
||||||
if (*p == XP_STX_CHAR('\0')) break;
|
if (*p == XP_CHAR('\0')) break;
|
||||||
|
|
||||||
name = p;
|
name = p;
|
||||||
while (*p != XP_STX_CHAR(' ') &&
|
while (*p != XP_CHAR(' ') &&
|
||||||
*p != XP_STX_CHAR('\t') &&
|
*p != XP_CHAR('\t') &&
|
||||||
*p != XP_STX_CHAR('\0')) p++;
|
*p != XP_CHAR('\0')) p++;
|
||||||
|
|
||||||
array[n++] = xp_stx_new_symbolx (stx, name, p - name);
|
array[n++] = xp_stx_new_symbolx (stx, name, p - name);
|
||||||
} while (1);
|
} while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static xp_stx_word_t __count_subclasses (const xp_stx_char_t* str)
|
static xp_word_t __count_subclasses (const xp_char_t* str)
|
||||||
{
|
{
|
||||||
class_info_t* p;
|
class_info_t* p;
|
||||||
xp_stx_word_t n = 0;
|
xp_word_t n = 0;
|
||||||
|
|
||||||
for (p = class_info; p->name != XP_NULL; p++) {
|
for (p = class_info; p->name != XP_NULL; p++) {
|
||||||
if (p->superclass == XP_NULL) continue;
|
if (p->superclass == XP_NULL) continue;
|
||||||
@ -518,31 +518,31 @@ static xp_stx_word_t __count_subclasses (const xp_stx_char_t* str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void __set_subclasses (
|
static void __set_subclasses (
|
||||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str)
|
xp_stx_t* stx, xp_word_t* array, const xp_char_t* str)
|
||||||
{
|
{
|
||||||
class_info_t* p;
|
class_info_t* p;
|
||||||
xp_stx_word_t n = 0, class;
|
xp_word_t n = 0, class;
|
||||||
|
|
||||||
for (p = class_info; p->name != XP_NULL; p++) {
|
for (p = class_info; p->name != XP_NULL; p++) {
|
||||||
if (p->superclass == XP_NULL) continue;
|
if (p->superclass == XP_NULL) continue;
|
||||||
if (xp_stx_strcmp (str, p->superclass) != 0) continue;
|
if (xp_stx_strcmp (str, p->superclass) != 0) continue;
|
||||||
class = xp_stx_lookup_class (stx, p->name);
|
class = xp_stx_lookup_class (stx, p->name);
|
||||||
xp_stx_assert (class != stx->nil);
|
xp_assert (class != stx->nil);
|
||||||
array[n++] = class;
|
array[n++] = class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __set_metaclass_subclasses (
|
static void __set_metaclass_subclasses (
|
||||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str)
|
xp_stx_t* stx, xp_word_t* array, const xp_char_t* str)
|
||||||
{
|
{
|
||||||
class_info_t* p;
|
class_info_t* p;
|
||||||
xp_stx_word_t n = 0, class;
|
xp_word_t n = 0, class;
|
||||||
|
|
||||||
for (p = class_info; p->name != XP_NULL; p++) {
|
for (p = class_info; p->name != XP_NULL; p++) {
|
||||||
if (p->superclass == XP_NULL) continue;
|
if (p->superclass == XP_NULL) continue;
|
||||||
if (xp_stx_strcmp (str, p->superclass) != 0) continue;
|
if (xp_stx_strcmp (str, p->superclass) != 0) continue;
|
||||||
class = xp_stx_lookup_class (stx, p->name);
|
class = xp_stx_lookup_class (stx, p->name);
|
||||||
xp_stx_assert (class != stx->nil);
|
xp_assert (class != stx->nil);
|
||||||
array[n++] = XP_STX_CLASS(stx,class);
|
array[n++] = XP_STX_CLASS(stx,class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bootstrp.h,v 1.2 2005-05-23 15:51:03 bacon Exp $
|
* $Id: bootstrp.h,v 1.3 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_BOOTSTRP_H_
|
#ifndef _XP_STX_BOOTSTRP_H_
|
||||||
@ -12,7 +12,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_array (xp_stx_t* stx, xp_stx_word_t size);
|
xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size);
|
||||||
int xp_stx_bootstrap (xp_stx_t* stx);
|
int xp_stx_bootstrap (xp_stx_t* stx);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: class.c,v 1.8 2005-05-29 16:51:16 bacon Exp $
|
* $Id: class.c,v 1.9 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
@ -8,10 +8,10 @@
|
|||||||
#include <xp/stx/hash.h>
|
#include <xp/stx/hash.h>
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name)
|
xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name)
|
||||||
{
|
{
|
||||||
xp_stx_word_t meta, class;
|
xp_word_t meta, class;
|
||||||
xp_stx_word_t class_name;
|
xp_word_t class_name;
|
||||||
|
|
||||||
meta = xp_stx_alloc_word_object (stx, XP_STX_METACLASS_SIZE);
|
meta = xp_stx_alloc_word_object (stx, XP_STX_METACLASS_SIZE);
|
||||||
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
|
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
|
||||||
@ -33,9 +33,9 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name)
|
|||||||
return class;
|
return class;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_stx_char_t* name)
|
xp_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_char_t* name)
|
||||||
{
|
{
|
||||||
xp_stx_word_t link, meta, value;
|
xp_word_t link, meta, value;
|
||||||
|
|
||||||
link = xp_stx_hash_lookup_symbol (stx, stx->smalltalk, name);
|
link = xp_stx_hash_lookup_symbol (stx, stx->smalltalk, name);
|
||||||
if (link == stx->nil) return stx->nil;
|
if (link == stx->nil) return stx->nil;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: class.h,v 1.5 2005-05-26 15:39:32 bacon Exp $
|
* $Id: class.h,v 1.6 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_CLASS_H_
|
#ifndef _XP_STX_CLASS_H_
|
||||||
@ -28,24 +28,24 @@
|
|||||||
struct xp_stx_class_t
|
struct xp_stx_class_t
|
||||||
{
|
{
|
||||||
xp_stx_objhdr_t header;
|
xp_stx_objhdr_t header;
|
||||||
xp_stx_word_t spec; /* indexable: 1, nfields: the rest */
|
xp_word_t spec; /* indexable: 1, nfields: the rest */
|
||||||
xp_stx_word_t methods;
|
xp_word_t methods;
|
||||||
xp_stx_word_t superclass;
|
xp_word_t superclass;
|
||||||
xp_stx_word_t subclasses;
|
xp_word_t subclasses;
|
||||||
xp_stx_word_t name;
|
xp_word_t name;
|
||||||
xp_stx_word_t variables;
|
xp_word_t variables;
|
||||||
xp_stx_word_t class_variables;
|
xp_word_t class_variables;
|
||||||
xp_stx_word_t pool_dictonaries;
|
xp_word_t pool_dictonaries;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xp_stx_metaclass_t
|
struct xp_stx_metaclass_t
|
||||||
{
|
{
|
||||||
xp_stx_objhdr_t header;
|
xp_stx_objhdr_t header;
|
||||||
xp_stx_word_t spec;
|
xp_word_t spec;
|
||||||
xp_stx_word_t methods;
|
xp_word_t methods;
|
||||||
xp_stx_word_t superclass;
|
xp_word_t superclass;
|
||||||
xp_stx_word_t subclasses;
|
xp_word_t subclasses;
|
||||||
xp_stx_word_t instance_class;
|
xp_word_t instance_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct xp_stx_class_t xp_stx_class_t;
|
typedef struct xp_stx_class_t xp_stx_class_t;
|
||||||
@ -55,8 +55,8 @@ typedef struct xp_stx_metaclass_t xp_stx_metaclass_t;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name);
|
xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name);
|
||||||
xp_stx_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_stx_char_t* name);
|
xp_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_char_t* name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: context.c,v 1.7 2005-05-23 14:43:03 bacon Exp $
|
* $Id: context.c,v 1.8 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/context.h>
|
#include <xp/stx/context.h>
|
||||||
@ -7,10 +7,10 @@
|
|||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
|
xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
||||||
xp_stx_word_t method, xp_stx_word_t args, xp_stx_word_t temp)
|
xp_word_t method, xp_word_t args, xp_word_t temp)
|
||||||
{
|
{
|
||||||
xp_stx_word_t context;
|
xp_word_t context;
|
||||||
xp_stx_context_t* obj;
|
xp_stx_context_t* obj;
|
||||||
|
|
||||||
context = xp_stx_alloc_word_object(stx,XP_STX_CONTEXT_SIZE);
|
context = xp_stx_alloc_word_object(stx,XP_STX_CONTEXT_SIZE);
|
||||||
@ -23,7 +23,7 @@ xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
||||||
obj->header.class = xp_stx_lookup_class(stx,XP_STX_TEXT("Context"));
|
obj->header.class = xp_stx_lookup_class(stx,XP_TEXT("Context"));
|
||||||
obj->ip = XP_STX_TO_SMALLINT(0);
|
obj->ip = XP_STX_TO_SMALLINT(0);
|
||||||
obj->method = method;
|
obj->method = method;
|
||||||
obj->arguments = args;
|
obj->arguments = args;
|
||||||
@ -32,25 +32,25 @@ xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
static xp_stx_byte_t __fetch_byte (
|
static xp_byte_t __fetch_byte (
|
||||||
xp_stx_t* stx, xp_stx_context_t* context_obj)
|
xp_stx_t* stx, xp_stx_context_t* context_obj)
|
||||||
{
|
{
|
||||||
xp_stx_word_t ip, method;
|
xp_word_t ip, method;
|
||||||
|
|
||||||
xp_stx_assert (XP_STX_IS_SMALLINT(context_obj->ip));
|
xp_assert (XP_STX_IS_SMALLINT(context_obj->ip));
|
||||||
ip = XP_STX_FROM_SMALLINT(context_obj->ip);
|
ip = XP_STX_FROM_SMALLINT(context_obj->ip);
|
||||||
method = context_obj->method;
|
method = context_obj->method;
|
||||||
|
|
||||||
/* increment instruction pointer */
|
/* increment instruction pointer */
|
||||||
context_obj->ip = XP_STX_TO_SMALLINT(ip + 1);
|
context_obj->ip = XP_STX_TO_SMALLINT(ip + 1);
|
||||||
|
|
||||||
xp_stx_assert (XP_STX_TYPE(stx,method) == XP_STX_BYTE_INDEXED);
|
xp_assert (XP_STX_TYPE(stx,method) == XP_STX_BYTE_INDEXED);
|
||||||
return XP_STX_BYTEAT(stx,method,ip);
|
return XP_STX_BYTEAT(stx,method,ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xp_stx_run_context (xp_stx_t* stx, xp_stx_word_t context)
|
int xp_stx_run_context (xp_stx_t* stx, xp_word_t context)
|
||||||
{
|
{
|
||||||
xp_stx_byte_t byte, operand;
|
xp_byte_t byte, operand;
|
||||||
xp_stx_context_t* context_obj;
|
xp_stx_context_t* context_obj;
|
||||||
|
|
||||||
context_obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
context_obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: context.h,v 1.2 2005-05-21 16:11:06 bacon Exp $
|
* $Id: context.h,v 1.3 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_CONTEXT_H_
|
#ifndef _XP_STX_CONTEXT_H_
|
||||||
@ -20,10 +20,10 @@
|
|||||||
struct xp_stx_context_t
|
struct xp_stx_context_t
|
||||||
{
|
{
|
||||||
xp_stx_objhdr_t header;
|
xp_stx_objhdr_t header;
|
||||||
xp_stx_word_t ip;
|
xp_word_t ip;
|
||||||
xp_stx_word_t method;
|
xp_word_t method;
|
||||||
xp_stx_word_t arguments;
|
xp_word_t arguments;
|
||||||
xp_stx_word_t temporaries;
|
xp_word_t temporaries;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct xp_stx_context_t xp_stx_context_t;
|
typedef struct xp_stx_context_t xp_stx_context_t;
|
||||||
@ -32,9 +32,9 @@ typedef struct xp_stx_context_t xp_stx_context_t;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
|
xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
||||||
xp_stx_word_t method, xp_stx_word_t args, xp_stx_word_t temp);
|
xp_word_t method, xp_word_t args, xp_word_t temp);
|
||||||
int xp_stx_run_context (xp_stx_t* stx, xp_stx_word_t context);
|
int xp_stx_run_context (xp_stx_t* stx, xp_word_t context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: extra.h,v 1.1 2005-05-15 18:37:00 bacon Exp $
|
* $Id: extra.h,v 1.2 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_EXTRA_H_
|
#ifndef _XP_STX_EXTRA_H_
|
||||||
@ -11,15 +11,15 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strlen (const xp_stx_char_t* str)
|
xp_word_t xp_stx_strlen (const xp_char_t* str)
|
||||||
|
|
||||||
int xp_stx_strcmp (
|
int xp_stx_strcmp (
|
||||||
const xp_stx_char_t* s1, const xp_stx_char_t* s2);
|
const xp_char_t* s1, const xp_char_t* s2);
|
||||||
int xp_stx_strxcmp (
|
int xp_stx_strxcmp (
|
||||||
const xp_stx_char_t* s1, xp_stx_word_t len, const xp_stx_char_t* s2);
|
const xp_char_t* s1, xp_word_t len, const xp_char_t* s2);
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strhash (const xp_stx_char_t* str);
|
xp_word_t xp_stx_strhash (const xp_char_t* str);
|
||||||
xp_stx_word_t xp_stx_strxhash (const xp_stx_char_t* str, xp_stx_word_t len);
|
xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: hash.c,v 1.18 2005-05-29 16:51:16 bacon Exp $
|
* $Id: hash.c,v 1.19 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/hash.h>
|
#include <xp/stx/hash.h>
|
||||||
#include <xp/stx/object.h>
|
#include <xp/stx/object.h>
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_pairlink (
|
xp_word_t xp_stx_new_pairlink (
|
||||||
xp_stx_t* stx, xp_stx_word_t key, xp_stx_word_t value)
|
xp_stx_t* stx, xp_word_t key, xp_word_t value)
|
||||||
{
|
{
|
||||||
xp_stx_word_t x;
|
xp_word_t x;
|
||||||
xp_stx_pairlink_t* obj;
|
xp_stx_pairlink_t* obj;
|
||||||
|
|
||||||
x = xp_stx_alloc_word_object (stx, XP_STX_PAIRLINK_SIZE);
|
x = xp_stx_alloc_word_object (stx, XP_STX_PAIRLINK_SIZE);
|
||||||
@ -29,14 +29,14 @@ xp_stx_word_t xp_stx_new_pairlink (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* returns the entire link */
|
/* returns the entire link */
|
||||||
xp_stx_word_t xp_stx_hash_lookup (
|
xp_word_t xp_stx_hash_lookup (
|
||||||
xp_stx_t* stx, xp_stx_word_t table,
|
xp_stx_t* stx, xp_word_t table,
|
||||||
xp_stx_word_t hash, xp_stx_word_t key)
|
xp_word_t hash, xp_word_t key)
|
||||||
{
|
{
|
||||||
xp_stx_word_t link;
|
xp_word_t link;
|
||||||
xp_stx_pairlink_t* obj;
|
xp_stx_pairlink_t* obj;
|
||||||
|
|
||||||
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED);
|
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);
|
||||||
link = XP_STX_WORDAT(stx,table,hash);
|
link = XP_STX_WORDAT(stx,table,hash);
|
||||||
@ -55,21 +55,21 @@ xp_stx_word_t xp_stx_hash_lookup (
|
|||||||
return stx->nil; /* not found */
|
return stx->nil; /* not found */
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_hash_lookup_symbol (
|
xp_word_t xp_stx_hash_lookup_symbol (
|
||||||
xp_stx_t* stx, xp_stx_word_t table, const xp_stx_char_t* name)
|
xp_stx_t* stx, xp_word_t table, const xp_char_t* name)
|
||||||
{
|
{
|
||||||
xp_stx_word_t link, hash;
|
xp_word_t link, hash;
|
||||||
xp_stx_pairlink_t* obj;
|
xp_stx_pairlink_t* obj;
|
||||||
xp_stx_char_object_t* tmp;
|
xp_stx_char_object_t* tmp;
|
||||||
|
|
||||||
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED);
|
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);
|
||||||
link = XP_STX_WORDAT(stx,table,hash);
|
link = XP_STX_WORDAT(stx,table,hash);
|
||||||
|
|
||||||
while (link != stx->nil) {
|
while (link != stx->nil) {
|
||||||
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx,link);
|
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx,link);
|
||||||
tmp = XP_STX_CHAR_OBJECT(stx,obj->key);
|
tmp = XP_CHAR_OBJECT(stx,obj->key);
|
||||||
if (tmp->header.class == stx->class_symbol &&
|
if (tmp->header.class == stx->class_symbol &&
|
||||||
xp_stx_strcmp (tmp->data, name) == 0) return link;
|
xp_stx_strcmp (tmp->data, name) == 0) return link;
|
||||||
link = obj->link;
|
link = obj->link;
|
||||||
@ -79,12 +79,12 @@ xp_stx_word_t xp_stx_hash_lookup_symbol (
|
|||||||
}
|
}
|
||||||
|
|
||||||
void xp_stx_hash_insert (
|
void xp_stx_hash_insert (
|
||||||
xp_stx_t* stx, xp_stx_word_t table,
|
xp_stx_t* stx, xp_word_t table,
|
||||||
xp_stx_word_t hash, xp_stx_word_t key, xp_stx_word_t value)
|
xp_word_t hash, xp_word_t key, xp_word_t value)
|
||||||
{
|
{
|
||||||
xp_stx_word_t link, next;
|
xp_word_t link, next;
|
||||||
|
|
||||||
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_WORD_INDEXED);
|
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);
|
||||||
link = XP_STX_WORDAT(stx,table,hash);
|
link = XP_STX_WORDAT(stx,table,hash);
|
||||||
@ -113,11 +113,11 @@ void xp_stx_hash_insert (
|
|||||||
}
|
}
|
||||||
|
|
||||||
void xp_stx_hash_traverse (
|
void xp_stx_hash_traverse (
|
||||||
xp_stx_t* stx, xp_stx_word_t table,
|
xp_stx_t* stx, xp_word_t table,
|
||||||
void (*func) (xp_stx_t*,xp_stx_word_t))
|
void (*func) (xp_stx_t*,xp_word_t))
|
||||||
{
|
{
|
||||||
xp_stx_word_t link;
|
xp_word_t link;
|
||||||
xp_stx_word_t size = XP_STX_SIZE(stx,table);
|
xp_word_t size = XP_STX_SIZE(stx,table);
|
||||||
|
|
||||||
while (size-- > 0) {
|
while (size-- > 0) {
|
||||||
link = XP_STX_WORDAT(stx,table,size);
|
link = XP_STX_WORDAT(stx,table,size);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: hash.h,v 1.8 2005-05-22 15:03:20 bacon Exp $
|
* $Id: hash.h,v 1.9 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_HASH_H_
|
#ifndef _XP_STX_HASH_H_
|
||||||
@ -15,9 +15,9 @@
|
|||||||
struct xp_stx_pairlink_t
|
struct xp_stx_pairlink_t
|
||||||
{
|
{
|
||||||
xp_stx_objhdr_t header;
|
xp_stx_objhdr_t header;
|
||||||
xp_stx_word_t link;
|
xp_word_t link;
|
||||||
xp_stx_word_t key;
|
xp_word_t key;
|
||||||
xp_stx_word_t value;
|
xp_word_t value;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct xp_stx_pairlink_t xp_stx_pairlink_t;
|
typedef struct xp_stx_pairlink_t xp_stx_pairlink_t;
|
||||||
@ -27,19 +27,19 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* hash table manipulation */
|
/* hash table manipulation */
|
||||||
xp_stx_word_t xp_stx_new_plink (
|
xp_word_t xp_stx_new_plink (
|
||||||
xp_stx_t* stx, xp_stx_word_t key, xp_stx_word_t value);
|
xp_stx_t* stx, xp_word_t key, xp_word_t value);
|
||||||
xp_stx_word_t xp_stx_hash_lookup (
|
xp_word_t xp_stx_hash_lookup (
|
||||||
xp_stx_t* stx, xp_stx_word_t table,
|
xp_stx_t* stx, xp_word_t table,
|
||||||
xp_stx_word_t hash, xp_stx_word_t key);
|
xp_word_t hash, xp_word_t key);
|
||||||
xp_stx_word_t xp_stx_hash_lookup_symbol (
|
xp_word_t xp_stx_hash_lookup_symbol (
|
||||||
xp_stx_t* stx, xp_stx_word_t table, const xp_stx_char_t* name);
|
xp_stx_t* stx, xp_word_t table, const xp_char_t* name);
|
||||||
void xp_stx_hash_insert (
|
void xp_stx_hash_insert (
|
||||||
xp_stx_t* stx, xp_stx_word_t table,
|
xp_stx_t* stx, xp_word_t table,
|
||||||
xp_stx_word_t hash, xp_stx_word_t key, xp_stx_word_t value);
|
xp_word_t hash, xp_word_t key, xp_word_t value);
|
||||||
void xp_stx_hash_traverse (
|
void xp_stx_hash_traverse (
|
||||||
xp_stx_t* stx, xp_stx_word_t table,
|
xp_stx_t* stx, xp_word_t table,
|
||||||
void (*func) (xp_stx_t*,xp_stx_word_t));
|
void (*func) (xp_stx_t*,xp_word_t));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: interp.c,v 1.3 2005-05-18 04:01:51 bacon Exp $
|
* $Id: interp.c,v 1.4 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/interp.h>
|
#include <xp/stx/interp.h>
|
||||||
@ -36,18 +36,18 @@ static byte_code_func_t byte_code_funcs[] =
|
|||||||
do_special
|
do_special
|
||||||
};
|
};
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_method (xp_stx_t* stx)
|
xp_word_t xp_stx_new_method (xp_stx_t* stx)
|
||||||
{
|
{
|
||||||
xp_stx_word_t method;
|
xp_word_t method;
|
||||||
method = xp_stx_alloc_object(XP_STX_METHOD_SIZE);
|
method = xp_stx_alloc_object(XP_STX_METHOD_SIZE);
|
||||||
|
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
|
xp_word_t xp_stx_new_context (xp_stx_t* stx,
|
||||||
xp_stx_word_t method, xp_stx_word_t args, xp_stx_word_t temp)
|
xp_word_t method, xp_word_t args, xp_word_t temp)
|
||||||
{
|
{
|
||||||
xp_stx_word_t context;
|
xp_word_t context;
|
||||||
|
|
||||||
context = xp_stx_alloc_object(XP_STX_CONTEXT_SIZE);
|
context = xp_stx_alloc_object(XP_STX_CONTEXT_SIZE);
|
||||||
XP_STX_CLASS(stx,context) = stx->class_context;
|
XP_STX_CLASS(stx,context) = stx->class_context;
|
||||||
@ -58,9 +58,9 @@ xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_new_process (xp_stx_t* stx, xp_stx_word_t method)
|
xp_word_t xp_stx_new_process (xp_stx_t* stx, xp_word_t method)
|
||||||
{
|
{
|
||||||
xp_stx_word_t process, stx;
|
xp_word_t process, stx;
|
||||||
|
|
||||||
process = xp_stx_alloc_object(XP_STX_PROCESS_SIZE);
|
process = xp_stx_alloc_object(XP_STX_PROCESS_SIZE);
|
||||||
stack = xp_new_array(stx,50);
|
stack = xp_new_array(stx,50);
|
||||||
@ -80,7 +80,7 @@ xp_stx_word_t xp_stx_new_process (xp_stx_t* stx, xp_stx_word_t method)
|
|||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xp_stx_execute (xp_stx_t* stx, xp_stx_word_t process)
|
int xp_stx_execute (xp_stx_t* stx, xp_word_t process)
|
||||||
{
|
{
|
||||||
int low, high;
|
int low, high;
|
||||||
byte_code_func_t bcfunc;
|
byte_code_func_t bcfunc;
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: memory.c,v 1.11 2005-05-20 04:01:12 bacon Exp $
|
* $Id: memory.c,v 1.12 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/memory.h>
|
#include <xp/stx/memory.h>
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
xp_stx_memory_t* xp_stx_memory_open (
|
xp_stx_memory_t* xp_stx_memory_open (
|
||||||
xp_stx_memory_t* mem, xp_stx_word_t capacity)
|
xp_stx_memory_t* mem, xp_word_t capacity)
|
||||||
{
|
{
|
||||||
xp_stx_object_t** slots;
|
xp_stx_object_t** slots;
|
||||||
xp_stx_word_t n;
|
xp_word_t n;
|
||||||
|
|
||||||
xp_stx_assert (capacity > 0);
|
xp_assert (capacity > 0);
|
||||||
if (mem == XP_NULL) {
|
if (mem == XP_NULL) {
|
||||||
mem = (xp_stx_memory_t*)xp_stx_malloc(xp_sizeof(xp_stx_memory_t));
|
mem = (xp_stx_memory_t*)xp_malloc(xp_sizeof(xp_stx_memory_t));
|
||||||
if (mem == XP_NULL) return XP_NULL;
|
if (mem == XP_NULL) return XP_NULL;
|
||||||
mem->__malloced = xp_true;
|
mem->__malloced = xp_true;
|
||||||
}
|
}
|
||||||
else mem->__malloced = xp_false;
|
else mem->__malloced = xp_false;
|
||||||
|
|
||||||
slots = (xp_stx_object_t**)xp_stx_malloc (
|
slots = (xp_stx_object_t**)xp_malloc (
|
||||||
capacity * xp_sizeof(xp_stx_object_t*));
|
capacity * xp_sizeof(xp_stx_object_t*));
|
||||||
if (slots == XP_NULL) {
|
if (slots == XP_NULL) {
|
||||||
if (mem->__malloced) xp_stx_free (mem);
|
if (mem->__malloced) xp_free (mem);
|
||||||
mem = XP_NULL;
|
mem = XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,11 +43,11 @@ void xp_stx_memory_close (xp_stx_memory_t* mem)
|
|||||||
{
|
{
|
||||||
/* TODO: free all linked objects... */
|
/* TODO: free all linked objects... */
|
||||||
|
|
||||||
xp_stx_free (mem->slots);
|
xp_free (mem->slots);
|
||||||
mem->capacity = 0;
|
mem->capacity = 0;
|
||||||
mem->slots = XP_NULL;
|
mem->slots = XP_NULL;
|
||||||
mem->free = XP_NULL;
|
mem->free = XP_NULL;
|
||||||
if (mem->__malloced) xp_stx_free (mem);
|
if (mem->__malloced) xp_free (mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xp_stx_memory_gc (xp_stx_memory_t* mem)
|
void xp_stx_memory_gc (xp_stx_memory_t* mem)
|
||||||
@ -55,7 +55,7 @@ void xp_stx_memory_gc (xp_stx_memory_t* mem)
|
|||||||
/* TODO: implement this function */
|
/* TODO: implement this function */
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_stx_word_t nbytes)
|
xp_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_word_t nbytes)
|
||||||
{
|
{
|
||||||
xp_stx_object_t** slot;
|
xp_stx_object_t** slot;
|
||||||
xp_stx_object_t* object;
|
xp_stx_object_t* object;
|
||||||
@ -66,13 +66,13 @@ xp_stx_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_stx_word_t nbytes)
|
|||||||
if (mem->free == XP_NULL) return mem->capacity;;
|
if (mem->free == XP_NULL) return mem->capacity;;
|
||||||
}
|
}
|
||||||
|
|
||||||
object = (xp_stx_object_t*)xp_stx_malloc (nbytes);
|
object = (xp_stx_object_t*)xp_malloc (nbytes);
|
||||||
if (object == XP_NULL) {
|
if (object == XP_NULL) {
|
||||||
xp_stx_memory_gc (mem);
|
xp_stx_memory_gc (mem);
|
||||||
object = (xp_stx_object_t*)xp_stx_malloc (nbytes);
|
object = (xp_stx_object_t*)xp_malloc (nbytes);
|
||||||
/*if (object == XP_NULL) return mem->capacity;*/
|
/*if (object == XP_NULL) return mem->capacity;*/
|
||||||
if (object == XP_NULL) {
|
if (object == XP_NULL) {
|
||||||
xp_stx_assert (XP_TEXT("MEMORY ALLOCATION ERROR\n") == XP_NULL);
|
xp_assert (XP_TEXT("MEMORY ALLOCATION ERROR\n") == XP_NULL);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,17 +81,17 @@ exit (1);
|
|||||||
mem->free = (xp_stx_object_t**)*slot;
|
mem->free = (xp_stx_object_t**)*slot;
|
||||||
*slot = object;
|
*slot = object;
|
||||||
|
|
||||||
return (xp_stx_word_t)(slot - mem->slots);
|
return (xp_word_t)(slot - mem->slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xp_stx_memory_dealloc (xp_stx_memory_t* mem, xp_stx_word_t object_index)
|
void xp_stx_memory_dealloc (xp_stx_memory_t* mem, xp_word_t object_index)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* THIS IS PRIMITIVE LOW-LEVEL DEALLOC. THIS WILL NOT
|
* THIS IS PRIMITIVE LOW-LEVEL DEALLOC. THIS WILL NOT
|
||||||
* DEALLOCATE MEMORY ALLOCATED FOR ITS INSTANCE VARIABLES.
|
* DEALLOCATE MEMORY ALLOCATED FOR ITS INSTANCE VARIABLES.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xp_stx_free (mem->slots[object_index]);
|
xp_free (mem->slots[object_index]);
|
||||||
mem->slots[object_index] = (xp_stx_object_t*)mem->free;
|
mem->slots[object_index] = (xp_stx_object_t*)mem->free;
|
||||||
mem->free = &mem->slots[object_index];
|
mem->free = &mem->slots[object_index];
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: memory.h,v 1.5 2005-05-08 10:31:24 bacon Exp $
|
* $Id: memory.h,v 1.6 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_MEMORY_H_
|
#ifndef _XP_STX_MEMORY_H_
|
||||||
@ -12,12 +12,12 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_stx_memory_t* xp_stx_memory_open (
|
xp_stx_memory_t* xp_stx_memory_open (
|
||||||
xp_stx_memory_t* mem, xp_stx_word_t capacity);
|
xp_stx_memory_t* mem, xp_word_t capacity);
|
||||||
void xp_stx_memory_close (xp_stx_memory_t* mem);
|
void xp_stx_memory_close (xp_stx_memory_t* mem);
|
||||||
|
|
||||||
void xp_stx_memory_gc (xp_stx_memory_t* mem);
|
void xp_stx_memory_gc (xp_stx_memory_t* mem);
|
||||||
xp_stx_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_stx_word_t size);
|
xp_word_t xp_stx_memory_alloc (xp_stx_memory_t* mem, xp_word_t size);
|
||||||
void xp_stx_memory_dealloc (xp_stx_memory_t* mem, xp_stx_word_t object_index);
|
void xp_stx_memory_dealloc (xp_stx_memory_t* mem, xp_word_t object_index);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.c,v 1.2 2005-05-16 14:14:34 bacon Exp $
|
* $Id: misc.c,v 1.3 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strlen (const xp_stx_char_t* str)
|
xp_word_t xp_stx_strlen (const xp_char_t* str)
|
||||||
{
|
{
|
||||||
const xp_stx_char_t* p = str;
|
const xp_char_t* p = str;
|
||||||
while (*p != XP_STX_CHAR('\0')) p++;
|
while (*p != XP_CHAR('\0')) p++;
|
||||||
return p - str;
|
return p - str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xp_stx_strcmp (const xp_stx_char_t* s1, const xp_stx_char_t* s2)
|
int xp_stx_strcmp (const xp_char_t* s1, const xp_char_t* s2)
|
||||||
{
|
{
|
||||||
while (*s1 == *s2 && *s2 != XP_STX_CHAR('\0')) s1++, s2++;
|
while (*s1 == *s2 && *s2 != XP_CHAR('\0')) s1++, s2++;
|
||||||
if (*s1 > *s2) return 1;
|
if (*s1 > *s2) return 1;
|
||||||
else if (*s1 < *s2) return -1;
|
else if (*s1 < *s2) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xp_stx_strxcmp (
|
int xp_stx_strxcmp (
|
||||||
const xp_stx_char_t* s1, xp_stx_word_t len, const xp_stx_char_t* s2)
|
const xp_char_t* s1, xp_word_t len, const xp_char_t* s2)
|
||||||
{
|
{
|
||||||
const xp_stx_char_t* end = s1 + len;
|
const xp_char_t* end = s1 + len;
|
||||||
while (s1 < end && *s2 != XP_STX_CHAR('\0') && *s1 == *s2) {
|
while (s1 < end && *s2 != XP_CHAR('\0') && *s1 == *s2) {
|
||||||
s1++; s2++;
|
s1++; s2++;
|
||||||
}
|
}
|
||||||
if (s1 == end && *s2 == XP_STX_CHAR('\0')) return 0;
|
if (s1 == end && *s2 == XP_CHAR('\0')) return 0;
|
||||||
if (*s1 == *s2) return (s1 < end)? 1: -1;
|
if (*s1 == *s2) return (s1 < end)? 1: -1;
|
||||||
return (*s1 > *s2)? 1: -1;
|
return (*s1 > *s2)? 1: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strhash (const xp_stx_char_t* str)
|
xp_word_t xp_stx_strhash (const xp_char_t* str)
|
||||||
{
|
{
|
||||||
xp_stx_word_t h = 0;
|
xp_word_t h = 0;
|
||||||
xp_stx_byte_t* bp, * be;
|
xp_byte_t* bp, * be;
|
||||||
const xp_stx_char_t* p = str;
|
const xp_char_t* p = str;
|
||||||
|
|
||||||
while (*p != XP_STX_CHAR('\0')) {
|
while (*p != XP_CHAR('\0')) {
|
||||||
bp = (xp_stx_byte_t*)p;
|
bp = (xp_byte_t*)p;
|
||||||
be = bp + xp_sizeof(xp_stx_char_t);
|
be = bp + xp_sizeof(xp_char_t);
|
||||||
while (bp < be) h = h * 31 + *bp++;
|
while (bp < be) h = h * 31 + *bp++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -47,15 +47,15 @@ xp_stx_word_t xp_stx_strhash (const xp_stx_char_t* str)
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strxhash (const xp_stx_char_t* str, xp_stx_word_t len)
|
xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len)
|
||||||
{
|
{
|
||||||
xp_stx_word_t h = 0;
|
xp_word_t h = 0;
|
||||||
xp_stx_byte_t* bp, * be;
|
xp_byte_t* bp, * be;
|
||||||
const xp_stx_char_t* p = str, * end = str + len;
|
const xp_char_t* p = str, * end = str + len;
|
||||||
|
|
||||||
while (p < end) {
|
while (p < end) {
|
||||||
bp = (xp_stx_byte_t*)p;
|
bp = (xp_byte_t*)p;
|
||||||
be = bp + xp_sizeof(xp_stx_char_t);
|
be = bp + xp_sizeof(xp_char_t);
|
||||||
while (bp < be) h = h * 31 + *bp++;
|
while (bp < be) h = h * 31 + *bp++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.h,v 1.4 2005-06-05 05:26:24 bacon Exp $
|
* $Id: misc.h,v 1.5 2005-06-08 16:00:51 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_MISC_H_
|
#ifndef _XP_STX_MISC_H_
|
||||||
@ -14,51 +14,53 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#define xp_stx_assert assert
|
#define xp_assert assert
|
||||||
#define xp_stx_malloc malloc
|
#define xp_malloc malloc
|
||||||
#define xp_stx_realloc realloc
|
#define xp_realloc realloc
|
||||||
#define xp_stx_free free
|
#define xp_free free
|
||||||
#define xp_stx_va_list va_list
|
#define xp_va_list va_list
|
||||||
#define xp_stx_va_start va_start
|
#define xp_va_start va_start
|
||||||
#define xp_stx_va_end va_end
|
#define xp_va_end va_end
|
||||||
#define xp_stx_va_arg va_arg
|
#define xp_va_arg va_arg
|
||||||
#define xp_stx_isspace isspace
|
#define xp_isspace isspace
|
||||||
#define xp_stx_isdigit isdigit
|
#define xp_isdigit isdigit
|
||||||
#define xp_stx_isalpha isalpha
|
#define xp_isalpha isalpha
|
||||||
#define xp_stx_isalnum isalnum
|
#define xp_isalnum isalnum
|
||||||
#else
|
#else
|
||||||
#include <xp/bas/memory.h>
|
#include <xp/bas/memory.h>
|
||||||
#include <xp/bas/assert.h>
|
#include <xp/bas/assert.h>
|
||||||
#include <xp/bas/stdarg.h>
|
#include <xp/bas/stdarg.h>
|
||||||
#include <xp/bas/ctype.h>
|
#include <xp/bas/ctype.h>
|
||||||
|
|
||||||
#define xp_stx_assert xp_assert
|
/*
|
||||||
#define xp_stx_malloc xp_malloc
|
#define xp_assert xp_assert
|
||||||
#define xp_stx_realloc xp_realloc
|
#define xp_malloc xp_malloc
|
||||||
#define xp_stx_free xp_free
|
#define xp_realloc xp_realloc
|
||||||
#define xp_stx_va_list xp_va_list
|
#define xp_free xp_free
|
||||||
#define xp_stx_va_start xp_va_start
|
#define xp_va_list xp_va_list
|
||||||
#define xp_stx_va_end xp_va_end
|
#define xp_va_start xp_va_start
|
||||||
#define xp_stx_va_arg xp_va_arg
|
#define xp_va_end xp_va_end
|
||||||
#define xp_stx_isspace xp_isspace
|
#define xp_va_arg xp_va_arg
|
||||||
#define xp_stx_isdigit xp_isdigit
|
#define xp_isspace xp_isspace
|
||||||
#define xp_stx_isalpha xp_isalpha
|
#define xp_isdigit xp_isdigit
|
||||||
#define xp_stx_isalnum xp_isalnum
|
#define xp_isalpha xp_isalpha
|
||||||
|
#define xp_isalnum xp_isalnum
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strlen (const xp_stx_char_t* str);
|
xp_word_t xp_stx_strlen (const xp_char_t* str);
|
||||||
|
|
||||||
int xp_stx_strcmp (
|
int xp_stx_strcmp (
|
||||||
const xp_stx_char_t* s1, const xp_stx_char_t* s2);
|
const xp_char_t* s1, const xp_char_t* s2);
|
||||||
int xp_stx_strxcmp (
|
int xp_stx_strxcmp (
|
||||||
const xp_stx_char_t* s1, xp_stx_word_t len, const xp_stx_char_t* s2);
|
const xp_char_t* s1, xp_word_t len, const xp_char_t* s2);
|
||||||
|
|
||||||
xp_stx_word_t xp_stx_strhash (const xp_stx_char_t* str);
|
xp_word_t xp_stx_strhash (const xp_char_t* str);
|
||||||
xp_stx_word_t xp_stx_strxhash (const xp_stx_char_t* str, xp_stx_word_t len);
|
xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user