*** empty log message ***
This commit is contained in:
parent
cb36ac447e
commit
f3f5b911dd
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: bootstrp.c,v 1.7 2005-05-25 16:44:05 bacon Exp $
|
||||
* $Id: bootstrp.c,v 1.8 2005-05-26 15:39:32 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/bootstrp.h>
|
||||
@ -11,10 +11,15 @@
|
||||
|
||||
static void __create_bootstrapping_objects (xp_stx_t* stx);
|
||||
static void __create_builtin_classes (xp_stx_t* stx);
|
||||
|
||||
static xp_stx_word_t __count_names (const xp_stx_char_t* str);
|
||||
static void __set_names (
|
||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
||||
|
||||
static xp_stx_word_t __count_subclasses (const xp_stx_char_t* str);
|
||||
static void __set_subclasses (
|
||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str);
|
||||
|
||||
struct class_info_t
|
||||
{
|
||||
const xp_stx_char_t* name;
|
||||
@ -416,6 +421,18 @@ static void __create_builtin_classes (xp_stx_t* stx)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* fill subclasses */
|
||||
for (p = class_info; p->name != XP_NULL; p++) {
|
||||
n = __count_subclasses (p->name);
|
||||
array = xp_stx_new_array (stx, n);
|
||||
__set_subclasses (stx, XP_STX_DATA(stx,array), p->name);
|
||||
|
||||
class = xp_stx_lookup_class(stx, p->name);
|
||||
xp_stx_assert (class != stx->nil);
|
||||
class_obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx, class);
|
||||
class_obj->subclasses = array;
|
||||
}
|
||||
}
|
||||
|
||||
static xp_stx_word_t __count_names (const xp_stx_char_t* str)
|
||||
@ -457,3 +474,31 @@ static void __set_names (
|
||||
array[n++] = xp_stx_new_symbolx (stx, name, p - name);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
static xp_stx_word_t __count_subclasses (const xp_stx_char_t* str)
|
||||
{
|
||||
class_info_t* p;
|
||||
xp_stx_word_t n = 0;
|
||||
|
||||
for (p = class_info; p->name != XP_NULL; p++) {
|
||||
if (p->superclass == XP_NULL) continue;
|
||||
if (xp_stx_strcmp (str, p->superclass) == 0) n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void __set_subclasses (
|
||||
xp_stx_t* stx, xp_stx_word_t* array, const xp_stx_char_t* str)
|
||||
{
|
||||
class_info_t* p;
|
||||
xp_stx_word_t n = 0, class;
|
||||
|
||||
for (p = class_info; p->name != XP_NULL; p++) {
|
||||
if (p->superclass == XP_NULL) continue;
|
||||
if (xp_stx_strcmp (str, p->superclass) != 0) continue;
|
||||
class = xp_stx_lookup_class (stx, p->name);
|
||||
xp_stx_assert (class != stx->nil);
|
||||
array[n++] = class;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: class.h,v 1.4 2005-05-25 16:44:05 bacon Exp $
|
||||
* $Id: class.h,v 1.5 2005-05-26 15:39:32 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_CLASS_H_
|
||||
@ -8,20 +8,22 @@
|
||||
#include <xp/stx/stx.h>
|
||||
|
||||
/* definitions for common objects */
|
||||
#define XP_STX_CLASS_SIZE 7
|
||||
#define XP_STX_CLASS_SIZE 8
|
||||
#define XP_STX_CLASS_SPEC 0
|
||||
#define XP_STX_CLASS_METHODS 1
|
||||
#define XP_STX_CLASS_SUPERCLASS 2
|
||||
#define XP_STX_CLASS_NAME 3
|
||||
#define XP_STX_CLASS_VARIABLES 4
|
||||
#define XP_STX_CLASS_CLASS_VARIABLES 5
|
||||
#define XP_STX_CLASS_POOL_DICTIONARIES 6
|
||||
#define XP_STX_CLASS_SUBCLASSES 3
|
||||
#define XP_STX_CLASS_NAME 4
|
||||
#define XP_STX_CLASS_VARIABLES 5
|
||||
#define XP_STX_CLASS_CLASS_VARIABLES 6
|
||||
#define XP_STX_CLASS_POOL_DICTIONARIES 7
|
||||
|
||||
#define XP_STX_METACLASS_SIZE 4
|
||||
#define XP_STX_METACLASS_SIZE 5
|
||||
#define XP_STX_METACLASS_SPEC 0
|
||||
#define XP_STX_METACLASS_METHODS 1
|
||||
#define XP_STX_METACLASS_SUPERCLASS 2
|
||||
#define XP_STX_METACLASS_INSTANCE_CLASS 3
|
||||
#define XP_STX_METACLASS_SUBCLASSES 3
|
||||
#define XP_STX_METACLASS_INSTANCE_CLASS 4
|
||||
|
||||
struct xp_stx_class_t
|
||||
{
|
||||
@ -29,6 +31,7 @@ struct xp_stx_class_t
|
||||
xp_stx_word_t spec; /* indexable: 1, nfields: the rest */
|
||||
xp_stx_word_t methods;
|
||||
xp_stx_word_t superclass;
|
||||
xp_stx_word_t subclasses;
|
||||
xp_stx_word_t name;
|
||||
xp_stx_word_t variables;
|
||||
xp_stx_word_t class_variables;
|
||||
@ -41,6 +44,7 @@ struct xp_stx_metaclass_t
|
||||
xp_stx_word_t spec;
|
||||
xp_stx_word_t methods;
|
||||
xp_stx_word_t superclass;
|
||||
xp_stx_word_t subclasses;
|
||||
xp_stx_word_t instance_class;
|
||||
};
|
||||
|
||||
|
@ -76,6 +76,42 @@ void print_metaclass_hierachy (xp_stx_t* stx, const xp_char_t* name)
|
||||
}
|
||||
}
|
||||
|
||||
void print_class_name (xp_stx_t* stx, xp_stx_word_t class, int tabs)
|
||||
{
|
||||
xp_stx_class_t* xobj;
|
||||
xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class);
|
||||
|
||||
while (tabs-- > 0) xp_printf (XP_TEXT(" "));
|
||||
|
||||
xp_printf (XP_TEXT("%s [%lu]\n"),
|
||||
XP_STX_DATA(stx, xobj->name),
|
||||
(unsigned long)xobj->name);
|
||||
}
|
||||
|
||||
void print_subclass_names (xp_stx_t* stx, xp_stx_word_t class, int tabs)
|
||||
{
|
||||
xp_stx_class_t* obj;
|
||||
|
||||
obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class);
|
||||
print_class_name (stx, class, tabs);
|
||||
|
||||
if (obj->subclasses != stx->nil) {
|
||||
xp_stx_word_t count = XP_STX_SIZE(stx, obj->subclasses);
|
||||
while (count-- > 0) {
|
||||
print_subclass_names (stx,
|
||||
XP_STX_AT(stx,obj->subclasses,count), tabs + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_subclasses (xp_stx_t* stx, const xp_char_t* name)
|
||||
{
|
||||
xp_stx_word_t class;
|
||||
class = xp_stx_lookup_class (stx, name);
|
||||
print_subclass_names (stx, class, 0);
|
||||
}
|
||||
|
||||
|
||||
int xp_main (int argc, xp_char_t* argv[])
|
||||
{
|
||||
xp_stx_t stx;
|
||||
@ -132,6 +168,9 @@ int xp_main (int argc, xp_char_t* argv[])
|
||||
print_metaclass_hierachy (&stx, XP_STX_TEXT("Class"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
|
||||
print_subclasses (&stx, XP_STX_TEXT("Object"));
|
||||
xp_printf (XP_TEXT("-------------\n"));
|
||||
|
||||
#if 0
|
||||
{
|
||||
xp_stx_word_t method_name;
|
||||
|
Loading…
Reference in New Issue
Block a user