*** empty log message ***
This commit is contained in:
parent
6e9643b9a8
commit
4a866f508b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bootstrp.c,v 1.16 2005-07-04 11:32:41 bacon Exp $
|
* $Id: bootstrp.c,v 1.17 2005-07-04 16:23:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/bootstrp.h>
|
#include <xp/stx/bootstrp.h>
|
||||||
@ -32,7 +32,7 @@ struct class_info_t
|
|||||||
const xp_char_t* instance_variables;
|
const xp_char_t* instance_variables;
|
||||||
const xp_char_t* class_variables;
|
const xp_char_t* class_variables;
|
||||||
const xp_char_t* pool_dictionaries;
|
const xp_char_t* pool_dictionaries;
|
||||||
const int is_indexable;
|
const int indexable;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct class_info_t class_info_t;
|
typedef struct class_info_t class_info_t;
|
||||||
@ -45,7 +45,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("UndefinedObject"),
|
XP_TEXT("UndefinedObject"),
|
||||||
@ -53,7 +53,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Behavior"),
|
XP_TEXT("Behavior"),
|
||||||
@ -61,7 +61,7 @@ static class_info_t class_info[] =
|
|||||||
XP_TEXT("spec methods superclass"),
|
XP_TEXT("spec methods superclass"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Class"),
|
XP_TEXT("Class"),
|
||||||
@ -69,7 +69,7 @@ static class_info_t class_info[] =
|
|||||||
XP_TEXT("name variables classVariables poolDictionaries"),
|
XP_TEXT("name variables classVariables poolDictionaries"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Metaclass"),
|
XP_TEXT("Metaclass"),
|
||||||
@ -77,7 +77,7 @@ static class_info_t class_info[] =
|
|||||||
XP_TEXT("instanceClass"),
|
XP_TEXT("instanceClass"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Block"),
|
XP_TEXT("Block"),
|
||||||
@ -85,7 +85,7 @@ static class_info_t class_info[] =
|
|||||||
XP_TEXT("context argCount argLoc bytePointer"),
|
XP_TEXT("context argCount argLoc bytePointer"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Boolean"),
|
XP_TEXT("Boolean"),
|
||||||
@ -93,7 +93,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("True"),
|
XP_TEXT("True"),
|
||||||
@ -101,7 +101,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("False"),
|
XP_TEXT("False"),
|
||||||
@ -109,7 +109,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Context"),
|
XP_TEXT("Context"),
|
||||||
@ -117,7 +117,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Method"),
|
XP_TEXT("Method"),
|
||||||
@ -126,7 +126,7 @@ static class_info_t class_info[] =
|
|||||||
//XP_NULL,
|
//XP_NULL,
|
||||||
XP_TEXT("Win32Errors"), // TODO: REMOVE THIS
|
XP_TEXT("Win32Errors"), // TODO: REMOVE THIS
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Magnitude"),
|
XP_TEXT("Magnitude"),
|
||||||
@ -134,7 +134,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Collection"),
|
XP_TEXT("Collection"),
|
||||||
@ -142,7 +142,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("IndexedCollection"),
|
XP_TEXT("IndexedCollection"),
|
||||||
@ -150,7 +150,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Array"),
|
XP_TEXT("Array"),
|
||||||
@ -158,7 +158,15 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_WORD_INDEXABLE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
XP_TEXT("ByteArray"),
|
||||||
|
XP_TEXT("IndexedCollection"),
|
||||||
|
XP_NULL,
|
||||||
|
XP_NULL,
|
||||||
|
XP_NULL,
|
||||||
|
XP_STX_SPEC_BYTE_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("SymbolTable"),
|
XP_TEXT("SymbolTable"),
|
||||||
@ -166,7 +174,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_WORD_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Dictionary"),
|
XP_TEXT("Dictionary"),
|
||||||
@ -174,7 +182,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_WORD_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("SystemDictionary"),
|
XP_TEXT("SystemDictionary"),
|
||||||
@ -182,7 +190,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_WORD_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("PoolDictionary"),
|
XP_TEXT("PoolDictionary"),
|
||||||
@ -190,7 +198,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_WORD_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("String"),
|
XP_TEXT("String"),
|
||||||
@ -198,7 +206,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_CHAR_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Symbol"),
|
XP_TEXT("Symbol"),
|
||||||
@ -206,7 +214,7 @@ static class_info_t class_info[] =
|
|||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
1
|
XP_STX_SPEC_CHAR_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Link"),
|
XP_TEXT("Link"),
|
||||||
@ -214,7 +222,7 @@ static class_info_t class_info[] =
|
|||||||
XP_TEXT("link"),
|
XP_TEXT("link"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XP_TEXT("Symlink"),
|
XP_TEXT("Symlink"),
|
||||||
@ -222,15 +230,16 @@ static class_info_t class_info[] =
|
|||||||
XP_TEXT("symbol"),
|
XP_TEXT("symbol"),
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
XP_NULL,
|
XP_NULL,
|
||||||
0
|
XP_STX_SPEC_NOT_INDEXABLE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -385,16 +394,16 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
|
|||||||
|
|
||||||
/* (Symlink class) setSpec: XP_STX_CLASS_SIZE */
|
/* (Symlink class) setSpec: XP_STX_CLASS_SIZE */
|
||||||
XP_STX_WORDAT(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);
|
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 2) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
/* (Symbol class) setSpec: CLASS_SIZE */
|
/* (Symbol class) setSpec: CLASS_SIZE */
|
||||||
XP_STX_WORDAT(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);
|
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 2) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
/* (Metaclass class) setSpec: CLASS_SIZE */
|
/* (Metaclass class) setSpec: CLASS_SIZE */
|
||||||
XP_STX_WORDAT(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);
|
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 2) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
/* (Pairlink class) setSpec: CLASS_SIZE */
|
/* (Pairlink class) setSpec: CLASS_SIZE */
|
||||||
XP_STX_WORDAT(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);
|
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 2) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
|
|
||||||
/* specs for class_metaclass, class_pairlink,
|
/* specs for class_metaclass, class_pairlink,
|
||||||
* class_symbol, class_symlink are set later in
|
* class_symbol, class_symlink are set later in
|
||||||
@ -440,7 +449,7 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
|||||||
xp_stx_class_t* class_obj, * superclass_obj;
|
xp_stx_class_t* class_obj, * superclass_obj;
|
||||||
xp_word_t metaclass;
|
xp_word_t metaclass;
|
||||||
xp_stx_metaclass_t* metaclass_obj;
|
xp_stx_metaclass_t* metaclass_obj;
|
||||||
xp_word_t n, spec;
|
xp_word_t n, nfields;
|
||||||
|
|
||||||
xp_assert (stx->class_array != stx->nil);
|
xp_assert (stx->class_array != stx->nil);
|
||||||
|
|
||||||
@ -455,7 +464,7 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
|||||||
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;
|
nfields = 0;
|
||||||
if (p->superclass != XP_NULL) {
|
if (p->superclass != XP_NULL) {
|
||||||
xp_word_t meta;
|
xp_word_t meta;
|
||||||
xp_stx_metaclass_t* meta_obj;
|
xp_stx_metaclass_t* meta_obj;
|
||||||
@ -471,21 +480,24 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
|||||||
while (superclass != stx->nil) {
|
while (superclass != stx->nil) {
|
||||||
superclass_obj = (xp_stx_class_t*)
|
superclass_obj = (xp_stx_class_t*)
|
||||||
XP_STX_WORD_OBJECT(stx,superclass);
|
XP_STX_WORD_OBJECT(stx,superclass);
|
||||||
spec += XP_STX_FROM_SMALLINT(superclass_obj->spec >> 1);
|
nfields += XP_STX_FROM_SMALLINT(superclass_obj->spec) >> 2;
|
||||||
superclass = superclass_obj->superclass;
|
superclass = superclass_obj->superclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->instance_variables != XP_NULL) {
|
if (p->instance_variables != XP_NULL) {
|
||||||
n = __count_names (p->instance_variables);
|
nfields += __count_names (p->instance_variables);
|
||||||
class_obj->variables =
|
class_obj->variables =
|
||||||
xp_stx_new_string (stx, p->instance_variables);
|
xp_stx_new_string (stx, p->instance_variables);
|
||||||
}
|
}
|
||||||
else n = 0;
|
|
||||||
|
xp_assert (nfields <= 0 || (nfields > 0 &&
|
||||||
|
(p->indexable == XP_STX_SPEC_NOT_INDEXABLE ||
|
||||||
|
p->indexable == XP_STX_SPEC_WORD_INDEXABLE)));
|
||||||
|
|
||||||
class_obj->spec =
|
class_obj->spec =
|
||||||
XP_STX_TO_SMALLINT(((spec + n) << 1) | p->is_indexable);
|
XP_STX_TO_SMALLINT((nfields << 2) | p->indexable);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (p = class_info; p->name != XP_NULL; p++) {
|
for (p = class_info; p->name != XP_NULL; p++) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: class.c,v 1.14 2005-07-04 08:37:25 bacon Exp $
|
* $Id: class.c,v 1.15 2005-07-04 16:23:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/class.h>
|
#include <xp/stx/class.h>
|
||||||
@ -18,7 +18,7 @@ xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name)
|
|||||||
/* the spec of the metaclass must be the spec of its
|
/* the spec of the metaclass must be the spec of its
|
||||||
* instance. so the XP_STX_CLASS_SIZE is set */
|
* instance. so the XP_STX_CLASS_SIZE is set */
|
||||||
XP_STX_WORDAT(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);
|
XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 2) | XP_STX_SPEC_NOT_INDEXABLE);
|
||||||
|
|
||||||
/* the spec of the class is set later in __create_builtin_classes */
|
/* the spec of the class is set later in __create_builtin_classes */
|
||||||
class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE);
|
class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: class.h,v 1.8 2005-07-03 16:37:01 bacon Exp $
|
* $Id: class.h,v 1.9 2005-07-04 16:23:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_CLASS_H_
|
#ifndef _XP_STX_CLASS_H_
|
||||||
@ -25,10 +25,15 @@
|
|||||||
#define XP_STX_METACLASS_SUBCLASSES 3
|
#define XP_STX_METACLASS_SUBCLASSES 3
|
||||||
#define XP_STX_METACLASS_INSTANCE_CLASS 4
|
#define XP_STX_METACLASS_INSTANCE_CLASS 4
|
||||||
|
|
||||||
|
#define XP_STX_SPEC_NOT_INDEXABLE 0
|
||||||
|
#define XP_STX_SPEC_WORD_INDEXABLE 1
|
||||||
|
#define XP_STX_SPEC_BYTE_INDEXABLE 2
|
||||||
|
#define XP_STX_SPEC_CHAR_INDEXABLE 3
|
||||||
|
|
||||||
struct xp_stx_class_t
|
struct xp_stx_class_t
|
||||||
{
|
{
|
||||||
xp_stx_objhdr_t header;
|
xp_stx_objhdr_t header;
|
||||||
xp_word_t spec; /* indexable: 1, nfields: the rest */
|
xp_word_t spec; /* indexable: 2, nfields: the rest */
|
||||||
xp_word_t methods;
|
xp_word_t methods;
|
||||||
xp_word_t superclass;
|
xp_word_t superclass;
|
||||||
xp_word_t subclasses;
|
xp_word_t subclasses;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: object.c,v 1.27 2005-07-04 11:32:41 bacon Exp $
|
* $Id: object.c,v 1.28 2005-07-04 16:23:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/stx/object.h>
|
#include <xp/stx/object.h>
|
||||||
#include <xp/stx/memory.h>
|
#include <xp/stx/memory.h>
|
||||||
#include <xp/stx/symbol.h>
|
#include <xp/stx/symbol.h>
|
||||||
|
#include <xp/stx/class.h>
|
||||||
#include <xp/stx/hash.h>
|
#include <xp/stx/hash.h>
|
||||||
#include <xp/stx/misc.h>
|
#include <xp/stx/misc.h>
|
||||||
|
|
||||||
@ -71,7 +72,9 @@ xp_word_t xp_stx_alloc_byte_object (
|
|||||||
xp_word_t xp_stx_alloc_char_object (
|
xp_word_t xp_stx_alloc_char_object (
|
||||||
xp_stx_t* stx, const xp_char_t* str)
|
xp_stx_t* stx, const xp_char_t* str)
|
||||||
{
|
{
|
||||||
return xp_stx_alloc_char_objectx (stx, str, xp_strlen(str));
|
return (str == XP_NULL)?
|
||||||
|
xp_stx_alloc_char_objectx (stx, XP_NULL, 0):
|
||||||
|
xp_stx_alloc_char_objectx (stx, str, xp_strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_word_t xp_stx_alloc_char_objectx (
|
xp_word_t xp_stx_alloc_char_objectx (
|
||||||
@ -96,7 +99,13 @@ xp_word_t xp_stx_alloc_char_objectx (
|
|||||||
obj->header.class = stx->nil;
|
obj->header.class = stx->nil;
|
||||||
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
|
||||||
obj->data[n] = XP_CHAR('\0');
|
obj->data[n] = XP_CHAR('\0');
|
||||||
|
|
||||||
|
if (str == XP_NULL) {
|
||||||
|
while (n-- > 0) obj->data[n] = XP_CHAR('\0');
|
||||||
|
}
|
||||||
|
else {
|
||||||
while (n-- > 0) obj->data[n] = str[n];
|
while (n-- > 0) obj->data[n] = str[n];
|
||||||
|
}
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
@ -150,3 +159,46 @@ xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx)
|
|||||||
XP_STX_DATA(stx,idx), XP_STX_SIZE(stx,idx));
|
XP_STX_DATA(stx,idx), XP_STX_SIZE(stx,idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xp_word_t xp_stx_instantiate (
|
||||||
|
xp_stx_t* stx, xp_word_t class_index, xp_word_t size)
|
||||||
|
{
|
||||||
|
xp_stx_class_t* class_obj;
|
||||||
|
xp_word_t spec, nfields, new;
|
||||||
|
int indexable;
|
||||||
|
|
||||||
|
class_obj = (xp_stx_class_t*)
|
||||||
|
XP_STX_WORD_OBJECT(stx, class_index);
|
||||||
|
|
||||||
|
/* don't instantiate a metaclass whose instance must be
|
||||||
|
created in a different way */
|
||||||
|
/* TODO: maybe delete the following line */
|
||||||
|
xp_assert (class_obj->header.class != stx->class_metaclass);
|
||||||
|
|
||||||
|
spec = XP_STX_FROM_SMALLINT(class_obj->spec);
|
||||||
|
nfields = (spec >> 2);
|
||||||
|
indexable = spec & 0x3;
|
||||||
|
|
||||||
|
if (indexable == XP_STX_SPEC_BYTE_INDEXABLE) {
|
||||||
|
xp_assert (nfields == 0);
|
||||||
|
new = xp_stx_alloc_byte_object (
|
||||||
|
stx, XP_NULL, nfields + size);
|
||||||
|
}
|
||||||
|
else if (indexable == XP_STX_SPEC_CHAR_INDEXABLE) {
|
||||||
|
xp_assert (nfields == 0);
|
||||||
|
new = xp_stx_alloc_char_objectx (
|
||||||
|
stx, XP_NULL, nfields + size);
|
||||||
|
}
|
||||||
|
else if (indexable == XP_STX_SPEC_WORD_INDEXABLE) {
|
||||||
|
new = xp_stx_alloc_word_object (stx, nfields + size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xp_assert (indexable == XP_STX_SPEC_WORD_INDEXABLE);
|
||||||
|
xp_assert (size == 0);
|
||||||
|
new = xp_stx_alloc_word_object (stx, nfields + size);
|
||||||
|
}
|
||||||
|
|
||||||
|
XP_STX_CLASS(stx, new) = class_index;
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stx.h,v 1.28 2005-06-30 12:07:02 bacon Exp $
|
* $Id: stx.h,v 1.29 2005-07-04 16:23:13 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_STX_STX_H_
|
#ifndef _XP_STX_STX_H_
|
||||||
@ -93,10 +93,18 @@ struct xp_stx_t
|
|||||||
|
|
||||||
#define XP_STX_TYPE(stx,idx) (XP_STX_ACCESS(stx,idx) & 0x03)
|
#define XP_STX_TYPE(stx,idx) (XP_STX_ACCESS(stx,idx) & 0x03)
|
||||||
#define XP_STX_SIZE(stx,idx) (XP_STX_ACCESS(stx,idx) >> 0x02)
|
#define XP_STX_SIZE(stx,idx) (XP_STX_ACCESS(stx,idx) >> 0x02)
|
||||||
|
|
||||||
#define XP_STX_WORD_INDEXED (0x00)
|
#define XP_STX_WORD_INDEXED (0x00)
|
||||||
#define XP_STX_BYTE_INDEXED (0x01)
|
#define XP_STX_BYTE_INDEXED (0x01)
|
||||||
#define XP_STX_CHAR_INDEXED (0x02)
|
#define XP_STX_CHAR_INDEXED (0x02)
|
||||||
|
|
||||||
|
#define XP_STX_IS_WORD_INDEXED(stx,idx) \
|
||||||
|
(XP_STX_TYPE(stx,idx) == XP_STX_WORD_INDEXED)
|
||||||
|
#define XP_STX_IS_BYTE_INDEXED(stx,idx) \
|
||||||
|
(XP_STX_TYPE(stx,idx) == XP_STX_BYTE_INDEXED)
|
||||||
|
#define XP_STX_IS_CHAR_INDEXED(stx,idx) \
|
||||||
|
(XP_STX_TYPE(stx,idx) == XP_STX_CHAR_INDEXED)
|
||||||
|
|
||||||
#define XP_STX_WORD_OBJECT(stx,idx) \
|
#define XP_STX_WORD_OBJECT(stx,idx) \
|
||||||
((xp_stx_word_object_t*)XP_STX_OBJECT(stx,idx))
|
((xp_stx_word_object_t*)XP_STX_OBJECT(stx,idx))
|
||||||
#define XP_STX_BYTE_OBJECT(stx,idx) \
|
#define XP_STX_BYTE_OBJECT(stx,idx) \
|
||||||
|
Loading…
Reference in New Issue
Block a user