*** empty log message ***

This commit is contained in:
hyung-hwan 2005-07-03 16:37:01 +00:00
parent 928f27d416
commit b40ff5db60
7 changed files with 120 additions and 49 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: bootstrp.c,v 1.14 2005-06-30 12:07:02 bacon Exp $
* $Id: bootstrp.c,v 1.15 2005-07-03 16:37:01 bacon Exp $
*/
#include <xp/stx/bootstrp.h>
@ -11,6 +11,8 @@
static void __create_bootstrapping_objects (xp_stx_t* stx);
static void __create_builtin_classes (xp_stx_t* stx);
static xp_word_t __make_classvar_dict (
xp_stx_t* stx, xp_word_t class, const xp_char_t* names);
static void __filein_kernel (xp_stx_t* stx);
static xp_word_t __count_names (const xp_char_t* str);
@ -121,7 +123,8 @@ static class_info_t class_info[] =
XP_TEXT("Method"),
XP_TEXT("Object"),
XP_TEXT("text message bytecodes literals stackSize temporarySize class"),
XP_NULL,
//XP_NULL,
XP_TEXT("Win32Errors"), // TODO: REMOVE THIS
XP_NULL,
0
},
@ -166,13 +169,29 @@ static class_info_t class_info[] =
1
},
{
XP_TEXT("SystemDictionary"),
XP_TEXT("Dictionary"),
XP_TEXT("IndexedCollection"),
XP_NULL,
XP_NULL,
XP_NULL,
1
},
{
XP_TEXT("SystemDictionary"),
XP_TEXT("Dictionary"),
XP_NULL,
XP_NULL,
XP_NULL,
1
},
{
XP_TEXT("PoolDictionary"),
XP_TEXT("Dictionary"),
XP_NULL,
XP_NULL,
XP_NULL,
1
},
{
XP_TEXT("String"),
XP_TEXT("IndexedCollection"),
@ -458,39 +477,42 @@ 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);
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;
}
else n = 0;
class_obj->spec =
XP_STX_TO_SMALLINT(((spec + n) << 1) | p->is_indexable);
}
for (p = class_info; p->name != XP_NULL; p++) {
class = xp_stx_lookup_class(stx, p->name);
xp_assert (class != stx->nil);
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
/*
if (p->class_variables != XP_NULL) {
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->class_variables = array;
}
*/
if (p->class_variables != XP_NULL) {
class_obj->class_variables =
__make_classvar_dict(stx, class, p->class_variables);
}
/*
TODO:
if (p->pool_dictionaries != XP_NULL) {
class_obj->pool_dictionaries =
__make_pool_dictionary(stx, class, p->pool_dictionaries);
}
*/
}
@ -604,6 +626,36 @@ static void __set_metaclass_subclasses (
}
}
static xp_word_t __make_classvar_dict (
xp_stx_t* stx, xp_word_t class, const xp_char_t* names)
{
xp_size_t n;
xp_word_t dict, symbol;
const xp_char_t* p = names;
const xp_char_t* name;
n = __count_names (names);
dict = xp_stx_alloc_word_object (stx, n);
do {
while (*p == XP_CHAR(' ') ||
*p == XP_CHAR('\t')) p++;
if (*p == XP_CHAR('\0')) break;
name = p;
while (*p != XP_CHAR(' ') &&
*p != XP_CHAR('\t') &&
*p != XP_CHAR('\0')) p++;
symbol = xp_stx_new_symbolx (stx, name, p - name);
xp_stx_hash_insert (stx, dict,
xp_stx_hash_char_object(stx, symbol), symbol, stx->nil);
} while (1);
return dict;
}
static void __filein_kernel (xp_stx_t* stx)
{
class_info_t* p;
@ -612,3 +664,4 @@ static void __filein_kernel (xp_stx_t* stx)
/* TODO: */
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: class.c,v 1.12 2005-06-30 15:11:00 bacon Exp $
* $Id: class.c,v 1.13 2005-07-03 16:37:01 bacon Exp $
*/
#include <xp/stx/class.h>
@ -52,11 +52,9 @@ int xp_stx_get_instance_variable_index (
xp_stx_t* stx, xp_word_t class_index,
const xp_char_t* name, xp_word_t* index)
{
xp_word_t i, size, index_super = 0;
xp_word_t index_super = 0;
xp_stx_class_t* class_obj;
/*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);
xp_assert (class_obj != XP_NULL);
@ -75,20 +73,6 @@ 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);
for (i = 0; i < size; i++) {
iname = &XP_STX_CHARAT(stx, array->data[i], 0);
if (xp_strcmp(iname, name) == 0) {
*index = i + index_super;
return 0;
}
}
*index = size + index_super;
*/
if (class_obj->variables == stx->nil) *index = 0;
else {
string = XP_STX_CHAR_OBJECT(stx, class_obj->variables);
@ -103,3 +87,28 @@ int xp_stx_get_instance_variable_index (
return -1;
}
xp_word_t xp_stx_lookup_class_variable (
xp_stx_t* stx, xp_word_t class_index, const xp_char_t* name)
{
xp_stx_class_t* class_obj;
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class_index);
xp_assert (class_obj != XP_NULL);
if (class_obj->superclass != stx->nil) {
xp_word_t tmp;
tmp = xp_stx_lookup_class_variable (
stx, class_obj->superclass, name);
if (tmp != stx->nil) return tmp;
}
/* TODO: can a metaclas have class variables? */
if (class_obj->header.class != stx->class_metaclass &&
class_obj->variables != stx->nil) {
if (xp_stx_hash_lookup_symbol(stx,
class_obj->class_variables, name) != stx->nil) return class_index;
}
return stx->nil;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: class.h,v 1.7 2005-06-29 16:01:32 bacon Exp $
* $Id: class.h,v 1.8 2005-07-03 16:37:01 bacon Exp $
*/
#ifndef _XP_STX_CLASS_H_
@ -62,6 +62,8 @@ int xp_stx_get_instance_variable_index (
xp_stx_t* stx, xp_word_t class_index,
const xp_char_t* name, xp_word_t* index);
xp_word_t xp_stx_lookup_class_variable (
xp_stx_t* stx, xp_word_t class_index, const xp_char_t* name);
#ifdef __cplusplus
}

View File

@ -5,7 +5,7 @@ OBJS = $(SRCS:.c=.obj)
OUT = xpstx.lib
CC = cl
CFLAGS = /nologo /MT /GX /W3 /GR- /D_WIN32_WINNT=0400 -I../..
CFLAGS = /nologo /MT /GX /W3 /GR- /D_WIN32_WINNT=0x0400 -I../..
all: $(OBJS)
link -lib @<<

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.h,v 1.9 2005-06-30 15:11:00 bacon Exp $
* $Id: misc.h,v 1.10 2005-07-03 16:37:01 bacon Exp $
*/
#ifndef _XP_STX_MISC_H_
@ -34,6 +34,12 @@
#include <xp/bas/string.h>
#endif
#if defined(__BORLANDC__) || defined(_MSC_VER)
#define INLINE
#else
#define INLINE inline
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -1,17 +1,11 @@
/*
* $Id: parser.c,v 1.45 2005-06-29 16:01:32 bacon Exp $
* $Id: parser.c,v 1.46 2005-07-03 16:37:01 bacon Exp $
*/
#include <xp/stx/parser.h>
#include <xp/stx/misc.h>
#include <xp/stx/class.h>
#if defined(__BORLANDC__) || defined(_MSC_VER)
#define INLINE
#else
#define INLINE inline
#endif
static int __parse_method (
xp_stx_parser_t* parser,
xp_word_t method_class, void* input);
@ -567,7 +561,12 @@ xp_sprintf (buf, xp_countof(buf), XP_TEXT("%d"), i);
return 0;
}
/* TODO: check it in class variables */
if (xp_stx_lookup_class_variable (
parser->stx, parser->method_class, target, &i) != parser->stx->nil) {
if (__parse_expression(parser) == -1) return -1;
EMIT_CODE (parser, XP_TEXT("ASSIGN_CLASSVAR #"), target);
return 0;
}
/* TODO: global, but i don't like this idea */

View File

@ -8,7 +8,9 @@ perform: method with: x with: y with: z with: a with: b with: c
a := #xxx niceMethod.
"
b := -30 xxx nil this.
instanceClass := 10.
"instanceClass := 10."
literals := 20.
" Win32Errors := 10."
(jjj xxx: 10 xy) zzz: (10 fuck: 20 you: 40) yyy: kkk.
[ spec plus: 20]