updated the kernel class initialization to set the superclass
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-07-29 15:36:07 +09:00
parent e4a26b71be
commit 7252ee5e47
4 changed files with 234 additions and 8 deletions

View File

@ -3934,12 +3934,16 @@ static int execute (hcl_t* hcl)
if (HCL_OBJ_GET_FLAGS_KERNEL(class_obj) == 1)
{
/* check if the new definition is compatible with kernel definition */
hcl_ooi_t spec, selfspec;
hcl_ooi_t spec, selfspec, nivars_super, nivars_super_real;
spec = HCL_OOP_TO_SMOOI(class_obj->spec);
selfspec = HCL_OOP_TO_SMOOI(class_obj->selfspec);
nivars_super = HCL_OOP_TO_SMOOI(class_obj->nivars_super);
nivars_super_real = HCL_IS_NIL(hcl, superclass)? 0: HCL_OOP_TO_SMOOI(((hcl_oop_class_t)superclass)->nivars_super);
#if 0
hcl_logbfmt (hcl, HCL_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d ncvars=%d<<<\n", class_obj, class_obj->superclass, superclass, b2, b3, (int)HCL_CLASS_SPEC_NAMED_INSTVARS(spec), (int)HCL_CLASS_SELFSPEC_CLASSVARS(spec));
if (class_obj->superclass != superclass || HCL_CLASS_SPEC_NAMED_INSTVARS(spec) != b2 || HCL_CLASS_SELFSPEC_CLASSVARS(selfspec) != b3)
#endif
if (class_obj->superclass != superclass || HCL_CLASS_SPEC_NAMED_INSTVARS(spec) != b2 || HCL_CLASS_SELFSPEC_CLASSVARS(selfspec) != b3 || nivars_super != nivars_super_real)
{
hcl_seterrbfmt (hcl, HCL_EPERM, "incompatible redefintion of %.*js", HCL_OBJ_GET_SIZE(class_name), HCL_OBJ_GET_CHAR_SLOT(class_name));
if (do_throw_with_internal_errmsg(hcl, fetched_instruction_pointer) >= 0) break;

View File

@ -1468,6 +1468,7 @@ static int ignite_1 (hcl_t* hcl)
HCL_OBJ_SET_CLASS (hcl->c_class, (hcl_oop_t)hcl->c_class);
}
/* create class objects except Class */
for (i = 0; i < HCL_COUNTOF(kernel_classes); i++)
{
hcl_oop_class_t tmp;
@ -1496,6 +1497,20 @@ static int ignite_1 (hcl_t* hcl)
*(hcl_oop_class_t*)((hcl_uint8_t*)hcl + kernel_classes[i].offset) = tmp;
}
/* update the superclass field */
for (i = 0; i < HCL_COUNTOF(kernel_classes); i++)
{
int skci;
skci = kernel_classes[i].superclass_kci;
if (skci >= 0)
{
hcl_oop_class_t* x, * y;
x = (hcl_oop_class_t*)((hcl_uint8_t*)hcl + kernel_classes[i].offset);
y = (hcl_oop_class_t*)((hcl_uint8_t*)hcl + kernel_classes[skci].offset);
(*x)->superclass = (hcl_oop_t)*y;
}
}
#if 0
/* an instance of a method class stores byte codes in the trailer space.
* unlike other classes with trailer size set, the size of the trailer