object.r:

define __obj_exec_class, obj_msgSend and obj_msgSend_super for the way
	qfcc now handles these defs
pr_edict.c:
	PR_ValueString now checks that the function is valid before trying to
	print its name.
class.c:
	__obj_exec_class is now extern
linker.c:
	fix more mangled relocs
method.c:
	obj_msgSend and obj_msgSend_super are now extern
qfcc.c:
	fixes so obj_module_t doesn't get zapped
type.c:
	fixes so obj_module_t doesn't get zapped
This commit is contained in:
Bill Currie 2002-07-16 19:03:56 +00:00
parent 3b1825b692
commit ac1392eb74
7 changed files with 30 additions and 18 deletions

View file

@ -3,11 +3,14 @@ typedef enum {
YES, YES,
} BOOL; } BOOL;
void (obj_module_t [] module) __obj_exec_class = #0;
void (id object, integer code, string fmt, ...) obj_error = #0; void (id object, integer code, string fmt, ...) obj_error = #0;
void (id object, integer code, string fmt, ...) obj_verror = #0;//FIXME not ... void (id object, integer code, string fmt, ...) obj_verror = #0;//FIXME not ...
//obj_error_handler (objc_error_handler func) obj_set_error_handler = #0; //obj_error_handler (objc_error_handler func) obj_set_error_handler = #0;
IMP (id receiver, SEL op) obj_msg_lookup = #0; IMP (id receiver, SEL op) obj_msg_lookup = #0;
IMP (id receiver, SEL op) obj_msg_lookup_super = #0; IMP (id receiver, SEL op) obj_msg_lookup_super = #0;
id (id receiver, SEL op, ...) obj_msgSend = #0;
id (id receiver, SEL op, ...) obj_msgSend_super = #0;
//retval_t (id receiver, SEL op, arglist_t) obj_msg_sendv = #0; //retval_t (id receiver, SEL op, arglist_t) obj_msg_sendv = #0;
(void []) (integer size) obj_malloc = #0; (void []) (integer size) obj_malloc = #0;
(void []) (integer size) obj_atomic_malloc = #0; (void []) (integer size) obj_atomic_malloc = #0;

View file

@ -238,9 +238,15 @@ PR_ValueString (progs_t * pr, etype_t type, pr_type_t *val)
NUM_FOR_BAD_EDICT (pr, PROG_TO_EDICT (pr, val->entity_var))); NUM_FOR_BAD_EDICT (pr, PROG_TO_EDICT (pr, val->entity_var)));
break; break;
case ev_func: case ev_func:
f = pr->pr_functions + val->func_var; if (val->func_var < 0 || val->func_var >= pr->progs->numfunctions)
snprintf (line, sizeof (line), "%s()", snprintf (line, sizeof (line), "INVALID:%d", val->func_var);
PR_GetString (pr, f->s_name)); else if (!val->func_var)
return "NULL";
else {
f = pr->pr_functions + val->func_var;
snprintf (line, sizeof (line), "%s()",
PR_GetString (pr, f->s_name));
}
break; break;
case ev_field: case ev_field:
def = ED_FieldAtOfs (pr, val->integer_var); def = ED_FieldAtOfs (pr, val->integer_var);

View file

@ -443,7 +443,6 @@ class_finish_module (void)
def_t *module_def; def_t *module_def;
pr_module_t *module; pr_module_t *module;
def_t *exec_class_def; def_t *exec_class_def;
function_t *exec_class_func;
def_t *init_def; def_t *init_def;
function_t *init_func; function_t *init_func;
expr_t *init_expr; expr_t *init_expr;
@ -495,13 +494,7 @@ class_finish_module (void)
EMIT_DEF (module->symtab, symtab_def); EMIT_DEF (module->symtab, symtab_def);
exec_class_def = get_def (&type_obj_exec_class, "__obj_exec_class", exec_class_def = get_def (&type_obj_exec_class, "__obj_exec_class",
pr.scope, st_static); pr.scope, st_extern);
exec_class_func = new_function ("__obj_exec_class");
exec_class_func->builtin = 0;
exec_class_func->def = exec_class_def;
reloc_def_func (exec_class_func, exec_class_def->ofs);
build_function (exec_class_func);
finish_function (exec_class_func);
init_def = get_def (&type_function, ".ctor", pr.scope, st_static); init_def = get_def (&type_function, ".ctor", pr.scope, st_static);
init_func = new_function (".ctor"); init_func = new_function (".ctor");

View file

