added a name field to a complied method class.
wrote more code for implementing exception handling
This commit is contained in:
@ -4133,7 +4133,7 @@ printf ("\treturn_receiver\n");
|
||||
|
||||
static int add_compiled_method (stix_t* stix)
|
||||
{
|
||||
stix_oop_t name; /* selector */
|
||||
stix_oop_char_t name; /* selector */
|
||||
stix_oop_method_t mth; /* method */
|
||||
#if defined(STIX_USE_OBJECT_TRAILER)
|
||||
/* nothing extra */
|
||||
@ -4144,9 +4144,9 @@ static int add_compiled_method (stix_t* stix)
|
||||
stix_oow_t i;
|
||||
stix_ooi_t preamble_code, preamble_index;
|
||||
|
||||
name = stix_makesymbol (stix, stix->c->mth.name.ptr, stix->c->mth.name.len);
|
||||
name = (stix_oop_char_t)stix_makesymbol (stix, stix->c->mth.name.ptr, stix->c->mth.name.len);
|
||||
if (!name) return -1;
|
||||
stix_pushtmp (stix, &name); tmp_count++;
|
||||
stix_pushtmp (stix, (stix_oop_t*)&name); tmp_count++;
|
||||
|
||||
/* The variadic data part passed to stix_instantiate() is not GC-safe */
|
||||
#if defined(STIX_USE_OBJECT_TRAILER)
|
||||
@ -4295,6 +4295,7 @@ static int add_compiled_method (stix_t* stix)
|
||||
STIX_ASSERT (STIX_OOI_IN_PREAMBLE_INDEX_RANGE(preamble_index));
|
||||
|
||||
mth->owner = stix->c->cls.self_oop;
|
||||
mth->name = name;
|
||||
mth->preamble = STIX_SMOOI_TO_OOP(STIX_METHOD_MAKE_PREAMBLE(preamble_code, preamble_index));
|
||||
mth->preamble_data[0] = STIX_SMOOI_TO_OOP(0);
|
||||
mth->preamble_data[1] = STIX_SMOOI_TO_OOP(0);
|
||||
@ -4314,7 +4315,7 @@ need to write code to collect string.
|
||||
|
||||
stix_poptmps (stix, tmp_count); tmp_count = 0;
|
||||
|
||||
if (!stix_putatdic(stix, stix->c->cls.mthdic_oop[stix->c->mth.type], name, (stix_oop_t)mth)) goto oops;
|
||||
if (!stix_putatdic(stix, stix->c->cls.mthdic_oop[stix->c->mth.type], (stix_oop_t)name, (stix_oop_t)mth)) goto oops;
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
|
@ -942,6 +942,8 @@ static stix_oop_method_t find_method (stix_t* stix, stix_oop_t receiver, const s
|
||||
|
||||
#if defined(STIX_DEBUG_EXEC_002)
|
||||
printf ("==== FINDING METHOD FOR %p [", receiver);
|
||||
print_object (stix, receiver);
|
||||
printf ("] - [");
|
||||
print_oocs (message);
|
||||
printf ("] in ");
|
||||
#endif
|
||||
@ -949,7 +951,7 @@ printf ("] in ");
|
||||
cls = (stix_oop_class_t)STIX_CLASSOF(stix, receiver);
|
||||
if ((stix_oop_t)cls == stix->_class)
|
||||
{
|
||||
/* receiver is a class object */
|
||||
/* receiver is a class object (an instance of Class) */
|
||||
c = receiver;
|
||||
dic_no = STIX_CLASS_MTHDIC_CLASS;
|
||||
#if defined(STIX_DEBUG_EXEC_002)
|
||||
@ -969,7 +971,6 @@ printf ("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (c != stix->_nil)
|
||||
{
|
||||
if (super)
|
||||
@ -997,6 +998,22 @@ printf ("\n");
|
||||
}
|
||||
|
||||
not_found:
|
||||
if ((stix_oop_t)cls == stix->_class)
|
||||
{
|
||||
/* the object is an instance of Class. find the method
|
||||
* in an instance method dictionary of Class also */
|
||||
mthdic = ((stix_oop_class_t)cls)->mthdic[STIX_CLASS_MTHDIC_INSTANCE];
|
||||
STIX_ASSERT ((stix_oop_t)mthdic != stix->_nil);
|
||||
STIX_ASSERT (STIX_CLASSOF(stix, mthdic) == stix->_method_dictionary);
|
||||
|
||||
ass = (stix_oop_association_t)stix_lookupdic (stix, mthdic, message);
|
||||
if (ass)
|
||||
{
|
||||
STIX_ASSERT (STIX_CLASSOF(stix, ass->value) == stix->_method);
|
||||
return (stix_oop_method_t)ass->value;
|
||||
}
|
||||
}
|
||||
|
||||
stix->errnum = STIX_ENOENT;
|
||||
return STIX_NULL;
|
||||
}
|
||||
@ -1054,7 +1071,7 @@ TODO: overcome this problem
|
||||
ctx->ip = STIX_SMOOI_TO_OOP(0); /* point to the beginning */
|
||||
ctx->sp = STIX_SMOOI_TO_OOP(-1); /* pointer to -1 below the bottom */
|
||||
ctx->origin = ctx; /* point to self */
|
||||
ctx->method_or_nargs = (stix_oop_t)mth; /* fake. help SWITCH_ACTIVE_CONTEXT() not fail*/
|
||||
ctx->method_or_nargs = (stix_oop_t)mth; /* fake. help SWITCH_ACTIVE_CONTEXT() not fail. TODO: create a static fake method and use it... instead of 'mth' */
|
||||
|
||||
/* [NOTE]
|
||||
* the receiver field and the sender field of ctx are nils.
|
||||
|
@ -416,9 +416,9 @@ struct stix_association_t
|
||||
};
|
||||
|
||||
#if defined(STIX_USE_OBJECT_TRAILER)
|
||||
# define STIX_METHOD_NAMED_INSTVARS 7
|
||||
#else
|
||||
# define STIX_METHOD_NAMED_INSTVARS 8
|
||||
#else
|
||||
# define STIX_METHOD_NAMED_INSTVARS 9
|
||||
#endif
|
||||
typedef struct stix_method_t stix_method_t;
|
||||
typedef struct stix_method_t* stix_oop_method_t;
|
||||
@ -428,6 +428,8 @@ struct stix_method_t
|
||||
|
||||
stix_oop_class_t owner; /* Class */
|
||||
|
||||
stix_oop_char_t name; /* Symbol, method name */
|
||||
|
||||
/* primitive number */
|
||||
stix_oop_t preamble; /* SmallInteger */
|
||||
|
||||
|
Reference in New Issue
Block a user