Correct the emission of meta class ivars.

type_obj_class is no longer a class, so its ivars are not stored in
type_obj_class.t.class->ivars but rather type_obj_class.t.symtab.

This fixes the segfault Spirit and Randy were experiencing.

In passing, correct the unneeded emission of meta class ivars for non-root
classes. This should make for much smaller progs that use classes.
This commit is contained in:
Bill Currie 2013-01-30 18:05:07 +09:00
parent 831f84a47b
commit 6a3c775270
1 changed files with 9 additions and 2 deletions

View File

@ -642,8 +642,15 @@ begin_class (class_t *class)
EMIT_STRING (space, meta->name, class->name);
meta->info = _PR_CLS_META;
meta->instance_size = type_size (&type_obj_class);
EMIT_DEF (space, meta->ivars,
emit_ivars (type_obj_class.t.class->ivars, "Class"));
if (!class->super_class) {
// The ivars list for the meta class struct get emitted only for the
// root class of the hierachy.
// NOTE: type_obj_class is not actually a class
EMIT_DEF (space, meta->ivars,
emit_ivars (type_obj_class.t.symtab, "Class"));
} else {
meta->ivars = 0;
}
current_class = &class->class_type;
sym = class_symbol (current_class, 0);
class->def = def = sym->s.def;