*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-10 12:00:43 +00:00
parent e72d32500b
commit a0dab9e557
4 changed files with 97 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: object.c,v 1.7 2005-05-10 08:21:10 bacon Exp $ * $Id: object.c,v 1.8 2005-05-10 12:00:43 bacon Exp $
*/ */
#include <xp/stx/object.h> #include <xp/stx/object.h>
@ -76,16 +76,42 @@ xp_stx_word_t xp_stx_hash_string_object (xp_stx_t* stx, xp_stx_word_t idx)
return h; return h;
} }
/* xp_stx_word_t xp_stx_new_string_object (
xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, xp_stx_char_t* name) xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t class)
{ {
xp_stx_word_t x; xp_stx_word_t x;
x = xp_stx_alloc_string_object (stx, name); x = xp_stx_alloc_string_object (stx, name);
XP_STX_CLASS(&stx,x) = stx->class_string; XP_STX_CLASS(stx,x) = class;
return x; return x;
} }
*/
xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, 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_DIMENSION);
XP_STX_CLASS(stx,meta) = stx->class_metaclass;
XP_STX_AT(stx,meta,XP_STX_CLASS_SIZE) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_DIMENSION);
class = xp_stx_alloc_object (stx, XP_STX_CLASS_DIMENSION);
XP_STX_CLASS(stx,class) = meta;
meta_name = xp_stx_new_string_object (stx, name, stx->class_symbol);
XP_STX_AT(stx,meta,XP_STX_CLASS_NAME) = meta_name;
class_name = xp_stx_new_string_object (stx, name, stx->class_symbol);
XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
xp_stx_hash_insert (stx, stx->symbol_table,
xp_stx_hash_string_object(stx, meta_name),
meta_name, meta);
xp_stx_hash_insert (stx, stx->symbol_table,
xp_stx_hash_string_object(stx, class_name),
meta_name, class);
return class;
}
/* /*
struct class_info_t struct class_info_t
@ -106,19 +132,6 @@ class_info_t class_info[] =
/* /*
xp_stx_word_t xp_stx_instantiate_class (xp_stx_t* stx, xp_stx_char_t* name)
{
xp_stx_word_t x;
x = xp_str_alloc_object (str, classSize);
XP_STX_CLASS(stx,x) = globalValue("Metaclass");
XP_STX_AT(stx,x,sizeInClass) = XP_STX_TO_SMALLINT(classSize);
y = xp_str_alloc_object (str, classSize):
XP_STX_CLASS(stx,y) = x;
return x;
}
xp_stx_word_t xp_stx_instantiate_string (xp_stx_t* stx, xp_stx_char_t* str) xp_stx_word_t xp_stx_instantiate_string (xp_stx_t* stx, xp_stx_char_t* str)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: object.h,v 1.5 2005-05-10 08:21:10 bacon Exp $ * $Id: object.h,v 1.6 2005-05-10 12:00:43 bacon Exp $
*/ */
#ifndef _XP_STX_OBJECT_H_ #ifndef _XP_STX_OBJECT_H_
@ -22,6 +22,10 @@ xp_stx_word_t xp_stx_alloc_string_object (
xp_stx_word_t xp_stx_hash_string_object (xp_stx_t* stx, xp_stx_word_t idx); xp_stx_word_t xp_stx_hash_string_object (xp_stx_t* stx, xp_stx_word_t idx);
xp_stx_word_t xp_stx_new_string_object (
xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t class);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,10 +1,11 @@
/* /*
* $Id: stx.c,v 1.7 2005-05-10 08:21:10 bacon Exp $ * $Id: stx.c,v 1.8 2005-05-10 12:00:43 bacon Exp $
*/ */
#include <xp/stx/stx.h> #include <xp/stx/stx.h>
#include <xp/stx/memory.h> #include <xp/stx/memory.h>
#include <xp/stx/object.h> #include <xp/stx/object.h>
#include <xp/stx/hash.h>
#include <xp/bas/memory.h> #include <xp/bas/memory.h>
#include <xp/bas/assert.h> #include <xp/bas/assert.h>
@ -26,8 +27,9 @@ xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity)
stx->true = XP_STX_TRUE; stx->true = XP_STX_TRUE;
stx->false = XP_STX_FALSE; stx->false = XP_STX_FALSE;
stx->link_class = XP_STX_NIL;
stx->symbol_table = XP_STX_NIL; stx->symbol_table = XP_STX_NIL;
stx->class_metaclass = XP_STX_NIL;
stx->class_link = XP_STX_NIL;
return stx; return stx;
} }
@ -41,6 +43,7 @@ void xp_stx_close (xp_stx_t* stx)
int xp_stx_bootstrap (xp_stx_t* stx) int xp_stx_bootstrap (xp_stx_t* stx)
{ {
xp_stx_word_t symtab; xp_stx_word_t symtab;
xp_stx_word_t symbol_nil, symbol_true, symbol_false;
xp_stx_word_t symbol_Symbol, symbol_SymbolMeta; xp_stx_word_t symbol_Symbol, symbol_SymbolMeta;
xp_stx_word_t symbol_Metaclass, symbol_MetaclassMeta; xp_stx_word_t symbol_Metaclass, symbol_MetaclassMeta;
xp_stx_word_t class_Symbol, class_SymbolMeta; xp_stx_word_t class_Symbol, class_SymbolMeta;
@ -68,13 +71,11 @@ int xp_stx_bootstrap (xp_stx_t* stx)
symbol_MetaclassMeta = symbol_MetaclassMeta =
xp_stx_alloc_string_object(stx, XP_STX_TEXT("MetaclassMeta")); xp_stx_alloc_string_object(stx, XP_STX_TEXT("MetaclassMeta"));
// TODO: class size: maybe other than 5? class_Metaclass = xp_stx_alloc_object(stx, XP_STX_CLASS_SIZE);
class_Metaclass = xp_stx_alloc_object(stx, 5); class_MetaclassMeta = xp_stx_alloc_object(stx, XP_STX_CLASS_SIZE);
class_MetaclassMeta = xp_stx_alloc_object(stx, 5); class_Symbol = xp_stx_alloc_object(stx, XP_STX_CLASS_SIZE);
class_Symbol = xp_stx_alloc_object(stx, 5); class_SymbolMeta = xp_stx_alloc_object(stx, XP_STX_CLASS_SIZE);
class_SymbolMeta = xp_stx_alloc_object(stx, 5);
XP_STX_CLASS(stx,symbol_Symbol) = class_Symbol;
XP_STX_CLASS(stx,symbol_SymbolMeta) = class_Symbol; XP_STX_CLASS(stx,symbol_SymbolMeta) = class_Symbol;
XP_STX_CLASS(stx,symbol_Metaclass) = class_Symbol; XP_STX_CLASS(stx,symbol_Metaclass) = class_Symbol;
XP_STX_CLASS(stx,symbol_MetaclassMeta) = class_Symbol; XP_STX_CLASS(stx,symbol_MetaclassMeta) = class_Symbol;
@ -83,7 +84,44 @@ int xp_stx_bootstrap (xp_stx_t* stx)
XP_STX_CLASS(stx,class_SymbolMeta) = class_Metaclass; XP_STX_CLASS(stx,class_SymbolMeta) = class_Metaclass;
XP_STX_CLASS(stx,class_Metaclass) = class_MetaclassMeta; XP_STX_CLASS(stx,class_Metaclass) = class_MetaclassMeta;
XP_STX_CLASS(stx,class_MetaclassMeta) = class_Metaclass; XP_STX_CLASS(stx,class_MetaclassMeta) = class_Metaclass;
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_Symbol),
symbol_Symbol, class_Symbol);
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_SymbolMeta),
symbol_SymbolMeta, class_SymbolMeta);
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_Metaclass),
symbol_Metaclass, class_Metaclass);
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_MetaclassMeta),
symbol_MetaclassMeta, class_MetaclassMeta);
/* more initialization for nil, true, false */
symbol_nil = xp_stx_new_string_object (
stx, XP_STX_TEXT("nil"), class_Symbol);
symbol_true = xp_stx_new_string_object (
stx, XP_STX_TEXT("true"), class_Symbol);
symbol_false = xp_stx_new_string_object (
stx, XP_STX_TEXT("false"), class_Symbol);
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_nil),
symbol_nil, stx->nil);
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_true),
symbol_true, stx->true);
xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_false),
symbol_false, stx->false);
/* ready to use new_class */
stx->symbol_table = symtab;
stx->class_metaclass = class_Metaclass;
/* /*
class_Symbol = xp_stx_instantiate_class (XP_STX_TEXT("Symbol")); class_Symbol = xp_stx_instantiate_class (XP_STX_TEXT("Symbol"));
XP_STX_CLASS(stx,symbol_Symbol) = class_Symbol; XP_STX_CLASS(stx,symbol_Symbol) = class_Symbol;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: stx.h,v 1.7 2005-05-10 06:08:57 bacon Exp $ * $Id: stx.h,v 1.8 2005-05-10 12:00:43 bacon Exp $
*/ */
#ifndef _XP_STX_STX_H_ #ifndef _XP_STX_STX_H_
@ -69,9 +69,10 @@ struct xp_stx_t
xp_stx_word_t nil; xp_stx_word_t nil;
xp_stx_word_t true; xp_stx_word_t true;
xp_stx_word_t false; xp_stx_word_t false;
xp_stx_word_t link_class;
xp_stx_word_t symbol_table;
xp_stx_word_t symbol_table;
xp_stx_word_t class_metaclass;
xp_stx_word_t class_link;
xp_bool_t __malloced; xp_bool_t __malloced;
}; };
@ -111,6 +112,16 @@ struct xp_stx_t
#define XP_STX_CHARAT(stx,idx,n) \ #define XP_STX_CHARAT(stx,idx,n) \
(((xp_stx_char_t*)(XP_STX_OBJECT(stx,idx) + 1))[n]) (((xp_stx_char_t*)(XP_STX_OBJECT(stx,idx) + 1))[n])
#define XP_STX_CLASS_DIMENSION 8
#define XP_STX_CLASS_NAME 0
#define XP_STX_CLASS_SIZE 1
#define XP_STX_CLASS_METHODS 2
#define XP_STX_CLASS_SUPERCLASS 3
#define XP_STX_CLASS_VARIABLES 4
#define XP_STX_CLASS_CLASSVARS 5
#define XP_STX_CLASS_POOLDICT 6
#define XP_STX_CLASS_CATEGORY 7
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif