*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-23 15:51:03 +00:00
parent 05951ad1bf
commit efb5f7c4c2
7 changed files with 60 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: bootstrp.c,v 1.2 2005-05-23 14:43:03 bacon Exp $
* $Id: bootstrp.c,v 1.3 2005-05-23 15:51:03 bacon Exp $
*/
#include <xp/stx/bootstrp.h>
@ -12,6 +12,8 @@
static void __create_bootstrapping_objects (xp_stx_t* stx);
static void __create_builtin_classes (xp_stx_t* stx);
static xp_stx_word_t __count_names (const xp_stx_char_t* str);
static void __set_names (
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
struct class_info_t
{
@ -153,9 +155,15 @@ static class_info_t class_info[] =
}
};
int xp_stx_new_array (xp_stx_t* stx, xp_stx_word_t size)
xp_stx_word_t xp_stx_new_array (xp_stx_t* stx, xp_stx_word_t size)
{
return 0;
xp_stx_word_t x;
xp_stx_assert (stx->class_array != stx->nil);
x = xp_stx_alloc_word_object (stx, size);
XP_STX_CLASS(stx,x) = stx->class_array;
return x;
}
int xp_stx_bootstrap (xp_stx_t* stx)
@ -320,7 +328,6 @@ static void __create_builtin_classes (xp_stx_t* stx)
class_info_t* p;
xp_stx_word_t class, array;
xp_stx_class_t* class_obj;
xp_stx_word_object_t* array_obj;
xp_stx_word_t n;
xp_stx_assert (stx->class_array != stx->nil);
@ -341,15 +348,14 @@ 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);
array_obj = XP_STX_DATA(stx,array);
__set_names (array_obj, p->instance_variables);
__set_names (stx, XP_STX_DATA(stx,array), p->instance_variables);
class_obj->variables = array;
}
if (p->class_variables != XP_NULL) {
n = __count_names (p->instance_variables);
n = __count_names (p->class_variables);
array = xp_stx_new_array (stx, n);
__set_names (stx, XP_STX_DATA(stx,array), p->class_variables);
class_obj->classvars = array;
}
}
@ -374,21 +380,23 @@ static xp_stx_word_t __count_names (const xp_stx_char_t* str)
return n;
}
static void __set_names (const xp_stx_char_t* str)
static void __set_names (
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str)
{
xp_stx_word_t n = 0;
const xp_stx_char_t* p = str;
const xp_stx_char_t* name;
do {
while (*p == XP_STX_CHAR(' ') ||
*p == XP_STX_CHAR('\t')) p++;
if (*p == XP_STX_CHAR('\0')) break;
n++;
name = p;
while (*p != XP_STX_CHAR(' ') &&
*p != XP_STX_CHAR('\t') &&
*p != XP_STX_CHAR('\0')) p++;
} while (1);
return n;
array[n++] = xp_stx_new_symbolx (stx, name, p - name);
} while (1);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: bootstrp.h,v 1.1 2005-05-23 12:06:53 bacon Exp $
* $Id: bootstrp.h,v 1.2 2005-05-23 15:51:03 bacon Exp $
*/
#ifndef _XP_STX_BOOTSTRP_H_
@ -11,6 +11,8 @@
extern "C" {
#endif
xp_stx_word_t xp_stx_new_array (xp_stx_t* stx, xp_stx_word_t size);
int xp_stx_bootstrap (xp_stx_t* stx);
#ifdef __cplusplus

View File

@ -1,5 +1,5 @@
/*
* $Id: object.c,v 1.22 2005-05-23 14:43:03 bacon Exp $
* $Id: object.c,v 1.23 2005-05-23 15:51:03 bacon Exp $
*/
#include <xp/stx/object.h>
@ -64,10 +64,15 @@ 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)
{
xp_stx_word_t idx, n;
return xp_stx_alloc_char_objectx (stx, str, xp_stx_strlen(str));
}
xp_stx_word_t xp_stx_alloc_char_objectx (
xp_stx_t* stx, const xp_stx_char_t* str, xp_stx_word_t n)
{
xp_stx_word_t idx;
xp_stx_char_object_t* obj;
n = xp_stx_strlen(str);
idx = xp_stx_memory_alloc (&stx->memory,
(n + 1) * xp_sizeof(xp_stx_char_t) + xp_sizeof(xp_stx_object_t));
if (idx >= stx->memory.capacity) return idx; /* failed */

View File

@ -1,5 +1,5 @@
/*
* $Id: object.h,v 1.16 2005-05-22 15:03:20 bacon Exp $
* $Id: object.h,v 1.17 2005-05-23 15:51:03 bacon Exp $
*/
#ifndef _XP_STX_OBJECT_H_
@ -19,6 +19,8 @@ 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);
xp_stx_word_t xp_stx_alloc_char_objectx (
xp_stx_t* stx, const xp_stx_char_t* str, xp_stx_word_t n);
xp_stx_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...);
xp_stx_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_stx_word_t idx);