@ -393,12 +393,14 @@ move_def (hashtab_t *deftab, qfo_def_t *d)
} }
if (deftab) { if (deftab) {
while ((d = Hash_Del (deftab, strings->strings + def->name))) { while ((d = Hash_Del (deftab, strings->strings + def->name))) {
int def_relocs;
relocgroup_add_relocs (&final_relocs, relocs.relocs + d->relocs, relocgroup_add_relocs (&final_relocs, relocs.relocs + d->relocs,
d->num_relocs); d->num_relocs);
def_relocs = def->relocs + def->num_relocs;
def->num_relocs += d->num_relocs; def->num_relocs += d->num_relocs;
for (j = 0; j < d->num_relocs; j++) { for (j = 0; j < d->num_relocs; j++) {
relocs.relocs[d->relocs + j].type = rel_none; relocs.relocs[d->relocs + j].type = rel_none;
final_relocs.relocs[def->relocs + j].def = def_num; final_relocs.relocs[def_relocs + j].def = def_num;
} }
} }
} }

View file

@ -176,8 +176,7 @@ make_message_def (const char *name, def_t **def)
expr_t *zero = new_expr (); expr_t *zero = new_expr ();
zero->type = ex_integer; zero->type = ex_integer;
*def = get_def (&type_IMP, name, pr.scope, st_static); *def = get_def (&type_IMP, name, pr.scope, st_extern);
build_builtin_function (*def, zero);
} }
expr_t * expr_t *

View file

@ -132,7 +132,6 @@ InitData (void)
strpool_delete (pr.strings); strpool_delete (pr.strings);
} }
memset (&pr, 0, sizeof (pr)); memset (&pr, 0, sizeof (pr));
chain_initial_types ();
pr.source_line = 1; pr.source_line = 1;
pr.error_count = 0; pr.error_count = 0;
pr.code = codespace_new (); pr.code = codespace_new ();
@ -469,7 +468,6 @@ compile_to_obj (const char *file, const char *obj)
yyin = preprocess_file (file); yyin = preprocess_file (file);
InitData (); InitData ();
begin_compilation ();
clear_frame_macros (); clear_frame_macros ();
clear_classes (); clear_classes ();
clear_defs (); clear_defs ();
@ -478,6 +476,8 @@ compile_to_obj (const char *file, const char *obj)
clear_structs (); clear_structs ();
clear_enums (); clear_enums ();
clear_typedefs (); clear_typedefs ();
chain_initial_types ();
begin_compilation ();
pr.source_file = ReuseString (strip_path (file)); pr.source_file = ReuseString (strip_path (file));
err = yyparse () || pr.error_count; err = yyparse () || pr.error_count;
fclose (yyin); fclose (yyin);
@ -595,6 +595,7 @@ progs_src_compile (void)
setup_sym_file (options.output_file); setup_sym_file (options.output_file);
InitData (); InitData ();
chain_initial_types ();
begin_compilation (); begin_compilation ();

View file

@ -628,12 +628,13 @@ init_types (void)
new_struct_field (type, &type_string, "ivar_name", vis_public); new_struct_field (type, &type_string, "ivar_name", vis_public);
new_struct_field (type, &type_string, "ivar_type", vis_public); new_struct_field (type, &type_string, "ivar_type", vis_public);
new_struct_field (type, &type_integer, "ivar_offset", vis_public); new_struct_field (type, &type_integer, "ivar_offset", vis_public);
#if 0
type = type_module = new_struct (0); type = type_module = new_struct ("obj_module_t");
new_struct_field (type, &type_integer, "version", vis_public); new_struct_field (type, &type_integer, "version", vis_public);
new_struct_field (type, &type_integer, "size", vis_public); new_struct_field (type, &type_integer, "size", vis_public);
new_struct_field (type, &type_string, "name", vis_public); new_struct_field (type, &type_string, "name", vis_public);
new_struct_field (type, &type_pointer, "symtab", vis_public); new_struct_field (type, &type_pointer, "symtab", vis_public);
#endif
} }
void void
@ -662,7 +663,14 @@ chain_initial_types (void)
chain_type (&type_id); chain_type (&type_id);
chain_type (type_category); chain_type (type_category);
chain_type (type_ivar); chain_type (type_ivar);
type_module = new_struct ("obj_module_t");
new_struct_field (type_module, &type_integer, "version", vis_public);
new_struct_field (type_module, &type_integer, "size", vis_public);
new_struct_field (type_module, &type_string, "name", vis_public);
new_struct_field (type_module, &type_pointer, "symtab", vis_public);
chain_type (type_module); chain_type (type_module);
chain_type (&type_obj_exec_class); chain_type (&type_obj_exec_class);
type_obj_exec_class.parm_types[0] = pointer_type (type_module); type_obj_exec_class.parm_types[0] = pointer_type (type_module);