fixed a wrong class name specified when adding a compiled method
This commit is contained in:
parent
cf029a0570
commit
87929410db
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
/* initial method dictionary size */
|
/* initial method dictionary size */
|
||||||
#define INSTANCE_METHOD_DICTIONARY_SIZE 256 /* TODO: choose the right size */
|
#define INSTANCE_METHOD_DICTIONARY_SIZE 256 /* TODO: choose the right size */
|
||||||
#define CLASS_METHOD_DICTIONARY_SIZE 256 /* TODO: choose the right size */
|
#define CLASS_METHOD_DICTIONARY_SIZE 128 /* TODO: choose the right size */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
@ -2350,21 +2350,23 @@ static int compile_method_statements (stix_t* stix)
|
|||||||
|
|
||||||
static int add_compiled_method (stix_t* stix)
|
static int add_compiled_method (stix_t* stix)
|
||||||
{
|
{
|
||||||
stix_oop_t sel; /* selector */
|
stix_oop_t name; /* selector */
|
||||||
stix_oop_method_t mth; /* method */
|
stix_oop_method_t mth; /* method */
|
||||||
stix_oop_t code;
|
stix_oop_t code;
|
||||||
stix_size_t tmp_count = 0;
|
stix_size_t tmp_count = 0;
|
||||||
|
|
||||||
sel = stix_makesymbol (stix, stix->c->mth.name.ptr, stix->c->mth.name.len);
|
name = stix_makesymbol (stix, stix->c->mth.name.ptr, stix->c->mth.name.len);
|
||||||
if (!sel) return -1;
|
if (!name) return -1;
|
||||||
stix_pushtmp (stix, &sel); tmp_count++;
|
stix_pushtmp (stix, &name); tmp_count++;
|
||||||
|
|
||||||
mth = (stix_oop_method_t)stix_instantiate (stix, stix->_method_dictionary, stix->c->mth.literals, stix->c->mth.literal_count);
|
/* TODO: check if this stix_instantiate is GC safe...as it passed mth.literals... */
|
||||||
|
mth = (stix_oop_method_t)stix_instantiate (stix, stix->_method, stix->c->mth.literals, stix->c->mth.literal_count);
|
||||||
if (!mth) goto oops;
|
if (!mth) goto oops;
|
||||||
stix_pushtmp (stix, (stix_oop_t*)&mth); tmp_count++;
|
stix_pushtmp (stix, (stix_oop_t*)&mth); tmp_count++;
|
||||||
|
|
||||||
code = stix_instantiate (stix, stix->_byte_array, stix->c->mth.code.ptr, stix->c->mth.code.len);
|
code = stix_instantiate (stix, stix->_byte_array, stix->c->mth.code.ptr, stix->c->mth.code.len);
|
||||||
if (!code) goto oops;
|
if (!code) goto oops;
|
||||||
|
stix_pushtmp (stix, &code); tmp_count++;
|
||||||
|
|
||||||
mth->owner = stix->c->cls.self_oop;
|
mth->owner = stix->c->cls.self_oop;
|
||||||
mth->tmpr_count = STIX_OOP_FROM_SMINT(stix->c->mth.tmpr_count);
|
mth->tmpr_count = STIX_OOP_FROM_SMINT(stix->c->mth.tmpr_count);
|
||||||
@ -2374,7 +2376,8 @@ static int add_compiled_method (stix_t* stix)
|
|||||||
|
|
||||||
stix_poptmps (stix, tmp_count); tmp_count = 0;
|
stix_poptmps (stix, tmp_count); tmp_count = 0;
|
||||||
|
|
||||||
if (!stix_putatdic (stix, stix->c->cls.mthdic_oop[stix->c->mth.type], sel, (stix_oop_t)mth)) goto oops;
|
//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], name, stix->_nil)) goto oops;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
@ -2778,8 +2781,8 @@ printf ("\n");
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* use the method dictionary of an existing class object */
|
/* use the method dictionary of an existing class object */
|
||||||
stix->c->cls.mthdic_oop[0] = stix->c->cls.self_oop->instmths;
|
stix->c->cls.mthdic_oop[MTH_INSTANCE] = stix->c->cls.self_oop->instmths;
|
||||||
stix->c->cls.mthdic_oop[1] = stix->c->cls.self_oop->classmths;
|
stix->c->cls.mthdic_oop[MTH_CLASS] = stix->c->cls.self_oop->classmths;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -67,6 +67,7 @@ static stix_oop_t find_or_insert (stix_t* stix, stix_oop_set_t dic, stix_oop_cha
|
|||||||
stix_oop_association_t ass;
|
stix_oop_association_t ass;
|
||||||
stix_oow_t tmp_count = 0;
|
stix_oow_t tmp_count = 0;
|
||||||
|
|
||||||
|
|
||||||
/* the system dictionary is not a generic dictionary.
|
/* the system dictionary is not a generic dictionary.
|
||||||
* it accepts only a symbol as a key. */
|
* it accepts only a symbol as a key. */
|
||||||
STIX_ASSERT (STIX_CLASSOF(stix,key) == stix->_symbol);
|
STIX_ASSERT (STIX_CLASSOF(stix,key) == stix->_symbol);
|
||||||
@ -200,7 +201,7 @@ stix_oop_t stix_lookupsysdic (stix_t* stix, const stix_ucs_t* name)
|
|||||||
stix_oop_t stix_putatdic (stix_t* stix, stix_oop_set_t dic, stix_oop_t key, stix_oop_t value)
|
stix_oop_t stix_putatdic (stix_t* stix, stix_oop_set_t dic, stix_oop_t key, stix_oop_t value)
|
||||||
{
|
{
|
||||||
STIX_ASSERT (STIX_CLASSOF(stix,key) == stix->_symbol);
|
STIX_ASSERT (STIX_CLASSOF(stix,key) == stix->_symbol);
|
||||||
return find_or_insert (stix, stix->sysdic, (stix_oop_char_t)key, value);
|
return find_or_insert (stix, dic, (stix_oop_char_t)key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
stix_oop_t stix_getatdic (stix_t* stix, stix_oop_set_t dic, stix_oop_t key)
|
stix_oop_t stix_getatdic (stix_t* stix, stix_oop_set_t dic, stix_oop_t key)
|
||||||
@ -220,7 +221,6 @@ stix_oop_t stix_makedic (stix_t* stix, stix_oop_t cls, stix_oow_t size)
|
|||||||
stix_oop_t tmp;
|
stix_oop_t tmp;
|
||||||
|
|
||||||
STIX_ASSERT (STIX_CLASSOF(stix,cls) == stix->_class);
|
STIX_ASSERT (STIX_CLASSOF(stix,cls) == stix->_class);
|
||||||
STIX_ASSERT (cls != stix->_system_dictionary);
|
|
||||||
|
|
||||||
dic = (stix_oop_set_t)stix_instantiate (stix, cls, STIX_NULL, 0);
|
dic = (stix_oop_set_t)stix_instantiate (stix, cls, STIX_NULL, 0);
|
||||||
if (!dic) return STIX_NULL;
|
if (!dic) return STIX_NULL;
|
||||||
@ -234,5 +234,9 @@ stix_oop_t stix_makedic (stix_t* stix, stix_oop_t cls, stix_oow_t size)
|
|||||||
|
|
||||||
dic->tally = STIX_OOP_FROM_SMINT(0);
|
dic->tally = STIX_OOP_FROM_SMINT(0);
|
||||||
dic->bucket = (stix_oop_oop_t)tmp;
|
dic->bucket = (stix_oop_oop_t)tmp;
|
||||||
|
|
||||||
|
STIX_ASSERT (STIX_OBJ_GET_SIZE(dic) == STIX_SET_NAMED_INSTVARS);
|
||||||
|
STIX_ASSERT (STIX_OBJ_GET_SIZE(dic->bucket) == size);
|
||||||
|
|
||||||
return (stix_oop_t)dic;
|
return (stix_oop_t)dic;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,9 @@ printf ("STARTING GC curheap base %p ptr %p newheap base %p ptr %p\n",
|
|||||||
|
|
||||||
for (i = 0; i < stix->tmp_count; i++)
|
for (i = 0; i < stix->tmp_count; i++)
|
||||||
{
|
{
|
||||||
*stix->tmp_stack[i] = stix_moveoop (stix, *stix->tmp_stack[i]);
|
stix_oop_t t;
|
||||||
|
t = stix_moveoop (stix, *stix->tmp_stack[i]);
|
||||||
|
*stix->tmp_stack[i] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cb = stix->cblist; cb; cb = cb->next)
|
for (cb = stix->cblist; cb; cb = cb->next)
|
||||||
|
@ -137,7 +137,8 @@ static int ignite_1 (stix_t* stix)
|
|||||||
stix->_small_integer = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
stix->_small_integer = alloc_kernel_class (stix, 0, STIX_CLASS_SPEC_MAKE(0, 0, STIX_OBJ_TYPE_OOP));
|
||||||
|
|
||||||
if (!stix->_stix || !stix->_nil_object || !stix->_object ||
|
if (!stix->_stix || !stix->_nil_object || !stix->_object ||
|
||||||
!stix->_array || !stix->_string || !stix->_symbol ||
|
!stix->_array || !stix->_byte_array ||
|
||||||
|
!stix->_string || !stix->_symbol ||
|
||||||
!stix->_symbol_set || !stix->_system_dictionary || !stix->_method_dictionary ||
|
!stix->_symbol_set || !stix->_system_dictionary || !stix->_method_dictionary ||
|
||||||
!stix->_association || !stix->_true_class || !stix->_false_class ||
|
!stix->_association || !stix->_true_class || !stix->_false_class ||
|
||||||
!stix->_character || !stix->_small_integer) return -1;
|
!stix->_character || !stix->_small_integer) return -1;
|
||||||
@ -170,15 +171,10 @@ static int ignite_2 (stix_t* stix)
|
|||||||
stix->symtab->bucket = (stix_oop_oop_t)tmp;
|
stix->symtab->bucket = (stix_oop_oop_t)tmp;
|
||||||
|
|
||||||
/* Create the system dictionary */
|
/* Create the system dictionary */
|
||||||
tmp = stix_instantiate (stix, stix->_system_dictionary, STIX_NULL, 0);
|
tmp = stix_makedic (stix, stix->_system_dictionary, stix->option.dfl_sysdic_size);
|
||||||
if (!tmp) return -1;
|
if (!tmp) return -1;
|
||||||
stix->sysdic = (stix_oop_set_t)tmp;
|
stix->sysdic = (stix_oop_set_t)tmp;
|
||||||
|
|
||||||
stix->sysdic->tally = STIX_OOP_FROM_SMINT(0);
|
|
||||||
tmp = stix_instantiate (stix, stix->_array, STIX_NULL, stix->option.dfl_sysdic_size);
|
|
||||||
if (!tmp) return -1;
|
|
||||||
stix->sysdic->bucket = (stix_oop_oop_t)tmp;
|
|
||||||
|
|
||||||
/* Export the system dictionary via the first class variable of the Stix class */
|
/* Export the system dictionary via the first class variable of the Stix class */
|
||||||
((stix_oop_class_t)stix->_stix)->classvar[0] = (stix_oop_t)stix->sysdic;
|
((stix_oop_class_t)stix->_stix)->classvar[0] = (stix_oop_t)stix->sysdic;
|
||||||
|
|
||||||
@ -201,9 +197,11 @@ static int ignite_3 (stix_t* stix)
|
|||||||
{ 6, { 'S','t','r','i','n','g' } },
|
{ 6, { 'S','t','r','i','n','g' } },
|
||||||
{ 6, { 'S','y','m','b','o','l' } },
|
{ 6, { 'S','y','m','b','o','l' } },
|
||||||
{ 5, { 'A','r','r','a','y' } },
|
{ 5, { 'A','r','r','a','y' } },
|
||||||
|
{ 9, { 'B','y','t','e','A','r','r','a','y' } },
|
||||||
{ 9, { 'S','y','m','b','o','l','S','e','t' } },
|
{ 9, { 'S','y','m','b','o','l','S','e','t' } },
|
||||||
{ 16, { 'S','y','s','t','e','m','D','i','c','t','i','o','n','a','r','y' } },
|
{ 16, { 'S','y','s','t','e','m','D','i','c','t','i','o','n','a','r','y' } },
|
||||||
{ 16, { 'M','e','t','h','o','d','D','i','c','t','i','o','n','a','r','y' } },
|
{ 16, { 'M','e','t','h','o','d','D','i','c','t','i','o','n','a','r','y' } },
|
||||||
|
{ 14, { 'C','o','m','p','i','l','e','d','M','e','t','h','o','d' } },
|
||||||
{ 11, { 'A','s','s','o','c','i','a','t','i','o','n' } },
|
{ 11, { 'A','s','s','o','c','i','a','t','i','o','n' } },
|
||||||
{ 4, { 'T','r','u','e' } },
|
{ 4, { 'T','r','u','e' } },
|
||||||
{ 5, { 'F','a','l','s','e' } },
|
{ 5, { 'F','a','l','s','e' } },
|
||||||
|
@ -298,9 +298,9 @@ int main (int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
stix_uch_t x[] = { 'S', 't', 'r', 'i', 'n', 'g', '\0' };
|
stix_uch_t x[] = { 'X', 't', 'r', 'i', 'n', 'g', '\0' };
|
||||||
stix_uch_t y[] = { 'S', 'y', 'm', 'b', 'o', 'l', '\0' };
|
stix_uch_t y[] = { 'S', 'y', 'm', 'b', 'o', 'l', '\0' };
|
||||||
stix_oop_t a, b;
|
stix_oop_t a, b, k;
|
||||||
|
|
||||||
a = stix_makesymbol (stix, x, 6);
|
a = stix_makesymbol (stix, x, 6);
|
||||||
b = stix_makesymbol (stix, y, 6);
|
b = stix_makesymbol (stix, y, 6);
|
||||||
@ -310,6 +310,13 @@ printf ("%p %p\n", a, b);
|
|||||||
|
|
||||||
dump_symbol_table (stix);
|
dump_symbol_table (stix);
|
||||||
|
|
||||||
|
/*
|
||||||
|
stix_pushtmp (stix, &a);
|
||||||
|
stix_pushtmp (stix, &b);
|
||||||
|
k = stix_instantiate (stix, stix->_byte_array, STIX_NULL, 100);
|
||||||
|
stix_poptmps (stix, 2);
|
||||||
|
stix_putatsysdic (stix, a, k);
|
||||||
|
*/
|
||||||
|
|
||||||
stix_gc (stix);
|
stix_gc (stix);
|
||||||
a = stix_findsymbol (stix, x, 6);
|
a = stix_findsymbol (stix, x, 6);
|
||||||
|
@ -176,6 +176,7 @@ stix_oop_t stix_instantiate (stix_t* stix, stix_oop_t _class, const void* vptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
stix_pushtmp (stix, &_class); tmp_count++;
|
stix_pushtmp (stix, &_class); tmp_count++;
|
||||||
|
/*TODO: protected vptr if it's not STIX_NULL and the variability(indexed_type) is OOP. the current impl is buggy */
|
||||||
|
|
||||||
switch (indexed_type)
|
switch (indexed_type)
|
||||||
{
|
{
|
||||||
@ -214,6 +215,7 @@ stix_oop_t stix_instantiate (stix_t* stix, stix_oop_t _class, const void* vptr,
|
|||||||
return oop;
|
return oop;
|
||||||
|
|
||||||
einval:
|
einval:
|
||||||
|
STIX_ASSERT (tmp_count <= 0);
|
||||||
stix->errnum = STIX_EINVAL;
|
stix->errnum = STIX_EINVAL;
|
||||||
return STIX_NULL;
|
return STIX_NULL;
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ struct stix_t
|
|||||||
stix_oop_t _false;
|
stix_oop_t _false;
|
||||||
|
|
||||||
/* == NEVER CHANGE THE ORDER OF FIELDS BELOW == */
|
/* == NEVER CHANGE THE ORDER OF FIELDS BELOW == */
|
||||||
/* stix_ignite() assumes this order */
|
/* stix_ignite() assumes this order. make sure to update symnames in ignite_3() */
|
||||||
stix_oop_t _stix; /* Stix */
|
stix_oop_t _stix; /* Stix */
|
||||||
stix_oop_t _nil_object; /* NilObject */
|
stix_oop_t _nil_object; /* NilObject */
|
||||||
stix_oop_t _class; /* Class */
|
stix_oop_t _class; /* Class */
|
||||||
|
Loading…
Reference in New Issue
Block a user