From fd769d0f290db1ea3244ebfee958275e9a8d2435 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 5 Jul 2005 06:26:33 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/bootstrp.c | 41 ++++++++++++++++------------------------- ase/stx/class.c | 6 +++--- ase/stx/context.c | 12 ++---------- ase/stx/hash.c | 10 ++-------- ase/stx/object.c | 26 +++++++++++++++++--------- ase/stx/object.h | 7 ++++--- ase/stx/parser.c | 32 +++++++++++++++++--------------- ase/stx/symbol.c | 9 +++++++-- 8 files changed, 68 insertions(+), 75 deletions(-) diff --git a/ase/stx/bootstrp.c b/ase/stx/bootstrp.c index e79fca55..8551ad5a 100644 --- a/ase/stx/bootstrp.c +++ b/ase/stx/bootstrp.c @@ -1,5 +1,5 @@ /* - * $Id: bootstrp.c,v 1.19 2005-07-05 04:29:31 bacon Exp $ + * $Id: bootstrp.c,v 1.20 2005-07-05 06:26:33 bacon Exp $ */ #include @@ -248,7 +248,7 @@ xp_word_t xp_stx_new_array (xp_stx_t* stx, xp_word_t size) xp_word_t x; xp_assert (stx->class_array != stx->nil); - x = xp_stx_alloc_word_object (stx, size); + x = xp_stx_alloc_word_object (stx, XP_NULL, size); XP_STX_CLASS(stx,x) = stx->class_array; return x; @@ -341,9 +341,9 @@ static void __create_bootstrapping_objects (xp_stx_t* stx) xp_word_t symbol_Pairlink; /* allocate three keyword objects */ - 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); + stx->nil = xp_stx_alloc_word_object (stx, XP_NULL, 0); + stx->true = xp_stx_alloc_word_object (stx, XP_NULL, 0); + stx->false = xp_stx_alloc_word_object (stx, XP_NULL, 0); xp_assert (stx->nil == XP_STX_NIL); xp_assert (stx->true == XP_STX_TRUE); @@ -351,30 +351,30 @@ 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_word_object (stx, 1000); - stx->smalltalk = xp_stx_alloc_word_object (stx, 2000); + stx->symbol_table = xp_stx_alloc_word_object (stx, XP_NULL, 1000); + stx->smalltalk = xp_stx_alloc_word_object (stx, XP_NULL, 2000); stx->class_symlink = /* Symlink */ - xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE); stx->class_symbol = /* Symbol */ - xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE); stx->class_metaclass = /* Metaclass */ - xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE); stx->class_pairlink = /* Pairlink */ - xp_stx_alloc_word_object(stx,XP_STX_CLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CLASS_SIZE); /* Metaclass is a class so it has the same structure * as a normal class. "Metaclass class" is an instance of * Metaclass. */ class_SymlinkMeta = /* Symlink class */ - xp_stx_alloc_word_object(stx,XP_STX_METACLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE); class_SymbolMeta = /* Symbol class */ - xp_stx_alloc_word_object(stx,XP_STX_METACLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE); class_MetaclassMeta = /* Metaclass class */ - xp_stx_alloc_word_object(stx,XP_STX_METACLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE); class_PairlinkMeta = /* Pairlink class */ - xp_stx_alloc_word_object(stx,XP_STX_METACLASS_SIZE); + xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_METACLASS_SIZE); /* (Symlink class) setClass: Metaclass */ XP_STX_CLASS(stx,class_SymlinkMeta) = stx->class_metaclass; @@ -510,15 +510,6 @@ static void __create_builtin_classes (xp_stx_t* stx) 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); @@ -650,7 +641,7 @@ static xp_word_t __make_classvar_dict ( const xp_char_t* name; dict = xp_stx_instantiate ( - stx, stx->class_dictionary, __count_names(names)); + stx, stx->class_dictionary, XP_NULL, __count_names(names)); do { while (*p == XP_CHAR(' ') || diff --git a/ase/stx/class.c b/ase/stx/class.c index e7629c6d..f9bc16ed 100644 --- a/ase/stx/class.c +++ b/ase/stx/class.c @@ -1,5 +1,5 @@ /* - * $Id: class.c,v 1.17 2005-07-05 04:29:31 bacon Exp $ + * $Id: class.c,v 1.18 2005-07-05 06:26:33 bacon Exp $ */ #include @@ -13,7 +13,7 @@ xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name) xp_word_t meta, class; xp_word_t class_name; - meta = xp_stx_alloc_word_object (stx, XP_STX_METACLASS_SIZE); + meta = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_METACLASS_SIZE); XP_STX_CLASS(stx,meta) = stx->class_metaclass; /* the spec of the metaclass must be the spec of its * instance. so the XP_STX_CLASS_SIZE is set */ @@ -21,7 +21,7 @@ xp_word_t xp_stx_new_class (xp_stx_t* stx, const xp_char_t* name) XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << XP_STX_SPEC_INDEXABLE_BITS) | XP_STX_SPEC_NOT_INDEXABLE); /* the spec of the class is set later in __create_builtin_classes */ - class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE); + class = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_CLASS_SIZE); XP_STX_CLASS(stx,class) = meta; class_name = xp_stx_new_symbol (stx, name); XP_STX_WORDAT(stx,class,XP_STX_CLASS_NAME) = class_name; diff --git a/ase/stx/context.c b/ase/stx/context.c index 8b78d125..09c21b16 100644 --- a/ase/stx/context.c +++ b/ase/stx/context.c @@ -1,5 +1,5 @@ /* - * $Id: context.c,v 1.8 2005-06-08 16:00:51 bacon Exp $ + * $Id: context.c,v 1.9 2005-07-05 06:26:33 bacon Exp $ */ #include @@ -13,15 +13,7 @@ xp_word_t xp_stx_new_context (xp_stx_t* stx, xp_word_t context; xp_stx_context_t* obj; - 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); - XP_STX_AT(stx,context,XP_STX_CONTEXT_METHOD) = method; - XP_STX_AT(stx,context,XP_STX_CONTEXT_ARGUMENTS) = args; - XP_STX_AT(stx,context,XP_STX_CONTEXT_TEMPORARIES) = temp; - */ - + context = xp_stx_alloc_word_object(stx, XP_NULL, XP_STX_CONTEXT_SIZE); obj = (xp_stx_context_t*)XP_STX_OBJECT(stx,context); obj->header.class = xp_stx_lookup_class(stx,XP_TEXT("Context")); obj->ip = XP_STX_TO_SMALLINT(0); diff --git a/ase/stx/hash.c b/ase/stx/hash.c index 889ce12b..50b5dad5 100644 --- a/ase/stx/hash.c +++ b/ase/stx/hash.c @@ -1,5 +1,5 @@ /* - * $Id: hash.c,v 1.21 2005-06-30 12:07:02 bacon Exp $ + * $Id: hash.c,v 1.22 2005-07-05 06:26:33 bacon Exp $ */ #include @@ -12,14 +12,8 @@ xp_word_t xp_stx_new_pairlink ( xp_word_t x; xp_stx_pairlink_t* obj; - x = xp_stx_alloc_word_object (stx, XP_STX_PAIRLINK_SIZE); + x = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_PAIRLINK_SIZE); obj = (xp_stx_pairlink_t*)XP_STX_WORD_OBJECT(stx, x); - /* - XP_STX_CLASS(stx,x) = stx->class_pairlink; - XP_STX_WORDAT(stx,x,XP_STX_PAIRLINK_LINK) = stx->nil; - XP_STX_WORDAT(stx,x,XP_STX_PAIRLINK_KEY) = key; - XP_STX_WORDAT(stx,x,XP_STX_PAIRLINK_VALUE) = value; - */ obj->header.class = stx->class_pairlink; obj->link = stx->nil; obj->key = key; diff --git a/ase/stx/object.c b/ase/stx/object.c index 6bc6b104..33b82ef2 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.30 2005-07-05 04:29:31 bacon Exp $ + * $Id: object.c,v 1.31 2005-07-05 06:26:33 bacon Exp $ */ #include @@ -10,7 +10,8 @@ #include /* n: number of instance variables */ -xp_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_word_t n) +xp_word_t xp_stx_alloc_word_object ( + xp_stx_t* stx, const xp_word_t* data, xp_word_t n) { xp_word_t idx; xp_stx_word_object_t* obj; @@ -32,7 +33,12 @@ xp_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_word_t n) 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; + if (data == XP_NULL) { + while (n-- > 0) obj->data[n] = stx->nil; + } + else { + while (n-- > 0) obj->data[n] = data[n]; + } return idx; } @@ -62,7 +68,7 @@ xp_word_t xp_stx_alloc_byte_object ( if (data == XP_NULL) { while (n-- > 0) obj->data[n] = 0; } - else { + else { while (n-- > 0) obj->data[n] = data[n]; } @@ -160,7 +166,7 @@ xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx) } xp_word_t xp_stx_instantiate ( - xp_stx_t* stx, xp_word_t class_index, xp_word_t size) + xp_stx_t* stx, xp_word_t class_index, const void* data, xp_word_t size) { xp_stx_class_t* class_obj; xp_word_t spec, nfields, new; @@ -181,20 +187,22 @@ xp_word_t xp_stx_instantiate ( if (indexable == XP_STX_SPEC_BYTE_INDEXABLE) { xp_assert (nfields == 0); new = xp_stx_alloc_byte_object ( - stx, XP_NULL, nfields + size); + stx, data, nfields + size); } else if (indexable == XP_STX_SPEC_CHAR_INDEXABLE) { xp_assert (nfields == 0); new = xp_stx_alloc_char_objectx ( - stx, XP_NULL, nfields + size); + stx, data, nfields + size); } else if (indexable == XP_STX_SPEC_WORD_INDEXABLE) { - new = xp_stx_alloc_word_object (stx, nfields + size); + new = xp_stx_alloc_word_object ( + stx, data, nfields + size); } else { xp_assert (indexable == XP_STX_SPEC_NOT_INDEXABLE); xp_assert (size == 0); - new = xp_stx_alloc_word_object (stx, nfields + size); + new = xp_stx_alloc_word_object ( + stx, data, nfields + size); } XP_STX_CLASS(stx, new) = class_index; diff --git a/ase/stx/object.h b/ase/stx/object.h index 60413e36..931bee10 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.20 2005-07-05 04:29:31 bacon Exp $ + * $Id: object.h,v 1.21 2005-07-05 06:26:33 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -15,7 +15,8 @@ extern "C" { #endif -xp_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_word_t n); +xp_word_t xp_stx_alloc_word_object ( + xp_stx_t* stx, const xp_word_t* data, xp_word_t n); xp_word_t xp_stx_alloc_byte_object ( xp_stx_t* stx, const xp_byte_t* data, xp_word_t n); @@ -29,7 +30,7 @@ xp_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...); xp_word_t xp_stx_hash_char_object (xp_stx_t* stx, xp_word_t idx); xp_word_t xp_stx_instantiate ( - xp_stx_t* stx, xp_word_t class_index, xp_word_t size); + xp_stx_t* stx, xp_word_t class_index, const void* data, xp_word_t size); #ifdef __cplusplus } diff --git a/ase/stx/parser.c b/ase/stx/parser.c index 743df3e1..8c8279ea 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,10 +1,11 @@ /* - * $Id: parser.c,v 1.50 2005-07-04 11:47:25 bacon Exp $ + * $Id: parser.c,v 1.51 2005-07-05 06:26:33 bacon Exp $ */ #include -#include +#include #include +#include static int __parse_method ( xp_stx_parser_t* parser, @@ -282,35 +283,35 @@ static int __parse_method ( return 0; } - static int __finish_method (xp_stx_parser_t* parser) { + xp_stx_t* stx = parser->stx; xp_stx_class_t* class_obj; xp_word_t bytecodes; class_obj = (xp_stx_class_t*) - XP_STX_WORD_OBJECT(parser->stx, parser->method_class); + XP_STX_WORD_OBJECT(stx, parser->method_class); - if (class_obj->methods == parser->stx->nil) { + if (class_obj->methods == stx->nil) { /* TODO: reconfigure method dictionary size */ - class_obj->methods = xp_stx_alloc_word_object (parser->stx, 64); - XP_STX_CLASS(parser->stx, class_obj->methods) = - xp_stx_lookup_class (parser->stx, XP_TEXT("Dictionary")); + class_obj->methods = xp_stx_instantiate ( + stx, stx->class_dictionary, XP_NULL, 64); } - xp_assert (class_obj->methods != parser->stx->nil); + xp_assert (class_obj->methods != stx->nil); /* - bytecodes = xp_stx_alloc_byte_object (parser->stx, - parser->bytecodes, parser->bytecode_size); + bytecodes = xp_stx_instantiate ( + stx, stx->class_bytearray, + parser->bytecodes, parser->bytecode_size); */ /* TODO: text saving must be optional */ /* method_obj->text = - xp_stx_new_string (parser->stx, parser->text); + xp_stx_new_string (stx, parser->text); method_obj->message = - xp_stx_new_symbol (parser->stx, parser->method_name); + xp_stx_new_symbol (stx, parser->method_name); method_obj->bytecodes = bytecodes; //method_obj->literals = method_obj->stack_size = XP_STX_TO_SMALLINT(100); @@ -640,6 +641,7 @@ static int __parse_assignment ( */ xp_word_t i; + xp_stx_t* stx = parser->stx; for (i = 0; i < parser->temporary_count; i++) { if (xp_strcmp (target, parser->temporary[i]) == 0) { @@ -652,7 +654,7 @@ xp_sprintf (buf, xp_countof(buf), XP_TEXT("%d"), i); } if (xp_stx_get_instance_variable_index ( - parser->stx, parser->method_class, target, &i) == 0) { + stx, parser->method_class, target, &i) == 0) { xp_char_t buf[100]; if (__parse_expression(parser) == -1) return -1; xp_sprintf (buf, xp_countof(buf), XP_TEXT("%d"), i); @@ -661,7 +663,7 @@ xp_sprintf (buf, xp_countof(buf), XP_TEXT("%d"), i); } if (xp_stx_lookup_class_variable ( - parser->stx, parser->method_class, target) != parser->stx->nil) { + stx, parser->method_class, target) != stx->nil) { if (__parse_expression(parser) == -1) return -1; EMIT_CODE (parser, XP_TEXT("ASSIGN_CLASSVAR #"), target); return 0; diff --git a/ase/stx/symbol.c b/ase/stx/symbol.c index 27000c85..179b7d1f 100644 --- a/ase/stx/symbol.c +++ b/ase/stx/symbol.c @@ -1,5 +1,5 @@ /* - * $Id: symbol.c,v 1.10 2005-06-08 16:11:18 bacon Exp $ + * $Id: symbol.c,v 1.11 2005-07-05 06:26:33 bacon Exp $ */ #include @@ -9,11 +9,16 @@ xp_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_word_t sym) { xp_word_t x; + xp_word_t data[] = { stx->nil, sym }; - x = xp_stx_alloc_word_object (stx, XP_STX_SYMLINK_SIZE); + /* + x = xp_stx_alloc_word_object (stx, XP_NULL, XP_STX_SYMLINK_SIZE); XP_STX_CLASS(stx,x) = stx->class_symlink; XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_LINK) = stx->nil; XP_STX_WORDAT(stx,x,XP_STX_SYMLINK_SYMBOL) = sym; + */ + x = xp_stx_alloc_word_object (stx, data, XP_STX_SYMLINK_SIZE); + XP_STX_CLASS(stx,x) = stx->class_symlink; return x; }