diff --git a/ase/stx/object.c b/ase/stx/object.c index c3acfdc8..d250ae9e 100644 --- a/ase/stx/object.c +++ b/ase/stx/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.18 2005-05-21 07:27:32 bacon Exp $ + * $Id: object.c,v 1.19 2005-05-21 15:55:49 bacon Exp $ */ #include @@ -45,7 +45,7 @@ xp_stx_word_t xp_stx_alloc_byte_object (xp_stx_t* stx, xp_stx_word_t n) return idx; } -xp_stx_word_t xp_stx_alloc_string_object ( +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; @@ -64,7 +64,7 @@ xp_stx_word_t xp_stx_alloc_string_object ( return idx; } -xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...) +xp_stx_word_t xp_stx_allocn_char_object (xp_stx_t* stx, ...) { xp_stx_word_t idx, n = 0; const xp_stx_char_t* p; @@ -96,7 +96,7 @@ xp_stx_word_t xp_stx_allocn_string_object (xp_stx_t* stx, ...) return 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_hash_char_object (xp_stx_t* stx, xp_stx_word_t idx) { xp_stx_assert (XP_STX_TYPE(stx,idx) == XP_STX_CHAR_INDEXED); return xp_stx_strxhash ( @@ -126,11 +126,11 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name) /* xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx, meta_name), + xp_stx_hash_char_object(stx, meta_name), meta_name, meta); */ xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx, class_name), + xp_stx_hash_char_object(stx, class_name), class_name, class); return class; @@ -142,9 +142,9 @@ int xp_stx_lookup_global ( xp_stx_word_t link; /* TODO: maybe xp_stx_hash_object is required instead of - xp_stx_hash_string_object. */ + xp_stx_hash_char_object. */ link = xp_stx_hash_lookup (stx, stx->smalltalk, - xp_stx_hash_string_object(stx,key), key); + xp_stx_hash_char_object(stx,key), key); if (link == stx->nil) return -1; *value = XP_STX_AT(stx,link,XP_STX_PAIRLINK_VALUE); diff --git a/ase/stx/object.h b/ase/stx/object.h index cd3ce3eb..a87fbca5 100644 --- a/ase/stx/object.h +++ b/ase/stx/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.12 2005-05-18 04:01:51 bacon Exp $ + * $Id: object.h,v 1.13 2005-05-21 15:55:49 bacon Exp $ */ #ifndef _XP_STX_OBJECT_H_ @@ -28,11 +28,11 @@ extern "C" { xp_stx_word_t xp_stx_alloc_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_string_object ( +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_allocn_string_object (xp_stx_t* stx, ...); +xp_stx_word_t xp_stx_allocn_char_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_char_object (xp_stx_t* stx, xp_stx_word_t idx); xp_stx_word_t xp_stx_new_class ( xp_stx_t* stx, const xp_stx_char_t* name); diff --git a/ase/stx/stx.c b/ase/stx/stx.c index 55e017c8..715a8b14 100644 --- a/ase/stx/stx.c +++ b/ase/stx/stx.c @@ -1,5 +1,5 @@ /* - * $Id: stx.c,v 1.22 2005-05-21 07:27:32 bacon Exp $ + * $Id: stx.c,v 1.23 2005-05-21 15:55:49 bacon Exp $ */ #include @@ -67,7 +67,7 @@ int xp_stx_bootstrap (xp_stx_t* stx) symbol_Smalltalk = xp_stx_new_symbol (stx, XP_STX_TEXT("Smalltalk")); xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx,symbol_Smalltalk), + xp_stx_hash_char_object(stx,symbol_Smalltalk), symbol_Smalltalk, stx->smalltalk); /* create #nil, #true, #false */ @@ -192,16 +192,16 @@ static void __create_bootstrapping_objects (xp_stx_t* stx) /* register class names into the system dictionary */ xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx, symbol_Symlink), + xp_stx_hash_char_object(stx, symbol_Symlink), symbol_Symlink, stx->class_symlink); xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx, symbol_Symbol), + xp_stx_hash_char_object(stx, symbol_Symbol), symbol_Symbol, stx->class_symbol); xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx, symbol_Metaclass), + xp_stx_hash_char_object(stx, symbol_Metaclass), symbol_Metaclass, stx->class_metaclass); xp_stx_hash_insert (stx, stx->smalltalk, - xp_stx_hash_string_object(stx, symbol_Pairlink), + xp_stx_hash_char_object(stx, symbol_Pairlink), symbol_Pairlink, stx->class_pairlink); } diff --git a/ase/stx/stx.h b/ase/stx/stx.h index 0594f4b2..de16bcd9 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.16 2005-05-20 04:01:12 bacon Exp $ + * $Id: stx.h,v 1.17 2005-05-21 15:55:49 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -14,10 +14,11 @@ typedef xp_size_t xp_stx_word_t; typedef xp_size_t xp_stx_size_t; typedef xp_size_t xp_stx_index_t; +typedef struct xp_stx_objhdr_t xp_stx_objhdr_t; typedef struct xp_stx_object_t xp_stx_object_t; /* typedef struct xp_stx_byte_object_t xp_stx_byte_object_t; -typedef struct xp_stx_string_object_t xp_stx_string_object_t; +typedef struct xp_stx_char_object_t xp_stx_char_object_t; */ typedef struct xp_stx_memory_t xp_stx_memory_t; typedef struct xp_stx_t xp_stx_t; @@ -30,28 +31,31 @@ typedef struct xp_stx_t xp_stx_t; #define XP_STX_OBJECT_HEADER_SIZE \ (xp_sizeof(xp_stx_object_t) - xp_sizeof(xp_stx_word_t)) -struct xp_stx_object_t +struct xp_stx_objhdr_t { /* access - type: 2; size: rest; * type - word indexed: 00 byte indexed: 01 char indexed: 10 */ xp_stx_word_t access; xp_stx_word_t class; +}; + +struct xp_stx_object_t +{ + xp_stx_objhdr_t header; /*xp_stx_word_t data[1];*/ }; /* struct xp_stx_byte_object_t { - xp_stx_word_t access; - xp_stx_word_t class; + xp_stx_objhdr_t header; xp_stx_byte_t data[1]; }; -struct xp_stx_string_object_t +struct xp_stx_char_object_t { - xp_stx_word_t access; - xp_stx_word_t class; + xp_stx_objhdr_t header; xp_stx_char_t data[1]; }; */ @@ -96,8 +100,8 @@ struct xp_stx_t ((xp_stx_object_t*)((mem)->slots[idx])) #define XP_STX_BYTE_OBJECT(mem,idx) \ ((xp_stx_byte_object_t*)((mem)->slots[idx])) -#define XP_STX_STRING_OBJECT(mem,idx) \ - ((xp_stx_string_object_t*)((mem)->slots[idx])) +#define XP_STX_CHAR_OBJECT(mem,idx) \ + ((xp_stx_char_object_t*)((mem)->slots[idx])) #define XP_STX_OBJECT_DATA(mem,idx) \ ((XP_STX_OBJECT_TYPE(mem,idx) == XP_STX_INDEXED)? \ (XP_STX_OBJECT(mem,idx)).data): \ @@ -107,9 +111,9 @@ struct xp_stx_t */ #define XP_STX_OBJECT(stx,idx) (((stx)->memory).slots[idx]) -#define XP_STX_CLASS(stx,idx) (XP_STX_OBJECT(stx,(idx))->class) -#define XP_STX_ACCESS(stx,idx) (XP_STX_OBJECT(stx,(idx))->access) -#define XP_STX_DATA(stx,idx) ((void*)(XP_STX_OBJECT(stx,idx) + 1)) +#define XP_STX_CLASS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.class) +#define XP_STX_ACCESS(stx,idx) (XP_STX_OBJECT(stx,(idx))->header.access) +#define XP_STX_DATA(stx,idx) ((void*)(XP_STX_OBJECT(stx,idx) + 1)) #define XP_STX_TYPE(stx,idx) (XP_STX_ACCESS(stx,idx) & 0x03) #define XP_STX_SIZE(stx,idx) (XP_STX_ACCESS(stx,idx) >> 0x02) diff --git a/ase/stx/symbol.c b/ase/stx/symbol.c index 03af45d0..e58ca1c2 100644 --- a/ase/stx/symbol.c +++ b/ase/stx/symbol.c @@ -1,23 +1,19 @@ /* - * $Id: symbol.c,v 1.3 2005-05-19 16:41:10 bacon Exp $ + * $Id: symbol.c,v 1.4 2005-05-21 15:55:49 bacon Exp $ */ #include #include #include -#define SYMLINK_SIZE 2 -#define SYMLINK_LINK 0 -#define SYMLINK_SYMBOL 1 - xp_stx_word_t xp_stx_new_symlink (xp_stx_t* stx, xp_stx_word_t sym) { xp_stx_word_t x; - x = xp_stx_alloc_object (stx, SYMLINK_SIZE); + x = xp_stx_alloc_object (stx, XP_STX_SYMLINK_SIZE); XP_STX_CLASS(stx,x) = stx->class_symlink; - /*XP_STX_AT(stx,x,SYMLINK_LINK) = stx->nil;*/ - XP_STX_AT(stx,x,SYMLINK_SYMBOL) = sym; + XP_STX_AT(stx,x,XP_STX_SYMLINK_LINK) = stx->nil; + XP_STX_AT(stx,x,XP_STX_SYMLINK_SYMBOL) = sym; return x; } @@ -31,24 +27,24 @@ xp_stx_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_stx_char_t* name) link = XP_STX_AT(stx,table,hash); if (link == stx->nil) { - x = xp_stx_alloc_string_object (stx, name); + x = xp_stx_alloc_char_object (stx, name); XP_STX_CLASS(stx,x) = stx->class_symbol; XP_STX_AT(stx,table,hash) = xp_stx_new_symlink(stx,x); } else { do { - x = XP_STX_AT(stx,link,SYMLINK_SYMBOL); + x = XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL); xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); if (xp_stx_strxcmp ( &XP_STX_CHARAT(stx,x,0), XP_STX_SIZE(stx,x), name) == 0) return x; - next = XP_STX_AT(stx,link,SYMLINK_LINK); + next = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK); if (next == stx->nil) { - x = xp_stx_alloc_string_object (stx, name); + x = xp_stx_alloc_char_object (stx, name); XP_STX_CLASS(stx,x) = stx->class_symbol; - XP_STX_AT(stx,link,SYMLINK_LINK) = + XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK) = xp_stx_new_symlink(stx,x); break; } @@ -72,24 +68,24 @@ xp_stx_word_t xp_stx_new_symbol_pp ( link = XP_STX_AT(stx,table,hash); if (link == stx->nil) { - x = xp_stx_allocn_string_object (stx, prefix, name, postfix); + x = xp_stx_allocn_char_object (stx, prefix, name, postfix); XP_STX_CLASS(stx,x) = stx->class_symbol; XP_STX_AT(stx,table,hash) = xp_stx_new_symlink(stx,x); } else { do { - x = XP_STX_AT(stx,link,SYMLINK_SYMBOL); + x = XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL); xp_stx_assert (XP_STX_CLASS(stx,x) == stx->class_symbol); if (xp_stx_strxcmp ( &XP_STX_CHARAT(stx,x,0), XP_STX_SIZE(stx,x), name) == 0) return x; - next = XP_STX_AT(stx,link,SYMLINK_LINK); + next = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK); if (next == stx->nil) { - x = xp_stx_allocn_string_object (stx, prefix, name, postfix); + x = xp_stx_allocn_char_object (stx, prefix, name, postfix); XP_STX_CLASS(stx,x) = stx->class_symbol; - XP_STX_AT(stx,link,SYMLINK_LINK) = + XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK) = xp_stx_new_symlink(stx,x); break; } @@ -116,8 +112,8 @@ void xp_stx_traverse_symbol_table ( link = XP_STX_AT(stx,table,size); while (link != stx->nil) { - func (stx,XP_STX_AT(stx,link,SYMLINK_SYMBOL)); - link = XP_STX_AT(stx,link,SYMLINK_LINK); + func (stx,XP_STX_AT(stx,link,XP_STX_SYMLINK_SYMBOL)); + link = XP_STX_AT(stx,link,XP_STX_SYMLINK_LINK); } } } diff --git a/ase/stx/symbol.h b/ase/stx/symbol.h index a492d306..4b9a322d 100644 --- a/ase/stx/symbol.h +++ b/ase/stx/symbol.h @@ -1,5 +1,5 @@ /* - * $Id: symbol.h,v 1.2 2005-05-18 04:01:51 bacon Exp $ + * $Id: symbol.h,v 1.3 2005-05-21 15:55:49 bacon Exp $ */ #ifndef _XP_STX_SYMBOL_H_ @@ -7,6 +7,10 @@ #include +#define XP_STX_SYMLINK_SIZE 2 +#define XP_STX_SYMLINK_LINK 0 +#define XP_STX_SYMLINK_SYMBOL 1 + #ifdef __cplusplus extern "C" { #endif diff --git a/ase/test/stx/stx.c b/ase/test/stx/stx.c index 94bbc845..9b368ba2 100644 --- a/ase/test/stx/stx.c +++ b/ase/test/stx/stx.c @@ -5,6 +5,7 @@ #define xp_printf printf #else #include + #include #endif #include @@ -28,10 +29,12 @@ int xp_main (int argc, xp_char_t* argv[]) xp_stx_t stx; xp_stx_word_t i; +#ifndef _DOS if (xp_setlocale () == -1) { printf ("cannot set locale\n"); return -1; } +#endif if (argc != 2) { /* TODO: argument processing */ xp_printf (XP_TEXT("Usage: %s [-f imageFile] MainClass\n"), argv[0]);