*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-10 16:20:53 +00:00
parent c38f9c0f48
commit 5dd3db8cc5
3 changed files with 41 additions and 26 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: object.c,v 1.10 2005-05-10 15:15:57 bacon Exp $ * $Id: object.c,v 1.11 2005-05-10 16:20:53 bacon Exp $
*/ */
#include <xp/stx/object.h> #include <xp/stx/object.h>
@ -8,7 +8,7 @@
#include <xp/bas/assert.h> #include <xp/bas/assert.h>
#include <xp/bas/stdarg.h> #include <xp/bas/stdarg.h>
xp_stx_word_t xp_stx_strlen (const xp_stx_char_t* str) static xp_stx_word_t __strlen (const xp_stx_char_t* str)
{ {
const xp_stx_char_t* p = str; const xp_stx_char_t* p = str;
while (*p != XP_STX_CHAR('\0')) p++; while (*p != XP_STX_CHAR('\0')) p++;
@ -57,7 +57,7 @@ xp_stx_word_t xp_stx_alloc_string_object (
{ {
xp_stx_word_t idx, n; xp_stx_word_t idx, n;
n = xp_stx_strlen(str); n = __strlen(str);
idx = xp_stx_memory_alloc (&stx->memory, idx = xp_stx_memory_alloc (&stx->memory,
(n + 1) * xp_sizeof(xp_stx_char_t) + xp_sizeof(xp_stx_object_t)); (n + 1) * xp_sizeof(xp_stx_char_t) + xp_sizeof(xp_stx_object_t));
if (idx >= stx->memory.capacity) return idx; /* failed */ if (idx >= stx->memory.capacity) return idx; /* failed */
@ -79,7 +79,7 @@ xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...)
xp_va_start (ap, stx); xp_va_start (ap, stx);
while ((p = xp_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) { while ((p = xp_va_arg(ap, const xp_stx_char_t*)) != XP_NULL) {
n += xp_stx_strlen(p); n += __strlen(p);
} }
xp_va_end (ap); xp_va_end (ap);
@ -116,16 +116,25 @@ 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, const xp_stx_char_t* name, xp_stx_word_t class) xp_stx_t* stx, const xp_stx_char_t* name)
{ {
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) = class; XP_STX_CLASS(stx,x) = stx->class_symbol;
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 xp_stx_new_symbol_postfix (
xp_stx_t* stx, const xp_stx_char_t* name, const xp_char_t* postfix)
{
xp_stx_word_t x;
x = xp_stx_allocn_string_object (stx, name, postfix, XP_NULL);
XP_STX_CLASS(stx,x) = stx->class_symbol;
return x;
}
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, class;
xp_stx_word_t meta_name, class_name; xp_stx_word_t meta_name, class_name;
@ -138,9 +147,10 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, xp_stx_char_t* name)
class = xp_stx_alloc_object (stx, XP_STX_CLASS_DIMENSION); class = xp_stx_alloc_object (stx, XP_STX_CLASS_DIMENSION);
XP_STX_CLASS(stx,class) = meta; XP_STX_CLASS(stx,class) = meta;
meta_name = xp_stx_new_string_object (stx, name, stx->class_symbol); meta_name = xp_stx_new_symbol (stx, name);
XP_STX_AT(stx,meta,XP_STX_CLASS_NAME) = meta_name; XP_STX_AT(stx,meta,XP_STX_CLASS_NAME) = meta_name;
class_name = xp_stx_new_string_object (stx, name, stx->class_symbol); class_name = xp_stx_new_symbol_postfix (
stx, name, XP_STX_TEXT("Meta"));
XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name; XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
xp_stx_hash_insert (stx, stx->symbol_table, xp_stx_hash_insert (stx, stx->symbol_table,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: object.h,v 1.8 2005-05-10 15:15:57 bacon Exp $ * $Id: object.h,v 1.9 2005-05-10 16:20:53 bacon Exp $
*/ */
#ifndef _XP_STX_OBJECT_H_ #ifndef _XP_STX_OBJECT_H_
@ -34,9 +34,12 @@ xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...);
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_word_t xp_stx_new_symbol (
xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t class); xp_stx_t* stx, const xp_stx_char_t* name);
xp_stx_word_t xp_stx_new_symbol_postfix (
xp_stx_t* stx, const xp_stx_char_t* name, const xp_stx_char_t* postfix);
xp_stx_word_t xp_stx_new_class (
xp_stx_t* stx, const xp_stx_char_t* name);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: stx.c,v 1.9 2005-05-10 15:15:57 bacon Exp $ * $Id: stx.c,v 1.10 2005-05-10 16:20:53 bacon Exp $
*/ */
#include <xp/stx/stx.h> #include <xp/stx/stx.h>
@ -49,6 +49,7 @@ int xp_stx_bootstrap (xp_stx_t* stx)
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;
xp_stx_word_t class_Metaclass, class_MetaclassMeta; xp_stx_word_t class_Metaclass, class_MetaclassMeta;
xp_stx_word_t class_UndefinedObject;
/* allocate three keyword objects */ /* allocate three keyword objects */
stx->nil = xp_stx_alloc_object (stx, 0); stx->nil = xp_stx_alloc_object (stx, 0);
@ -100,13 +101,18 @@ int xp_stx_bootstrap (xp_stx_t* stx)
xp_stx_hash_string_object(stx, symbol_MetaclassMeta), xp_stx_hash_string_object(stx, symbol_MetaclassMeta),
symbol_MetaclassMeta, class_MetaclassMeta); symbol_MetaclassMeta, class_MetaclassMeta);
/* ready to use new_symbol & new_class */
stx->symbol_table = symtab;
stx->class_symbol = class_Symbol;
stx->class_metaclass = class_Metaclass;
/* more initialization for nil, true, false */ /* more initialization for nil, true, false */
symbol_nil = xp_stx_new_string_object ( symbol_nil = xp_stx_new_symbol (
stx, XP_STX_TEXT("nil"), class_Symbol); stx, XP_STX_TEXT("nil"));
symbol_true = xp_stx_new_string_object ( symbol_true = xp_stx_new_symbol (
stx, XP_STX_TEXT("true"), class_Symbol); stx, XP_STX_TEXT("true"));
symbol_false = xp_stx_new_string_object ( symbol_false = xp_stx_new_symbol (
stx, XP_STX_TEXT("false"), class_Symbol); stx, XP_STX_TEXT("false"));
xp_stx_hash_insert (stx, symtab, xp_stx_hash_insert (stx, symtab,
xp_stx_hash_string_object(stx, symbol_nil), xp_stx_hash_string_object(stx, symbol_nil),
@ -118,11 +124,7 @@ int xp_stx_bootstrap (xp_stx_t* stx)
xp_stx_hash_string_object(stx, symbol_false), xp_stx_hash_string_object(stx, symbol_false),
symbol_false, stx->false); symbol_false, stx->false);
/* ready to use new_class */ class_UndefinedObject = xp_stx_new_class (stx, XP_STX_TEXT("UndefinedObject"));
stx->symbol_table = symtab;
stx->class_symbol = class_Symbol;
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"));