Fix most of the FIXMEs in qfcc.c.

Functions and defs seem to be relocated correctly. Constants are very
broken, however.
This commit is contained in:
Bill Currie 2011-01-28 15:17:30 +09:00
parent 834417b8c8
commit 4837e0bd18

View file

@ -377,13 +377,12 @@ finish_compilation (void)
def_t *d; def_t *d;
qboolean errors = false; qboolean errors = false;
function_t *f; function_t *f;
//FIXME def_t *def; def_t *def;
expr_t e; expr_t e;
//FIXME ex_label_t *l;
dfunction_t *df; dfunction_t *df;
// check to make sure all functions prototyped have code // check to make sure all functions prototyped have code
if (options.warnings.undefined_function) if (options.warnings.undefined_function) {
for (d = pr.near_data->defs; d; d = d->next) { for (d = pr.near_data->defs; d; d = d->next) {
if (d->type->type == ev_func && d->global) { if (d->type->type == ev_func && d->global) {
// function args ok // function args ok
@ -395,20 +394,23 @@ finish_compilation (void)
//FIXME } //FIXME }
} }
} }
#if 0 //FIXME }
for (d = pr.near_data->defs; d; d = d->next) { for (d = pr.near_data->defs; d; d = d->next) {
if (d->external && d->relocs) { if (d->external && d->relocs) {
#if 0 //FIXME
if (strcmp (d->name, ".self") == 0) { if (strcmp (d->name, ".self") == 0) {
get_def (d->type, ".self", pr.scope, st_global); get_def (d->type, ".self", pr.scope, st_global);
} else if (strcmp (d->name, ".this") == 0) { } else if (strcmp (d->name, ".this") == 0) {
get_def (d->type, ".this", pr.scope, st_global); get_def (d->type, ".this", pr.scope, st_global);
} else { } else {
#endif
errors = true; errors = true;
error (0, "undefined global %s", d->name); error (0, "undefined global %s", d->name);
} //FIXME }
} }
} }
#endif
if (errors) if (errors)
return !errors; return !errors;
@ -426,16 +428,17 @@ finish_compilation (void)
//FIXME st_global)); //FIXME st_global));
} }
//FIXME for (def = pr.scope->head; def; def = def->def_next) for (def = pr.near_data->defs; def; def = def->next)
//FIXME relocate_refs (def->refs, def->ofs); relocate_refs (def->relocs, def->offset);
pr.functions = calloc (pr.num_functions + 1, sizeof (dfunction_t)); pr.functions = calloc (pr.num_functions + 1, sizeof (dfunction_t));
for (df = pr.functions + 1, f = pr.func_head; f; df++, f = f->next) { for (df = pr.functions + 1, f = pr.func_head; f; df++, f = f->next) {
relocate_refs (f->refs, f->function_num);
df->s_name = f->s_name; df->s_name = f->s_name;
df->s_file = f->s_file; df->s_file = f->s_file;
df->numparms = function_parms (f, df->parm_size); df->numparms = function_parms (f, df->parm_size);
//FIXME if (f->scope) if (f->symtab && f->symtab->space)
//FIXME df->locals = f->scope->space->size; df->locals = f->symtab->space->size;
if (f->builtin) { if (f->builtin) {
df->first_statement = -f->builtin; df->first_statement = -f->builtin;
continue; continue;
@ -444,28 +447,28 @@ finish_compilation (void)
continue; continue;
df->first_statement = f->code; df->first_statement = f->code;
if (options.code.local_merging) { if (options.code.local_merging) {
//FIXME if (f->scope->space->size > num_localdefs) { if (f->symtab->space->size > num_localdefs) {
//FIXME num_localdefs = f->scope->space->size; num_localdefs = f->symtab->space->size;
//FIXME big_function = f->def->name; big_function = f->def->name;
//FIXME } }
df->parm_start = pr.near_data->size; df->parm_start = pr.near_data->size;
} else { } else {
//FIXME df->parm_start = defspace_new_loc (pr.near_data, df->parm_start = defspace_new_loc (pr.near_data,
//FIXME f->scope->space->size); f->symtab->space->size);
//FIXME num_localdefs += f->scope->space->size; num_localdefs += f->symtab->space->size;
}
for (def = f->symtab->space->defs; def; def = def->next) {
if (!def->local)
continue;
def->offset += df->parm_start;
relocate_refs (def->relocs, def->offset);
} }
//FIXME for (def = f->scope->head; def; def = def->def_next) {
//FIXME if (!def->local)
//FIXME continue;
//FIXME def->ofs += df->parm_start;
//FIXME relocate_refs (def->refs, def->ofs);
//FIXME }
} }
if (options.code.local_merging) { if (options.code.local_merging) {
int ofs; int offset;
for (ofs = defspace_new_loc (pr.near_data, num_localdefs); for (offset = defspace_new_loc (pr.near_data, num_localdefs);
ofs < pr.near_data->size; ofs++) offset < pr.near_data->size; offset++)
pr.near_data->data[ofs].integer_var = 0; pr.near_data->data[offset].integer_var = 0;
} }
return !errors; return !errors;