diff --git a/ase/stx/bootstrp.c b/ase/stx/bootstrp.c index 7d9236b9..37d93135 100644 --- a/ase/stx/bootstrp.c +++ b/ase/stx/bootstrp.c @@ -1,5 +1,5 @@ /* - * $Id: bootstrp.c,v 1.15 2005-07-03 16:37:01 bacon Exp $ + * $Id: bootstrp.c,v 1.16 2005-07-04 11:32:41 bacon Exp $ */ #include @@ -122,7 +122,7 @@ static class_info_t class_info[] = { XP_TEXT("Method"), XP_TEXT("Object"), - XP_TEXT("text message bytecodes literals stackSize temporarySize class"), + XP_TEXT("text message bytecodes literals stackSize temporarySize"), //XP_NULL, XP_TEXT("Win32Errors"), // TODO: REMOVE THIS XP_NULL, @@ -636,6 +636,8 @@ static xp_word_t __make_classvar_dict ( n = __count_names (names); dict = xp_stx_alloc_word_object (stx, n); + XP_STX_CLASS(stx,dict) = /* TODO */ + xp_stx_lookup_class (stx, XP_TEXT("Dictionary")); do { while (*p == XP_CHAR(' ') || diff --git a/ase/stx/makefile.in b/ase/stx/makefile.in index 0d63d2c7..af992bbd 100644 --- a/ase/stx/makefile.in +++ b/ase/stx/makefile.in @@ -1,5 +1,5 @@ SRCS = stx.c memory.c object.c symbol.c class.c \ - hash.c misc.c context.c name.c token.c parser.c bootstrp.c + hash.c misc.c method.c context.c name.c token.c parser.c bootstrp.c OBJS = $(SRCS:.c=.o) OUT = libxpstx.a diff --git a/ase/stx/method.c b/ase/stx/method.c new file mode 100644 index 00000000..c85d34b7 --- /dev/null +++ b/ase/stx/method.c @@ -0,0 +1,9 @@ +/* + * $Id: method.c,v 1.1 2005-07-04 11:32:41 bacon Exp $ + */ + +#include + +int xp_stx_new_method (xp_stx_t* stx, xp_word_t size) +{ +} diff --git a/ase/stx/method.h b/ase/stx/method.h new file mode 100644 index 00000000..f354d343 --- /dev/null +++ b/ase/stx/method.h @@ -0,0 +1,28 @@ +/* + * $Id: method.h,v 1.1 2005-07-04 11:32:41 bacon Exp $ + */ + +#ifndef _XP_STX_METHOD_H_ +#define _XP_STX_METHOD_H_ + +#include + +#define XP_STX_METHOD_SIZE 6 +#define XP_STX_METHOD_TEXT 0 +#define XP_STX_METHOD_MESSAGE 1 +#define XP_STX_METHOD_BYTECODES 2 +#define XP_STX_METHOD_LITERALS 3 +#define XP_STX_METHOD_STACK_SIZE 4 +#define XP_STX_METHOD_TEMPORARY_SIZE 5 + +#ifdef __cplusplus +extern "C" { +#endif + +int xp_stx_new_method (xp_stx_t* stx, xp_word_t size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/object.c b/ase/stx/object.c index bad664fb..432f9c85 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.26 2005-06-30 12:07:02 bacon Exp $ + * $Id: object.c,v 1.27 2005-07-04 11:32:41 bacon Exp $ */ #include @@ -37,7 +37,8 @@ xp_word_t xp_stx_alloc_word_object (xp_stx_t* stx, xp_word_t n) } /* n: number of bytes */ -xp_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, 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) { xp_word_t idx; xp_stx_byte_object_t* obj; @@ -56,7 +57,13 @@ xp_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_word_t n) obj = XP_STX_BYTE_OBJECT(stx,idx); obj->header.class = stx->nil; obj->header.access = (n << 2) | XP_STX_BYTE_INDEXED; - while (n-- > 0) obj->data[n] = 0; + + if (data == XP_NULL) { + while (n-- > 0) obj->data[n] = 0; + } + else { + while (n-- > 0) obj->data[n] = data[n]; + } return idx; } diff --git a/ase/stx/object.h b/ase/stx/object.h index 0cec03bc..a3a19154 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.18 2005-06-08 16:00:51 bacon Exp $ + * $Id: object.h,v 1.19 2005-07-04 11:32:41 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -16,7 +16,10 @@ 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_byte_object (xp_stx_t* stx, 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); + xp_word_t xp_stx_alloc_char_object ( xp_stx_t* stx, const xp_char_t* str); xp_word_t xp_stx_alloc_char_objectx ( diff --git a/ase/stx/parser.c b/ase/stx/parser.c index 6bc9c00a..8d83d451 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.48 2005-07-04 10:02:00 bacon Exp $ + * $Id: parser.c,v 1.49 2005-07-04 11:32:41 bacon Exp $ */ #include @@ -9,6 +9,7 @@ static int __parse_method ( xp_stx_parser_t* parser, xp_word_t method_class, void* input); +static int __finish_method (xp_stx_parser_t* parser); static int __parse_message_pattern (xp_stx_parser_t* parser); static int __parse_unary_pattern (xp_stx_parser_t* parser); @@ -274,6 +275,46 @@ static int __parse_method ( if (__parse_temporaries(parser) == -1) return -1; if (__parse_primitive(parser) == -1) return -1; if (__parse_statements(parser) == -1) return -1; + if (__finish_method (parser) == -1) return -1; + + return 0; +} + + +static int __finish_method (xp_stx_parser_t* parser) +{ + 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); + + if (class_obj->methods == parser->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")); + } + xp_assert (class_obj->methods != parser->stx->nil); + +/* + bytecodes = xp_stx_alloc_byte_object (parser->stx, + parser->bytecodes, parser->bytecode_size); +*/ + + /* TODO: text saving must be optional */ +/* + method_obj->text = + xp_stx_new_string (parser->stx, parser->text); + + method_obj->message = + xp_stx_new_symbol (parser->stx, parser->method_name); + method_obj->bytecodes = bytecodes; + //method_obj->literals = + method_obj->stack_size = XP_STX_TO_SMALLINT(100); + method_obj->temporary_size = + XP_STX_TO_SMALLINT(parser->temporary_count); +*/ return 0; }