*** empty log message ***

This commit is contained in:
hyung-hwan 2005-06-30 12:07:02 +00:00
parent 4564d39052
commit baaacef33a
9 changed files with 120 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: bootstrp.c,v 1.13 2005-06-29 16:01:32 bacon Exp $
* $Id: bootstrp.c,v 1.14 2005-06-30 12:07:02 bacon Exp $
*/
#include <xp/stx/bootstrp.h>
@ -173,6 +173,38 @@ static class_info_t class_info[] =
XP_NULL,
1
},
{
XP_TEXT("String"),
XP_TEXT("IndexedCollection"),
XP_NULL,
XP_NULL,
XP_NULL,
1
},
{
XP_TEXT("Symbol"),
XP_TEXT("String"),
XP_NULL,
XP_NULL,
XP_NULL,
1
},
{
XP_TEXT("Link"),
XP_TEXT("Object"),
XP_TEXT("link"),
XP_NULL,
XP_NULL,
0
},
{
XP_TEXT("Symlink"),
XP_TEXT("Link"),
XP_TEXT("symbol"),
XP_NULL,
XP_NULL,
0
},
{
XP_NULL,
XP_NULL,
@ -194,6 +226,17 @@ xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size)
return x;
}
xp_word_t xp_stx_new_string (xp_stx_t* stx, const xp_char_t* str)
{
xp_word_t x;
xp_assert (stx->class_string != stx->nil);
x = xp_stx_alloc_char_object (stx, str);
XP_STX_CLASS(stx,x) = stx->class_string;
return x;
}
int xp_stx_bootstrap (xp_stx_t* stx)
{
xp_word_t symbol_Smalltalk;
@ -206,6 +249,7 @@ int xp_stx_bootstrap (xp_stx_t* stx)
stx->class_object = xp_stx_new_class (stx, XP_TEXT("Object"));
stx->class_class = xp_stx_new_class (stx, XP_TEXT("Class"));
stx->class_array = xp_stx_new_class (stx, XP_TEXT("Array"));
stx->class_string = xp_stx_new_class (stx, XP_TEXT("String"));
__create_builtin_classes (stx);
@ -251,7 +295,6 @@ int xp_stx_bootstrap (xp_stx_t* stx)
XP_STX_CLASS(stx,stx->false) =
xp_stx_lookup_class (stx, XP_TEXT("False"));
__filein_kernel (stx);
return 0;
}
@ -415,15 +458,28 @@ static void __create_builtin_classes (xp_stx_t* stx)
}
/*
if (p->instance_variables != XP_NULL) {
n = __count_names (p->instance_variables);
array = xp_stx_new_array (stx, n);
__set_names (stx, XP_STX_DATA(stx,array), p->instance_variables);
__set_names (stx,
XP_STX_DATA(stx,array), p->instance_variables);
class_obj->variables = array;
}
else n = 0;
*/
if (p->instance_variables != XP_NULL) {
n = __count_names (p->instance_variables);
class_obj->variables =
xp_stx_new_string (stx, p->instance_variables);
}
else {
n = 0;
class_obj->variables = stx->nil;
}
class_obj->spec = XP_STX_TO_SMALLINT(((spec + n) << 1) | p->is_indexable);
class_obj->spec =
XP_STX_TO_SMALLINT(((spec + n) << 1) | p->is_indexable);
if (p->class_variables != XP_NULL) {
n = __count_names (p->class_variables);

View File

@ -1,5 +1,5 @@
/*
* $Id: bootstrp.h,v 1.4 2005-06-08 16:14:52 bacon Exp $
* $Id: bootstrp.h,v 1.5 2005-06-30 12:07:02 bacon Exp $
*/
#ifndef _XP_STX_BOOTSTRP_H_
@ -12,6 +12,7 @@ extern "C" {
#endif
xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size);
xp_word_t xp_stx_new_string (xp_stx_t* stx, const xp_char_t* str);
int xp_stx_bootstrap (xp_stx_t* stx);
#ifdef __cplusplus

View File

@ -1,5 +1,5 @@
/*
* $Id: class.c,v 1.10 2005-06-29 16:01:32 bacon Exp $
* $Id: class.c,v 1.11 2005-06-30 12:07:02 bacon Exp $
*/
#include <xp/stx/class.h>
@ -54,7 +54,8 @@ int xp_stx_get_instance_variable_index (
{
xp_word_t i, size, index_super = 0;
xp_stx_class_t* class_obj;
xp_stx_word_object_t* array;
/*xp_stx_word_object_t* array;*/
xp_stx_char_object_t* string;
const xp_char_t* iname;
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class_index);
@ -75,6 +76,7 @@ int xp_stx_get_instance_variable_index (
*index = index_super;
}
else {
/*
size = XP_STX_SIZE(stx, class_obj->variables);
array = XP_STX_WORD_OBJECT(stx, class_obj->variables);
@ -85,8 +87,18 @@ int xp_stx_get_instance_variable_index (
return 0;
}
}
*index = size + index_super;
*/
if (class_obj->variables != stx->nil) {
string = XP_STX_CHAR_OBJECT(stx, class_obj->variables);
if (xp_stx_strword (string->data, name, index) != XP_NULL) {
*index += index_super;
return 0;
}
*index = size + index_super;
}
else *index = index_super;
}
return -1;

View File

@ -1,5 +1,5 @@
/*
* $Id: hash.c,v 1.20 2005-06-08 16:11:18 bacon Exp $
* $Id: hash.c,v 1.21 2005-06-30 12:07:02 bacon Exp $
*/
#include <xp/stx/hash.h>
@ -69,7 +69,7 @@ xp_word_t xp_stx_hash_lookup_symbol (
while (link != stx->nil) {
obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx,link);
tmp = XP_CHAR_OBJECT(stx,obj->key);
tmp = XP_STX_CHAR_OBJECT(stx,obj->key);
if (tmp->header.class == stx->class_symbol &&
xp_strcmp (tmp->data, name) == 0) return link;
link = obj->link;

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c,v 1.4 2005-06-08 16:11:18 bacon Exp $
* $Id: misc.c,v 1.5 2005-06-30 12:07:02 bacon Exp $
*/
#include <xp/stx/misc.h>
@ -36,3 +36,25 @@ xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len)
return h;
}
xp_char_t* xp_stx_strword (
const xp_char_t* str, const xp_char_t* word,
xp_word_t* word_index, xp_word_t* word_count)
{
xp_char_t* p = (xp_char_t*)str;
xp_char_t* tok;
xp_size_t len;
xp_word_t index = 0;
while (p != XP_NULL) {
p = xp_strtok (p, XP_TEXT(""), &tok, &len);
if (xp_strxcmp (tok, len, word) == 0) {
*word_index = index;
return tok;
}
index++;
}
*word_count = index;
return XP_NULL;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.h,v 1.7 2005-06-08 16:11:18 bacon Exp $
* $Id: misc.h,v 1.8 2005-06-30 12:07:02 bacon Exp $
*/
#ifndef _XP_STX_MISC_H_
@ -41,6 +41,10 @@ extern "C" {
xp_word_t xp_stx_strhash (const xp_char_t* str);
xp_word_t xp_stx_strxhash (const xp_char_t* str, xp_word_t len);
xp_char_t* xp_stx_strword (
const xp_char_t* str, const xp_char_t* word,
xp_word_t* word_index, xp_word_t* word_count);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: object.c,v 1.25 2005-06-08 16:11:18 bacon Exp $
* $Id: object.c,v 1.26 2005-06-30 12:07:02 bacon Exp $
*/
#include <xp/stx/object.h>
@ -81,13 +81,13 @@ xp_word_t xp_stx_alloc_char_objectx (
/*
XP_STX_CLASS(stx,idx) = stx->nil;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_CHAR_INDEXED;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED;
XP_STX_CHARAT(stx,idx,n) = XP_CHAR('\0');
while (n-- > 0) XP_STX_CHARAT(stx,idx,n) = str[n];
*/
obj = XP_CHAR_OBJECT(stx,idx);
obj = XP_STX_CHAR_OBJECT(stx,idx);
obj->header.class = stx->nil;
obj->header.access = (n << 2) | XP_CHAR_INDEXED;
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
obj->data[n] = XP_CHAR('\0');
while (n-- > 0) obj->data[n] = str[n];
@ -115,12 +115,12 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...)
/*
XP_STX_CLASS(stx,idx) = stx->nil;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_CHAR_INDEXED;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED;
XP_STX_CHARAT(stx,idx,n) = XP_CHAR('\0');
*/
obj = XP_CHAR_OBJECT(stx,idx);
obj = XP_STX_CHAR_OBJECT(stx,idx);
obj->header.class = stx->nil;
obj->header.access = (n << 2) | XP_CHAR_INDEXED;
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
obj->data[n] = XP_CHAR('\0');
xp_va_start (ap, stx);
@ -138,7 +138,7 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...)
xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx)
{
xp_assert (XP_STX_TYPE(stx,idx) == XP_CHAR_INDEXED);
xp_assert (XP_STX_TYPE(stx,idx) == XP_STX_CHAR_INDEXED);
return xp_stx_strxhash (
XP_STX_DATA(stx,idx), XP_STX_SIZE(stx,idx));
}

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.h,v 1.27 2005-06-08 16:14:52 bacon Exp $
* $Id: stx.h,v 1.28 2005-06-30 12:07:02 bacon Exp $
*/
#ifndef _XP_STX_STX_H_
@ -76,6 +76,7 @@ struct xp_stx_t
xp_word_t class_object;
xp_word_t class_class;
xp_word_t class_array;
xp_word_t class_string;
xp_bool_t __malloced;
xp_bool_t __wantabort; /* TODO: make it a function pointer */
@ -94,13 +95,13 @@ struct xp_stx_t
#define XP_STX_SIZE(stx,idx) (XP_STX_ACCESS(stx,idx) >> 0x02)
#define XP_STX_WORD_INDEXED (0x00)
#define XP_STX_BYTE_INDEXED (0x01)
#define XP_CHAR_INDEXED (0x02)
#define XP_STX_CHAR_INDEXED (0x02)
#define XP_STX_WORD_OBJECT(stx,idx) \
((xp_stx_word_object_t*)XP_STX_OBJECT(stx,idx))
#define XP_STX_BYTE_OBJECT(stx,idx) \
((xp_stx_byte_object_t*)XP_STX_OBJECT(stx,idx))
#define XP_CHAR_OBJECT(stx,idx) \
#define XP_STX_CHAR_OBJECT(stx,idx) \
((xp_stx_char_object_t*)XP_STX_OBJECT(stx,idx))
#define XP_STX_WORDAT(stx,idx,n) \

View File

@ -137,7 +137,7 @@ void print_subclasses (xp_stx_t* stx, const xp_char_t* name)
int xp_main (int argc, xp_char_t* argv[])
{
xp_stx_t stx;
xp_word_t i;
//xp_word_t i;
#ifndef _DOS
if (xp_setlocale () == -1) {