Beat __obj_exec_class into submission.

This commit is contained in:
Bill Currie 2011-02-10 00:15:19 +09:00
parent 006c16807d
commit 01a7af17e5
4 changed files with 29 additions and 16 deletions

View file

@ -113,6 +113,7 @@ class_t *extract_class (class_type_t *class_type);
const char *get_class_name (class_type_t *class_type, int pretty);
struct symbol_s *class_symbol (class_type_t *class_type, int external);
void class_init (void);
void class_init_obj_module (void);
class_t *get_class (struct symbol_s *sym, int create);
void class_add_methods (class_t *class, struct methodlist_s *methods);
void class_add_protocols (class_t *class, protocollist_t *protocols);

View file

@ -75,15 +75,16 @@ type_t type_IMP = { ev_func, "IMP", ty_none,
{{&type_id, -3, {&type_id, &type_SEL}}}};
type_t type_supermsg = { ev_func, ".supermsg", ty_none,
{{&type_id, -3, {0, &type_SEL}}}};
type_t type_obj_exec_class = { ev_func, "function", ty_none,
{{&type_void, 1, { 0 }}}};
type_t type_Method = { ev_invalid, "Method" };
type_t type_Super = { ev_invalid, "Super" };
type_t type_method_description = { ev_invalid, "obj_method_description",
ty_struct };
type_t type_category = { ev_invalid, "category", ty_struct};
type_t type_ivar = { ev_invalid, "ivar", ty_struct};
type_t type_module = { ev_invalid, "module", ty_struct};
type_t type_module = { ev_invalid, 0, ty_struct};
type_t type_moduleptr = { ev_pointer, 0, ty_none, {{&type_module}}};
type_t type_obj_exec_class = { ev_func, 0, ty_none,
{{&type_void, 1, { &type_moduleptr }}}};
type_t type_object = {ev_invalid, "object", ty_class};
type_t type_id = { ev_pointer, "id", ty_none, {{&type_object}}};
@ -231,13 +232,9 @@ init_objective_structs (void)
chain_type (&type_Super);
make_structure ("obj_module_s", 's', module_struct, &type_module);
chain_type (&type_module);
type_supermsg.t.func.param_types[0] = pointer_type (&type_Super);
chain_type (&type_supermsg);
type_obj_exec_class.t.func.param_types[0] = pointer_type (&type_module);
chain_type (&type_obj_exec_class);
}
static void
@ -275,14 +272,26 @@ init_classes (void)
void
class_init (void)
{
symbol_t *sym;
if (!current_symtab)
current_symtab = pr.symtab;
init_classes ();
init_objective_structs ();
}
sym = new_symbol_type ("obj_module_t", &type_module);
void
class_init_obj_module (void)
{
symbol_t *sym;
sym = new_symbol ("obj_module_s");
sym = find_struct ('s', sym, &type_module);
chain_type (&type_module);
chain_type (&type_moduleptr);
chain_type (&type_obj_exec_class);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
sym = new_symbol_type ("obj_module_t", sym->type);
sym->sy_type = sy_type;
symtab_addsymbol (pr.symtab, sym);
}

View file

@ -111,9 +111,11 @@ new_def (const char *name, type_t *type, defspace_t *space,
if (storage != st_extern) {
def->space = space;
def->offset = defspace_new_loc (space, type_size (type));
}
if (space) {
*space->def_tail = def;
space->def_tail = &def->next;
def->offset = defspace_new_loc (space, type_size (type));
}
def->file = pr.source_file;

View file

@ -471,6 +471,8 @@ print_type (type_t *type)
dstring_delete (str);
}
static void _encode_type (dstring_t *encoding, type_t *type, int level);
const char *
encode_params (type_t *type)
{
@ -483,7 +485,7 @@ encode_params (type_t *type)
else
count = type->t.func.num_params;
for (i = 0; i < count; i++)
encode_type (encoding, type->t.func.param_types[i]);
_encode_type (encoding, type->t.func.param_types[i], 1);
if (type->t.func.num_params < 0)
dasprintf (encoding, ".");
@ -492,8 +494,6 @@ encode_params (type_t *type)
return ret;
}
static void _encode_type (dstring_t *encoding, type_t *type, int level);
static void
encode_struct_fields (dstring_t *encoding, symtab_t *strct, int level)
{
@ -526,9 +526,9 @@ encode_struct (dstring_t *encoding, type_t *type, int level)
if (type->name) // FIXME
name = type->name;
if (strct && strct->type == stab_union)
if (type->ty == ty_union)
su = '-';
if (strct && strct->type != stab_union)
else
su = '=';
dasprintf (encoding, "{%s%c", name, su);
if (strct && level < 2)
@ -1010,4 +1010,5 @@ chain_initial_types (void)
chain_type (&type_quaternion);
chain_type (&type_integer);
chain_type (&type_short);
class_init_obj_module ();
}