*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-24 03:28:31 +00:00
parent d1d1f6f797
commit 5bff4cb2d5
3 changed files with 101 additions and 44 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: bootstrp.c,v 1.4 2005-05-23 16:07:39 bacon Exp $ * $Id: bootstrp.c,v 1.5 2005-05-24 03:28:31 bacon Exp $
*/ */
#include <xp/stx/bootstrp.h> #include <xp/stx/bootstrp.h>
@ -22,6 +22,7 @@ struct class_info_t
const xp_stx_char_t* instance_variables; const xp_stx_char_t* instance_variables;
const xp_stx_char_t* class_variables; const xp_stx_char_t* class_variables;
const xp_stx_char_t* pool_dictionaries; const xp_stx_char_t* pool_dictionaries;
const int is_indexable;
}; };
typedef struct class_info_t class_info_t; typedef struct class_info_t class_info_t;
@ -32,126 +33,144 @@ static class_info_t class_info[] =
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("UndefinedObject"), XP_STX_TEXT("UndefinedObject"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Behavior"), XP_STX_TEXT("Behavior"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_STX_TEXT("name instanceSize methods superclass intsanceVariables classVariables poolDictionaries category"), XP_STX_TEXT("name instanceSize methods superclass intsanceVariables classVariables poolDictionaries category"),
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Class"), XP_STX_TEXT("Class"),
XP_STX_TEXT("Behavior"), XP_STX_TEXT("Behavior"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Metaclass"), XP_STX_TEXT("Metaclass"),
XP_STX_TEXT("Behavior"), XP_STX_TEXT("Behavior"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Block"), XP_STX_TEXT("Block"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_STX_TEXT("context argCount argLoc bytePointer"), XP_STX_TEXT("context argCount argLoc bytePointer"),
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Boolean"), XP_STX_TEXT("Boolean"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("True"), XP_STX_TEXT("True"),
XP_STX_TEXT("Boolean"), XP_STX_TEXT("Boolean"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("False"), XP_STX_TEXT("False"),
XP_STX_TEXT("Boolean"), XP_STX_TEXT("Boolean"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Context"), XP_STX_TEXT("Context"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Method"), XP_STX_TEXT("Method"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_STX_TEXT("text message bytecodes literals stackSize temporarySize class"), XP_STX_TEXT("text message bytecodes literals stackSize temporarySize class"),
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Magnitude"), XP_STX_TEXT("Magnitude"),
XP_STX_TEXT("Object"), XP_STX_TEXT("Object"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("Collection"), XP_STX_TEXT("Collection"),
XP_STX_TEXT("Magnitude"), XP_STX_TEXT("Magnitude"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
}, },
{ {
XP_STX_TEXT("IndexedCollection"), XP_STX_TEXT("IndexedCollection"),
XP_STX_TEXT("Collection"), XP_STX_TEXT("Collection"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
1
}, },
{ {
XP_STX_TEXT("Array"), XP_STX_TEXT("Array"),
XP_STX_TEXT("IndexedCollection"), XP_STX_TEXT("IndexedCollection"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
1
}, },
{ {
XP_STX_TEXT("SymbolTable"), XP_STX_TEXT("SymbolTable"),
XP_STX_TEXT("IndexedCollection"), XP_STX_TEXT("IndexedCollection"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
1
}, },
{ {
XP_STX_TEXT("SystemDictionary"), XP_STX_TEXT("SystemDictionary"),
XP_STX_TEXT("IndexedCollection"), XP_STX_TEXT("IndexedCollection"),
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
1
}, },
{ {
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL, XP_NULL,
XP_NULL XP_NULL,
0
} }
}; };
@ -279,16 +298,16 @@ static void __create_bootstrapping_objects (xp_stx_t* stx)
/* (Symlink class) setSpec: CLASS_SIZE */ /* (Symlink class) setSpec: CLASS_SIZE */
XP_STX_AT(stx,class_SymlinkMeta,XP_STX_CLASS_SPEC) = XP_STX_AT(stx,class_SymlinkMeta,XP_STX_CLASS_SPEC) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_SIZE); XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
/* (Symbol class) setSpec: CLASS_SIZE */ /* (Symbol class) setSpec: CLASS_SIZE */
XP_STX_AT(stx,class_SymbolMeta,XP_STX_CLASS_SPEC) = XP_STX_AT(stx,class_SymbolMeta,XP_STX_CLASS_SPEC) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_SIZE); XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
/* (Metaclass class) setSpec: CLASS_SIZE */ /* (Metaclass class) setSpec: CLASS_SIZE */
XP_STX_AT(stx,class_MetaclassMeta,XP_STX_CLASS_SPEC) = XP_STX_AT(stx,class_MetaclassMeta,XP_STX_CLASS_SPEC) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_SIZE); XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
/* (Pairlink class) setSpec: CLASS_SIZE */ /* (Pairlink class) setSpec: CLASS_SIZE */
XP_STX_AT(stx,class_PairlinkMeta,XP_STX_CLASS_SPEC) = XP_STX_AT(stx,class_PairlinkMeta,XP_STX_CLASS_SPEC) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_SIZE); XP_STX_TO_SMALLINT((XP_STX_CLASS_SIZE << 1) | 0x00);
/* #Symlink */ /* #Symlink */
symbol_Symlink = xp_stx_new_symbol (stx, XP_STX_TEXT("Symlink")); symbol_Symlink = xp_stx_new_symbol (stx, XP_STX_TEXT("Symlink"));
@ -328,7 +347,7 @@ static void __create_builtin_classes (xp_stx_t* stx)
class_info_t* p; class_info_t* p;
xp_stx_word_t class, superclass, array; xp_stx_word_t class, superclass, array;
xp_stx_class_t* class_obj, * superclass_obj; xp_stx_class_t* class_obj, * superclass_obj;
xp_stx_word_t n, spec = 0; xp_stx_word_t n, spec;
xp_stx_assert (stx->class_array != stx->nil); xp_stx_assert (stx->class_array != stx->nil);
@ -343,6 +362,10 @@ static void __create_builtin_classes (xp_stx_t* stx)
class_obj->superclass = (p->superclass == XP_NULL)? class_obj->superclass = (p->superclass == XP_NULL)?
stx->nil: xp_stx_lookup_class(stx,p->superclass); stx->nil: xp_stx_lookup_class(stx,p->superclass);
}
for (p = class_info; p->name != XP_NULL; p++) {
spec = 0;
if (p->superclass != XP_NULL) { if (p->superclass != XP_NULL) {
superclass = xp_stx_lookup_class(stx,p->superclass); superclass = xp_stx_lookup_class(stx,p->superclass);
@ -350,7 +373,7 @@ static void __create_builtin_classes (xp_stx_t* stx)
while (superclass != stx->nil) { while (superclass != stx->nil) {
superclass_obj = (xp_stx_class_t*) superclass_obj = (xp_stx_class_t*)
XP_STX_WORD_OBJECT(stx,superclass); XP_STX_WORD_OBJECT(stx,superclass);
spec += XP_STX_FROM_SMALLINT(superclass_obj->spec); spec += XP_STX_FROM_SMALLINT(superclass_obj->spec >> 1);
superclass = superclass_obj->superclass; superclass = superclass_obj->superclass;
} }
} }
@ -360,10 +383,10 @@ static void __create_builtin_classes (xp_stx_t* stx)
array = xp_stx_new_array (stx, n); array = xp_stx_new_array (stx, n);
__set_names (stx, XP_STX_DATA(stx,array), p->instance_variables); __set_names (stx, XP_STX_DATA(stx,array), p->instance_variables);
class_obj->variables = array; class_obj->variables = array;
xp_printf (L"%s, spec = %d\n", p->name, spec + n);
class_obj->spec = XP_STX_TO_SMALLINT(spec + n);
} }
class_obj->spec = XP_STX_TO_SMALLINT(((spec + n) << 1) | p->is_indexable);
if (p->class_variables != XP_NULL) { if (p->class_variables != XP_NULL) {
n = __count_names (p->class_variables); n = __count_names (p->class_variables);
array = xp_stx_new_array (stx, n); array = xp_stx_new_array (stx, n);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: class.c,v 1.4 2005-05-22 16:26:58 bacon Exp $ * $Id: class.c,v 1.5 2005-05-24 03:28:31 bacon Exp $
*/ */
#include <xp/stx/class.h> #include <xp/stx/class.h>
@ -11,29 +11,19 @@
xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name) xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name)
{ {
xp_stx_word_t meta, class; xp_stx_word_t meta, class;
xp_stx_word_t /*meta_name,*/ class_name; xp_stx_word_t class_name;
meta = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE); meta = xp_stx_alloc_word_object (stx, XP_STX_METACLASS_SIZE);
XP_STX_CLASS(stx,meta) = stx->class_metaclass; XP_STX_CLASS(stx,meta) = stx->class_metaclass;
XP_STX_AT(stx,meta,XP_STX_CLASS_SPEC) = XP_STX_AT(stx,meta,XP_STX_METACLASS_SPEC) =
XP_STX_TO_SMALLINT(XP_STX_CLASS_SIZE); XP_STX_TO_SMALLINT((XP_STX_METACLASS_SIZE << 1) | 0x00);
class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE); class = xp_stx_alloc_word_object (stx, XP_STX_CLASS_SIZE);
XP_STX_CLASS(stx,class) = meta; XP_STX_CLASS(stx,class) = meta;
/*
meta_name = xp_stx_new_symbol_pp (
stx, name, XP_STX_TEXT(""), XP_STX_TEXT(" class"));
XP_STX_AT(stx,meta,XP_STX_CLASS_NAME) = meta_name;
*/
class_name = xp_stx_new_symbol (stx, name); class_name = xp_stx_new_symbol (stx, name);
XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name; XP_STX_AT(stx,class,XP_STX_CLASS_NAME) = class_name;
/*
xp_stx_hash_insert (stx, stx->smalltalk,
xp_stx_hash_char_object(stx, meta_name),
meta_name, meta);
*/
xp_stx_hash_insert (stx, stx->smalltalk, xp_stx_hash_insert (stx, stx->smalltalk,
xp_stx_hash_char_object(stx, class_name), xp_stx_hash_char_object(stx, class_name),
class_name, class); class_name, class);
@ -41,6 +31,30 @@ xp_stx_word_t xp_stx_new_class (xp_stx_t* stx, const xp_stx_char_t* name)
return class; return class;
} }
xp_stx_word_t xp_stx_new_metaclass (xp_stx_t* stx, xp_stx_word class)
{
meta = xp_stx_alloc_word_object (stx, XP_STX_METACLASS_SIZE);
meta_obj = meta;
if (class == stx->class_class) {
/*
* "Object class superclass" returns "Class"
* whereas "Class subclasses" just returns an empty array
* because "Object class" is not registered as a subclass of
* "Class".
*/
meta_obj->superclass = stx->class_class;
}
else {
meta_obj->superclass = (class, SUPERCLASS)->class;
}
meta_obj->name = class_obj->name;
meta_obj->instance_class = class;
return meta;
}
xp_stx_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_stx_char_t* name) xp_stx_word_t xp_stx_lookup_class (xp_stx_t* stx, const xp_stx_char_t* name)
{ {
xp_stx_word_t link, meta, value; xp_stx_word_t link, meta, value;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: class.h,v 1.1 2005-05-22 15:03:20 bacon Exp $ * $Id: class.h,v 1.2 2005-05-24 03:28:31 bacon Exp $
*/ */
#ifndef _XP_STX_CLASS_H_ #ifndef _XP_STX_CLASS_H_
@ -18,11 +18,19 @@
#define XP_STX_CLASS_POOLDICT 6 #define XP_STX_CLASS_POOLDICT 6
#define XP_STX_CLASS_CATEGORY 7 #define XP_STX_CLASS_CATEGORY 7
#define XP_STX_METACLASS_SIZE 6
#define XP_STX_METACLASS_NAME 0
#define XP_STX_METACLASS_SPEC 1
#define XP_STX_METACLASS_METHODS 2
#define XP_STX_METACLASS_SUPERCLASS 3
#define XP_STX_METACLASS_VARIABLES 4
#define XP_STX_METACLASS_CLASS 5
struct xp_stx_class_t struct xp_stx_class_t
{ {
xp_stx_objhdr_t header; xp_stx_objhdr_t header;
xp_stx_word_t name; xp_stx_word_t name;
xp_stx_word_t spec; xp_stx_word_t spec; /* indexable: 1, nfields: the rest */
xp_stx_word_t methods; xp_stx_word_t methods;
xp_stx_word_t superclass; xp_stx_word_t superclass;
xp_stx_word_t variables; xp_stx_word_t variables;
@ -31,7 +39,19 @@ struct xp_stx_class_t
xp_stx_word_t category; xp_stx_word_t category;
}; };
struct xp_stx_metaclass_t
{
xp_stx_objhdr_t header;
xp_stx_word_t name;
xp_stx_word_t spec;
xp_stx_word_t methods;
xp_stx_word_t superclass;
xp_stx_word_t variables;
xp_stx_word_t instance_class;
};
typedef struct xp_stx_class_t xp_stx_class_t; typedef struct xp_stx_class_t xp_stx_class_t;
typedef struct xp_stx_metaclass_t xp_stx_metaclass_t;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {