[qfcc] Clean up Obj-QC type struct names

I decided that the obj_ tag was unnecessary.
This commit is contained in:
Bill Currie 2020-03-27 15:33:53 +09:00
parent ab3d91f0c3
commit 498dfdbfef
5 changed files with 66 additions and 69 deletions

View file

@ -90,18 +90,18 @@ typedef struct static_instance_s {
} static_instance_t; } static_instance_t;
extern struct type_s type_id; extern struct type_s type_id;
extern struct type_s type_obj_object; extern struct type_s type_object;
extern struct type_s type_obj_class; extern struct type_s type_class;
extern struct type_s type_Class; extern struct type_s type_Class;
extern struct type_s type_obj_protocol; extern struct type_s type_protocol;
extern struct type_s type_SEL; extern struct type_s type_SEL;
extern struct type_s type_IMP; extern struct type_s type_IMP;
extern struct type_s type_supermsg; extern struct type_s type_supermsg;
extern struct type_s type_obj_exec_class; extern struct type_s type_exec_class;
extern struct type_s type_obj_method; extern struct type_s type_method;
extern struct type_s type_obj_super; extern struct type_s type_super;
extern struct type_s type_obj_method_description; extern struct type_s type_method_description;
extern struct type_s type_obj_category; extern struct type_s type_category;
extern struct type_s type_ivar; extern struct type_s type_ivar;
extern struct type_s type_module; extern struct type_s type_module;

View file

@ -70,33 +70,31 @@ static hashtab_t *static_instances;
static hashtab_t *static_instance_classes; static hashtab_t *static_instance_classes;
// these will be built up further // these will be built up further
type_t type_obj_selector = { ev_invalid, 0, 0, ty_struct}; type_t type_selector = { ev_invalid, 0, 0, ty_struct};
type_t type_SEL = { ev_pointer, "SEL", 1, ty_basic, type_t type_SEL = { ev_pointer, "SEL", 1, ty_basic, {{&type_selector}}};
{{&type_obj_selector}}};
type_t *IMP_params[] = {&type_id, &type_SEL}; type_t *IMP_params[] = {&type_id, &type_SEL};
type_t type_IMP = { ev_func, "IMP", 1, ty_basic, type_t type_IMP = { ev_func, "IMP", 1, ty_basic,
{{&type_id, -3, IMP_params}}}; {{&type_id, -3, IMP_params}}};
type_t type_obj_super = { ev_invalid, 0, 0 }; type_t type_super = { ev_invalid, 0, 0 };
type_t type_SuperPtr = { ev_pointer, 0, 1, ty_basic, {{&type_obj_super}}}; type_t type_SuperPtr = { ev_pointer, 0, 1, ty_basic, {{&type_super}}};
type_t *supermsg_params[] = {&type_SuperPtr, &type_SEL}; type_t *supermsg_params[] = {&type_SuperPtr, &type_SEL};
type_t type_supermsg = { ev_func, ".supermsg", 1, ty_basic, type_t type_supermsg = { ev_func, ".supermsg", 1, ty_basic,
{{&type_id, -3, supermsg_params}}}; {{&type_id, -3, supermsg_params}}};
type_t type_obj_method = { ev_invalid, 0, 0, ty_struct }; type_t type_method = { ev_invalid, 0, 0, ty_struct };
type_t type_obj_method_description = { ev_invalid, 0, 0, ty_struct }; type_t type_method_description = { ev_invalid, 0, 0, ty_struct };
type_t type_obj_category = { ev_invalid, 0, 0, ty_struct}; type_t type_category = { ev_invalid, 0, 0, ty_struct};
type_t type_obj_ivar = { ev_invalid, 0, 0, ty_struct}; type_t type_ivar = { ev_invalid, 0, 0, ty_struct};
type_t type_obj_module = { ev_invalid, 0, 0, ty_struct}; type_t type_module = { ev_invalid, 0, 0, ty_struct};
type_t type_moduleptr = { ev_pointer, 0, 1, ty_basic, type_t type_moduleptr = { ev_pointer, 0, 1, ty_basic, {{&type_module}}};
{{&type_obj_module}}};
type_t *obj_exec_class_params[] = { &type_moduleptr }; type_t *obj_exec_class_params[] = { &type_moduleptr };
type_t type_obj_exec_class = { ev_func, 0, 1, ty_basic, type_t type_exec_class = { ev_func, 0, 1, ty_basic,
{{&type_void, 1, obj_exec_class_params}}}; {{&type_void, 1, obj_exec_class_params}}};
type_t type_obj_object = {ev_invalid, 0, 0, ty_struct}; type_t type_object = {ev_invalid, 0, 0, ty_struct};
type_t type_id = { ev_pointer, "id", 1, ty_basic, {{&type_obj_object}}}; type_t type_id = { ev_pointer, "id", 1, ty_basic, {{&type_object}}};
type_t type_obj_class = { ev_invalid, 0, 0, ty_struct}; type_t type_class = { ev_invalid, 0, 0, ty_struct};
type_t type_Class = { ev_pointer, 0, 1, ty_basic, {{&type_obj_class}}}; type_t type_Class = { ev_pointer, 0, 1, ty_basic, {{&type_class}}};
type_t type_obj_protocol = { ev_invalid, 0, 0, ty_struct}; type_t type_protocol = { ev_invalid, 0, 0, ty_struct};
int obj_initialized = 0; int obj_initialized = 0;
@ -328,7 +326,7 @@ is_id (const type_t *type)
if (!is_struct (type->t.fldptr.type)) if (!is_struct (type->t.fldptr.type))
return 0; return 0;
// if the the symtabs match, then type is id in disguise // if the the symtabs match, then type is id in disguise
if (type->t.fldptr.type->t.symtab == type_obj_object.t.symtab) if (type->t.fldptr.type->t.symtab == type_object.t.symtab)
return 1; return 1;
return 0; return 0;
} }
@ -372,19 +370,19 @@ is_SEL (const type_t *type)
int int
is_object (const type_t *type) is_object (const type_t *type)
{ {
return type == &type_obj_object; return type == &type_object;
} }
int int
is_method (const type_t *type) is_method (const type_t *type)
{ {
return type == &type_obj_method; return type == &type_method;
} }
int int
is_method_description (const type_t *type) is_method_description (const type_t *type)
{ {
return type == &type_obj_method_description; return type == &type_method_description;
} }
static protocollist_t * static protocollist_t *
@ -564,11 +562,11 @@ class_symbol (class_type_t *class_type, int external)
name = va ("_OBJ_CATEGORY_%s_%s", name = va ("_OBJ_CATEGORY_%s_%s",
class_type->c.category->class->name, class_type->c.category->class->name,
class_type->c.category->name); class_type->c.category->name);
type = &type_obj_category; type = &type_category;
break; break;
case ct_class: case ct_class:
name = va ("_OBJ_CLASS_%s", class_type->c.class->name); name = va ("_OBJ_CLASS_%s", class_type->c.class->name);
type = &type_obj_class; type = &type_class;
break; break;
case ct_protocol: case ct_protocol:
return 0; // probably in error recovery return 0; // probably in error recovery
@ -784,7 +782,7 @@ emit_ivars (symtab_t *ivars, const char *name)
if (s->sy_type == sy_var) if (s->sy_type == sy_var)
ivar_data.count++; ivar_data.count++;
} }
ivar_list_struct[1].type = array_type (&type_obj_ivar, ivar_data.count); ivar_list_struct[1].type = array_type (&type_ivar, ivar_data.count);
def = emit_structure (va ("_OBJ_INSTANCE_VARIABLES_%s", name), 's', def = emit_structure (va ("_OBJ_INSTANCE_VARIABLES_%s", name), 's',
ivar_list_struct, 0, &ivar_data, sc_static); ivar_list_struct, 0, &ivar_data, sc_static);
@ -804,7 +802,7 @@ begin_class (class_t *class)
defspace_t *space; defspace_t *space;
sym = make_symbol (va ("_OBJ_METACLASS_%s", class->name), sym = make_symbol (va ("_OBJ_METACLASS_%s", class->name),
&type_obj_class, pr.far_data, sc_static); &type_class, pr.far_data, sc_static);
meta_def = sym->s.def; meta_def = sym->s.def;
meta_def->initialized = meta_def->constant = meta_def->nosave = 1; meta_def->initialized = meta_def->constant = meta_def->nosave = 1;
space = meta_def->space; space = meta_def->space;
@ -814,13 +812,13 @@ begin_class (class_t *class)
EMIT_STRING (space, meta->super_class, class->super_class->name); EMIT_STRING (space, meta->super_class, class->super_class->name);
EMIT_STRING (space, meta->name, class->name); EMIT_STRING (space, meta->name, class->name);
meta->info = _PR_CLS_META; meta->info = _PR_CLS_META;
meta->instance_size = type_size (&type_obj_class); meta->instance_size = type_size (&type_class);
if (!class->super_class) { if (!class->super_class) {
// The ivars list for the meta class struct get emitted only for the // The ivars list for the meta class struct get emitted only for the
// root class of the hierachy. // root class of the hierachy.
// NOTE: type_obj_class is not actually a class // NOTE: type_class is not actually a class
EMIT_DEF (space, meta->ivars, EMIT_DEF (space, meta->ivars,
emit_ivars (type_obj_class.t.symtab, "Class")); emit_ivars (type_class.t.symtab, "Class"));
} else { } else {
meta->ivars = 0; meta->ivars = 0;
} }
@ -1532,11 +1530,11 @@ class_finish_module (void)
free (data.classes); free (data.classes);
free (data.categories); free (data.categories);
module_sym = make_symbol ("_OBJ_MODULE", &type_obj_module, pr.far_data, module_sym = make_symbol ("_OBJ_MODULE", &type_module, pr.far_data,
sc_static); sc_static);
symtab_addsymbol (current_symtab, module_sym); symtab_addsymbol (current_symtab, module_sym);
module = &D_STRUCT (pr_module_t, module_sym->s.def); module = &D_STRUCT (pr_module_t, module_sym->s.def);
module->size = type_size (&type_obj_module); module->size = type_size (&type_module);
EMIT_STRING (module_sym->s.def->space, module->name, EMIT_STRING (module_sym->s.def->space, module->name,
GETSTR (pr.source_file)); GETSTR (pr.source_file));
EMIT_DEF (module_sym->s.def->space, module->symtab, symtab_def); EMIT_DEF (module_sym->s.def->space, module->symtab, symtab_def);
@ -1544,7 +1542,7 @@ class_finish_module (void)
exec_class_sym = symtab_lookup (pr.symtab, "__obj_exec_class"); exec_class_sym = symtab_lookup (pr.symtab, "__obj_exec_class");
if (!exec_class_sym) { if (!exec_class_sym) {
exec_class_sym = new_symbol_type ("__obj_exec_class", exec_class_sym = new_symbol_type ("__obj_exec_class",
&type_obj_exec_class); &type_exec_class);
exec_class_sym = function_symbol (exec_class_sym, 0, 1); exec_class_sym = function_symbol (exec_class_sym, 0, 1);
make_function (exec_class_sym, 0, exec_class_sym->table->space, make_function (exec_class_sym, 0, exec_class_sym->table->space,
sc_extern); sc_extern);
@ -1717,7 +1715,7 @@ emit_protocol (protocol_t *protocol)
defspace_t *space; defspace_t *space;
proto_def = make_symbol (va ("_OBJ_PROTOCOL_%s", protocol->name), proto_def = make_symbol (va ("_OBJ_PROTOCOL_%s", protocol->name),
&type_obj_protocol, pr.far_data, sc_static)->s.def; &type_protocol, pr.far_data, sc_static)->s.def;
if (proto_def->initialized) if (proto_def->initialized)
return proto_def; return proto_def;
proto_def->initialized = proto_def->constant = 1; proto_def->initialized = proto_def->constant = 1;
@ -1884,26 +1882,26 @@ class_finish_ivar_scope (class_type_t *class_type, symtab_t *ivar_scope,
static void static void
init_objective_structs (void) init_objective_structs (void)
{ {
make_structure ("obj_selector", 's', sel_struct, &type_obj_selector); make_structure ("obj_selector", 's', sel_struct, &type_selector);
chain_type (&type_obj_selector); chain_type (&type_selector);
chain_type (&type_SEL); chain_type (&type_SEL);
chain_type (&type_IMP); chain_type (&type_IMP);
make_structure ("obj_method", 's', method_struct, &type_obj_method); make_structure ("obj_method", 's', method_struct, &type_method);
chain_type (&type_obj_method); chain_type (&type_method);
make_structure ("obj_method_description", 's', method_desc_struct, make_structure ("obj_method_description", 's', method_desc_struct,
&type_obj_method_description); &type_method_description);
chain_type (&type_obj_method_description); chain_type (&type_method_description);
make_structure ("obj_category", 's', category_struct, &type_obj_category); make_structure ("obj_category", 's', category_struct, &type_category);
chain_type (&type_obj_category); chain_type (&type_category);
make_structure ("obj_ivar", 's', ivar_struct, &type_obj_ivar); make_structure ("obj_ivar", 's', ivar_struct, &type_ivar);
chain_type (&type_obj_ivar); chain_type (&type_ivar);
make_structure ("obj_super", 's', super_struct, &type_obj_super); make_structure ("obj_super", 's', super_struct, &type_super);
chain_type (&type_obj_super); chain_type (&type_super);
chain_type (&type_SuperPtr); chain_type (&type_SuperPtr);
chain_type (&type_supermsg); chain_type (&type_supermsg);
@ -1913,24 +1911,24 @@ init_objective_structs (void)
static void static void
init_classes (void) init_classes (void)
{ {
make_structure ("obj_class", 's', class_struct, &type_obj_class); make_structure ("obj_class", 's', class_struct, &type_class);
chain_type (&type_obj_class); chain_type (&type_class);
chain_type (&type_Class); chain_type (&type_Class);
make_structure ("obj_object", 's', object_struct, &type_obj_object); make_structure ("obj_object", 's', object_struct, &type_object);
chain_type (&type_obj_object); chain_type (&type_object);
chain_type (&type_id); chain_type (&type_id);
make_structure ("obj_protocol", 's', protocol_struct, &type_obj_protocol); make_structure ("obj_protocol", 's', protocol_struct, &type_protocol);
chain_type (&type_obj_protocol); chain_type (&type_protocol);
} }
static void static void
class_init_obj_module (void) class_init_obj_module (void)
{ {
make_structure ("obj_module", 's', module_struct, &type_obj_module); make_structure ("obj_module", 's', module_struct, &type_module);
chain_type (&type_obj_module); chain_type (&type_module);
chain_type (&type_moduleptr); chain_type (&type_moduleptr);
chain_type (&type_obj_exec_class); chain_type (&type_exec_class);
} }
void void

View file

@ -151,7 +151,7 @@ super_expr (class_type_t *class_type)
sym = symtab_lookup (current_symtab, ".super"); sym = symtab_lookup (current_symtab, ".super");
if (!sym || sym->table != current_symtab) { if (!sym || sym->table != current_symtab) {
sym = new_symbol_type (".super", &type_obj_super); sym = new_symbol_type (".super", &type_super);
initialize_def (sym, 0, current_symtab->space, sc_local); initialize_def (sym, 0, current_symtab->space, sc_local);
} }
super = new_symbol_expr (sym); super = new_symbol_expr (sym);

View file

@ -604,7 +604,7 @@ emit_methods (methodlist_t *methods, const char *name, int instance)
methods->count = count; methods->count = count;
methods->instance = instance; methods->instance = instance;
methods_struct[2].type = array_type (&type_obj_method, count); methods_struct[2].type = array_type (&type_method, count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's', return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',
methods_struct, 0, methods, sc_static); methods_struct, 0, methods, sc_static);
} }
@ -672,8 +672,7 @@ emit_method_descriptions (methodlist_t *methods, const char *name,
methods->count = count; methods->count = count;
methods->instance = instance; methods->instance = instance;
method_list_struct[1].type = array_type (&type_obj_method_description, method_list_struct[1].type = array_type (&type_method_description, count);
count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's', return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',
method_list_struct, 0, methods, sc_static); method_list_struct, 0, methods, sc_static);
} }

View file

@ -319,8 +319,8 @@ typedef struct {
static keyword_t obj_keywords[] = { static keyword_t obj_keywords[] = {
{"id", OBJECT, &type_id }, {"id", OBJECT, &type_id },
{"Class", TYPE, &type_Class }, {"Class", TYPE, &type_Class },
{"Method", TYPE, &type_obj_method}, {"Method", TYPE, &type_method },
{"Super", TYPE, &type_obj_super }, {"Super", TYPE, &type_super },
{"SEL", TYPE, &type_SEL }, {"SEL", TYPE, &type_SEL },
{"IMP", TYPE, &type_IMP }, {"IMP", TYPE, &type_IMP },