View File

@ -1,5 +1,5 @@
/*
* $Id: symbol.c,v 1.6 2005-05-23 14:43:03 bacon Exp $
* $Id: symbol.c,v 1.7 2005-05-23 15:51:03 bacon Exp $
*/
#include <xp/stx/symbol.h>
@ -56,7 +56,8 @@ xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name)
return x;
}
xp_stx_word_t xp_stx_new_symbol_with_len (
xp_stx_word_t xp_stx_new_symbolx (
xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t len)
{
xp_stx_word_t x, hash, table, link, next;
@ -65,7 +66,7 @@ xp_stx_word_t xp_stx_new_symbol_with_len (
link = XP_STX_AT(stx,table,hash);
if (link == stx->nil) {
x = xp_stx_alloc_char_object (stx, name);
x = xp_stx_alloc_char_objectx (stx, name, len);
XP_STX_CLASS(stx,x) = stx->class_symbol;
XP_STX_AT(stx,table,hash) = xp_stx_new_symlink(stx,x);
}
@ -80,7 +81,7 @@ xp_stx_word_t xp_stx_new_symbol_with_len (
next = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK);
if (next == stx->nil) {
x = xp_stx_alloc_char_object (stx, name);
x = xp_stx_alloc_char_objectx (stx, name, len);
XP_STX_CLASS(stx,x) = stx->class_symbol;
XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK) =
xp_stx_new_symlink(stx,x);

View File

@ -1,5 +1,5 @@
/*
* $Id: symbol.h,v 1.4 2005-05-23 14:43:03 bacon Exp $
* $Id: symbol.h,v 1.5 2005-05-23 15:51:03 bacon Exp $
*/
#ifndef _XP_STX_SYMBOL_H_
@ -25,7 +25,12 @@ extern "C" {
#endif
xp_stx_word_t xp_stx_new_symbol_link (xp_stx_t* stx, xp_stx_word_t sym);
xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name);
xp_stx_word_t xp_stx_new_symbol (
xp_stx_t* stx, const xp_stx_char_t* name);
xp_stx_word_t xp_stx_new_symbolx (
xp_stx_t* stx, const xp_stx_char_t* name, xp_stx_word_t len);
xp_stx_word_t xp_stx_new_symbol_pp (
xp_stx_t* stx, const xp_stx_char_t* name,
const xp_stx_char_t* prefix, const xp_stx_char_t* postfix);

View File

@ -8,7 +8,7 @@
#include <xp/bas/locale.h>
#endif
#include <xp/stx/bootstrap.h>
#include <xp/stx/bootstrp.h>
#include <xp/stx/object.h>
#include <xp/stx/symbol.h>
#include <xp/stx/context.h>
@ -80,8 +80,8 @@ int xp_main (int argc, xp_char_t* argv[])
xp_stx_word_t n;
xp_stx_class_t* obj;
n = xp_stx_lookup_class (&stx, XP_STX_TEXT("SymbolTable"));
xp_printf (XP_TEXT("Class hierarchy for the class SymbolTable\n"));
n = xp_stx_lookup_class (&stx, XP_STX_TEXT("Array"));
xp_printf (XP_TEXT("Class hierarchy for the class Array\n"));
while (n != stx.nil) {
obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(&stx,n);
@ -93,21 +93,25 @@ int xp_main (int argc, xp_char_t* argv[])
}
xp_printf (XP_TEXT("-------------\n"));
#if 0
{
xp_stx_word_t class_name, method_name;
xp_stx_word_t method_name;
xp_stx_word_t main_class;
xp_stx_word_t method, context;
class_name = xp_stx_new_symbol (&stx,argv[1]);
method_name = xp_stx_new_symbol (&stx,XP_STX_TEXT("main"));
if (xp_stx_lookup_global (&stx,class_name,&main_class) == -1) {
main_class = xp_stx_lookup_class (&stx,argv[1]);
if (main_class == stx.nil) {
xp_printf (XP_TEXT("non-existent class: %s\n"), argv[1]);
return -1;
}
/*
method = xp_stx_alloc_byte_object (&stx,100);
XP_STX_CLASS(&stx,method) = stx.class_method;
*/
method = xp_stx_instantiate (&stx, XP_STX_TEXT("Method"));
XP_STX_BYTEAT(&stx,method,0) = PUSH_OBJECT;
XP_STX_BYTEAT(&stx,method,1) = main_class;
@ -115,9 +119,13 @@ int xp_main (int argc, xp_char_t* argv[])
XP_STX_BYTEAT(&stx,method,3) = method_name;
XP_STX_BYTEAT(&stx,method,4) = HALT;
/*
context = xp_stx_new_context (&stx, method, stx.nil, stx.nil);
*/
context = xp_stx_instantiate (&stx, XP_STX_TEXT("Context"));
xp_stx_run_context (&stx, context);
}
#endif
xp_stx_close (&stx);
xp_printf (XP_TEXT("== End of program ==\n"));