*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-22 04:34:22 +00:00
parent 23c82ec467
commit 438a3aa9c9
7 changed files with 84 additions and 59 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: context.c,v 1.5 2005-05-21 16:11:06 bacon Exp $
* $Id: context.c,v 1.6 2005-05-22 04:34:22 bacon Exp $
*/
#include <xp/stx/context.h>
@ -12,7 +12,7 @@ xp_stx_word_t xp_stx_new_context (xp_stx_t* stx,
xp_stx_word_t context;
xp_stx_context_t* obj;
context = xp_stx_alloc_object(stx,XP_STX_CONTEXT_SIZE);
context = xp_stx_alloc_word_object(stx,XP_STX_CONTEXT_SIZE);
/*
XP_STX_CLASS(stx,context) = stx->class_context;
XP_STX_AT(stx,context,XP_STX_CONTEXT_IP) = XP_STX_TO_SMALLINT(0);

View File

@ -1,5 +1,5 @@
/*
* $Id: hash.c,v 1.15 2005-05-21 16:11:06 bacon Exp $
* $Id: hash.c,v 1.16 2005-05-22 04:34:22 bacon Exp $
*/
#include <xp/stx/hash.h>
@ -11,7 +11,7 @@ xp_stx_word_t xp_stx_new_pairlink (
{
xp_stx_word_t x;
x = xp_stx_alloc_object (stx, XP_STX_PAIRLINK_SIZE);
x = xp_stx_alloc_word_object (stx, XP_STX_PAIRLINK_SIZE);
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;
@ -27,7 +27,7 @@ xp_stx_word_t xp_stx_hash_lookup (
{
xp_stx_word_t link;
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_INDEXED);
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);
@ -46,7 +46,7 @@ void xp_stx_hash_insert (
{
xp_stx_word_t link, next;
xp_stx_assert (XP_STX_TYPE(stx,table) == XP_STX_INDEXED);
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);

View File

@ -1,5 +1,5 @@
/*
* $Id: object.c,v 1.19 2005-05-21 15:55:49 bacon Exp $
* $Id: object.c,v 1.20 2005-05-22 04:34:22 bacon Exp $
*/
#include <xp/stx/object.h>
@ -9,9 +9,10 @@
#include <xp/stx/misc.h>
/* n: number of instance variables */
xp_stx_word_t xp_stx_alloc_object (xp_stx_t* stx, xp_stx_word_t n)
xp_stx_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_stx_word_t n)
{
xp_stx_word_t idx;
xp_stx_word_object_t* obj;
/* bytes to allocidxed =
* number of instance variables * word_size
@ -21,9 +22,16 @@ xp_stx_word_t xp_stx_alloc_object (xp_stx_t* stx, xp_stx_word_t n)
if (idx >= stx->memory.capacity) return idx; /* failed */
xp_stx_assert (stx->nil == XP_STX_NIL);
/*
XP_STX_CLASS(stx,idx) = stx->nil;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_INDEXED;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_WORD_INDEXED;
while (n-- > 0) XP_STX_AT(stx,idx,n) = stx->nil;
*/
obj = XP_STX_WORD_OBJECT(stx,idx);
obj->header.class = stx->nil;
obj->header.access = (n << 2) | XP_STX_WORD_INDEXED;
while (n-- > 0) obj->data[n] = stx->nil;
return idx;
}
@ -32,15 +40,23 @@ xp_stx_word_t xp_stx_alloc_object (xp_stx_t* stx, xp_stx_word_t n)
xp_stx_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_stx_word_t n)
{
xp_stx_word_t idx;
xp_stx_byte_object_t* obj;
idx = xp_stx_memory_alloc (
&stx->memory, n + xp_sizeof(xp_stx_object_t));
if (idx >= stx->memory.capacity) return idx; /* failed */
xp_stx_assert (stx->nil == XP_STX_NIL);
/*
XP_STX_CLASS(stx,idx) = stx->nil;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_BYTE_INDEXED;
while (n-- > 0) XP_STX_BYTEAT(stx,idx,n) = 0;
*/
obj = XP_STX_BYTE_OBJECT(stx,idx);
obj->header.class = stx->nil;
obj->header.access = (n << 2) | XP_STX_BYTE_INDEXED;
while (n-- > 0) obj->data[n] = 0;
return idx;
}
@ -49,6 +65,7 @@ xp_stx_word_t xp_stx_alloc_char_object (
xp_stx_t* stx, const xp_stx_char_t* str)
{
xp_stx_word_t idx, n;
xp_stx_char_object_t* obj;
n = xp_stx_strlen(str);
idx = xp_stx_memory_alloc (&stx->memory,
@ -56,10 +73,18 @@ xp_stx_word_t xp_stx_alloc_char_object (
if (idx >= stx->memory.capacity) return idx; /* failed */
xp_stx_assert (stx->nil == XP_STX_NIL);
/*
XP_STX_CLASS(stx,idx) = stx->nil;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED;
XP_STX_CHARAT(stx,idx,n) = XP_STX_CHAR('\0');
while (n-- > 0) XP_STX_CHARAT(stx,idx,n) = str[n];
*/
obj = XP_STX_CHAR_OBJECT(stx,idx);
obj->header.class = stx->nil;
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
obj->data[n] = XP_STX_CHAR('\0');
while (n-- > 0) obj->data[n] = str[n];
return idx;
}
@ -69,6 +94,7 @@ xp_stx_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...)
xp_stx_word_t idx, n = 0;
const xp_stx_char_t* p;
xp_stx_va_list ap;
xp_stx_char_object_t* obj;
xp_stx_va_start (ap, stx);
while ((p = xp_stx_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) {
@ -81,15 +107,24 @@ xp_stx_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...)
if (idx >= stx->memory.capacity) return idx; /* failed */
xp_stx_assert (stx->nil == XP_STX_NIL);
/*
XP_STX_CLASS(stx,idx) = stx->nil;
XP_STX_ACCESS(stx,idx) = (n << 2) | XP_STX_CHAR_INDEXED;
XP_STX_CHARAT(stx,idx,n) = XP_STX_CHAR('\0');
*/
obj = XP_STX_CHAR_OBJECT(stx,idx);
obj->header.class = stx->nil;
obj->header.access = (n << 2) | XP_STX_CHAR_INDEXED;
obj->data[n] = XP_STX_CHAR('\0');
xp_stx_va_start (ap, stx);
n = 0;
while ((p = xp_stx_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) {
while (*p != XP_STX_CHAR('\0'))
XP_STX_CHARAT(stx,idx,n++) = *p++;
while (*p != XP_STX_CHAR('\0')) {
/*XP_STX_CHARAT(stx,idx,n++) = *p++;*/
obj->data[n++] = *p++;
}
}
xp_stx_va_end (ap);
@ -108,12 +143,12 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name)
xp_stx_word_t meta, class;
xp_stx_word_t /*meta_name,*/ class_name;
meta = xp_stx_alloc_object (stx, XP_STX_CLASS_SIZE);
meta = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE);
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
XP_STX_AT(stx,meta,XP_STX_CLASS_SPEC) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_SIZE);
class = xp_stx_alloc_object (stx, XP_STX_CLASS_SIZE);
class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE);
XP_STX_CLASS(stx,class) = meta;
/*

View File

@ -1,5 +1,5 @@
/*
* $Id: object.h,v 1.14 2005-05-22 04:11:54 bacon Exp $
* $Id: object.h,v 1.15 2005-05-22 04:34:22 bacon Exp $
*/
#ifndef _XP_STX_OBJECT_H_
@ -41,7 +41,7 @@ typedef struct xp_stx_class_t xp_stx_class_t;
extern "C" {
#endif
xp_stx_word_t xp_stx_alloc_object (xp_stx_t* stx, xp_stx_word_t n);
xp_stx_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_stx_word_t n);
xp_stx_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_stx_word_t n);
xp_stx_word_t xp_stx_alloc_char_object (
xp_stx_t* stx, const xp_stx_char_t* str);

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.c,v 1.23 2005-05-21 15:55:49 bacon Exp $
* $Id: stx.c,v 1.24 2005-05-22 04:34:22 bacon Exp $
*/
#include <xp/stx/stx.h>
@ -110,9 +110,9 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
xp_stx_word_t symbol_Pairlink;
/* allocate three keyword objects */
stx->nil = xp_stx_alloc_object (stx, 0);
stx->true = xp_stx_alloc_object (stx, 0);
stx->false = xp_stx_alloc_object (stx, 0);
stx->nil = 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);
xp_stx_assert (stx->nil == XP_STX_NIL);
xp_stx_assert (stx->true == XP_STX_TRUE);
@ -120,26 +120,26 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
/* symbol table & system dictionary */
/* TODO: symbol table and dictionary size */
stx->symbol_table = xp_stx_alloc_object (stx, 1000);
stx->smalltalk = xp_stx_alloc_object (stx, 2000);
stx->symbol_table = xp_stx_alloc_word_object (stx, 1000);
stx->smalltalk = xp_stx_alloc_word_object (stx, 2000);
stx->class_symlink = /* Symlink */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
stx->class_symbol = /* Symbol */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
stx->class_metaclass = /* Metaclass */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
stx->class_pairlink = /* Pairlink */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
class_SymlinkMeta = /* Symlink class */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
class_SymbolMeta = /* Symbol class */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
class_MetaclassMeta = /* Metaclass class */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
class_PairlinkMeta = /* Pairlink class */
xp_stx_alloc_object(stx,XP_STX_CLASS_SIZE);
xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE);
/* (Symlink class) setClass: Metaclass */
XP_STX_CLASS(stx,class_SymlinkMeta) = stx->class_metaclass;

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.h,v 1.17 2005-05-21 15:55:49 bacon Exp $
* $Id: stx.h,v 1.18 2005-05-22 04:34:22 bacon Exp $
*/
#ifndef _XP_STX_STX_H_
@ -16,21 +16,16 @@ typedef xp_size_t xp_stx_index_t;
typedef struct xp_stx_objhdr_t xp_stx_objhdr_t;
typedef struct xp_stx_object_t xp_stx_object_t;
/*
typedef struct xp_stx_word_object_t xp_stx_word_object_t;
typedef struct xp_stx_byte_object_t xp_stx_byte_object_t;
typedef struct xp_stx_char_object_t xp_stx_char_object_t;
*/
typedef struct xp_stx_memory_t xp_stx_memory_t;
typedef struct xp_stx_t xp_stx_t;
#define XP_STX_CHAR(x) XP_CHAR(x)
#define XP_STX_TEXT(x) XP_TEXT(x)
/* common object header structure */
#define XP_STX_OBJECT_HEADER_SIZE \
(xp_sizeof(xp_stx_object_t) - xp_sizeof(xp_stx_word_t))
/* common object structure */
struct xp_stx_objhdr_t
{
/* access - type: 2; size: rest;
@ -43,10 +38,14 @@ struct xp_stx_objhdr_t
struct xp_stx_object_t
{
xp_stx_objhdr_t header;
/*xp_stx_word_t data[1];*/
};
/*
struct xp_stx_word_object_t
{
xp_stx_objhdr_t header;
xp_stx_word_t data[1];
};
struct xp_stx_byte_object_t
{
xp_stx_objhdr_t header;
@ -58,7 +57,6 @@ struct xp_stx_char_object_t
xp_stx_objhdr_t header;
xp_stx_char_t data[1];
};
*/
struct xp_stx_memory_t
{
@ -95,21 +93,6 @@ struct xp_stx_t
#define XP_STX_TRUE 1
#define XP_STX_FALSE 2
/*
#define XP_STX_OBJECT(mem,idx) \
((xp_stx_object_t*)((mem)->slots[idx]))
#define XP_STX_BYTE_OBJECT(mem,idx) \
((xp_stx_byte_object_t*)((mem)->slots[idx]))
#define XP_STX_CHAR_OBJECT(mem,idx) \
((xp_stx_char_object_t*)((mem)->slots[idx]))
#define XP_STX_OBJECT_DATA(mem,idx) \
((XP_STX_OBJECT_TYPE(mem,idx) == XP_STX_INDEXED)? \
(XP_STX_OBJECT(mem,idx)).data): \
((XP_STX_OBJECT_TYPE(mem,idx) == XP_STX_BYTE_INDEXED)? \
(XP_STX_BYTE_OBJECT(mem,idx)).data): \
(XP_STX_STRING_OBJECT(mem,idx)).data))
*/
#define XP_STX_OBJECT(stx,idx) (((stx)->memory).slots[idx])
#define XP_STX_CLASS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.class)
#define XP_STX_ACCESS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.access)
@ -117,10 +100,17 @@ struct xp_stx_t
#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_INDEXED (0x00)
#define XP_STX_WORD_INDEXED (0x00)
#define XP_STX_BYTE_INDEXED (0x01)
#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_STX_CHAR_OBJECT(stx,idx) \
((xp_stx_char_object_t*)XP_STX_OBJECT(stx,idx))
#define XP_STX_AT(stx,idx,n) \
(((xp_stx_word_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
#define XP_STX_BYTEAT(stx,idx,n) \

View File

@ -1,5 +1,5 @@
/*
* $Id: symbol.c,v 1.4 2005-05-21 15:55:49 bacon Exp $
* $Id: symbol.c,v 1.5 2005-05-22 04:34:22 bacon Exp $
*/
#include <xp/stx/symbol.h>
@ -10,7 +10,7 @@ xp_stx_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_stx_word_t sym)
{
xp_stx_word_t x;
x = xp_stx_alloc_object (stx, XP_STX_SYMLINK_SIZE);
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;