mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-08 18:31:59 +00:00
[qfcc] Pass full specifier to function_symbol
With generic types, is_overload is no longer enough as the type expression needs to be parsed in order to create the symbol.
This commit is contained in:
parent
2b70eaa85e
commit
8da8bd9917
9 changed files with 32 additions and 21 deletions
|
@ -161,7 +161,7 @@ struct defspace_s;
|
|||
int value_too_large (const type_t *val_type) __attribute__((pure));
|
||||
void make_function (symbol_t *sym, const char *nice_name,
|
||||
struct defspace_s *space, enum storage_class_e storage);
|
||||
symbol_t *function_symbol (symbol_t *sym, int overload);
|
||||
symbol_t *function_symbol (symbol_t *sym, specifier_t spec);
|
||||
const expr_t *find_function (const expr_t *fexpr, const expr_t *params);
|
||||
function_t *new_function (const char *name, const char *nice_name);
|
||||
void add_function (function_t *f);
|
||||
|
|
|
@ -1635,13 +1635,18 @@ class_finish_module (void)
|
|||
if (!exec_class_sym) {
|
||||
exec_class_sym = new_symbol_type ("__obj_exec_class",
|
||||
&type_exec_class);
|
||||
exec_class_sym = function_symbol (exec_class_sym, 0);
|
||||
exec_class_sym = function_symbol (exec_class_sym,
|
||||
(specifier_t) {
|
||||
.is_overload = false
|
||||
});
|
||||
make_function (exec_class_sym, 0, exec_class_sym->table->space,
|
||||
sc_extern);
|
||||
}
|
||||
|
||||
init_sym = new_symbol_type (".ctor", &type_func);
|
||||
init_sym = function_symbol (init_sym, 0);
|
||||
init_sym = function_symbol (init_sym, (specifier_t) {
|
||||
.is_overload = false
|
||||
});
|
||||
|
||||
const expr_t *module_expr;
|
||||
module_expr = address_expr (new_symbol_expr (module_sym), 0);
|
||||
|
|
|
@ -3063,7 +3063,9 @@ think_expr (symbol_t *think_sym)
|
|||
} else {
|
||||
think_sym->type = &type_func;
|
||||
}
|
||||
think_sym = function_symbol (think_sym, 0);
|
||||
think_sym = function_symbol (think_sym, (specifier_t) {
|
||||
.is_overload = false
|
||||
});
|
||||
make_function (think_sym, 0, current_symtab->space, current_storage);
|
||||
return new_symbol_expr (think_sym);
|
||||
}
|
||||
|
|
|
@ -301,13 +301,13 @@ get_function (const char *name, const type_t *type, int overload)
|
|||
}
|
||||
|
||||
symbol_t *
|
||||
function_symbol (symbol_t *sym, int overload)
|
||||
function_symbol (symbol_t *sym, specifier_t spec)
|
||||
{
|
||||
const char *name = sym->name;
|
||||
overloaded_function_t *func;
|
||||
symbol_t *s;
|
||||
|
||||
func = get_function (name, unalias_type (sym->type), overload);
|
||||
func = get_function (name, unalias_type (sym->type), spec.is_overload);
|
||||
|
||||
if (func && func->overloaded)
|
||||
name = func->full_name;
|
||||
|
@ -685,12 +685,12 @@ begin_function (symbol_t *sym, const char *nicename, symtab_t *parent,
|
|||
if (sym->sy_type != sy_func) {
|
||||
error (0, "%s is not a function", sym->name);
|
||||
sym = new_symbol_type (sym->name, &type_func);
|
||||
sym = function_symbol (sym, 1);
|
||||
sym = function_symbol (sym, (specifier_t) { .is_overload = true });
|
||||
}
|
||||
if (sym->s.func && sym->s.func->def && sym->s.func->def->initialized) {
|
||||
error (0, "%s redefined", sym->name);
|
||||
sym = new_symbol_type (sym->name, sym->type);
|
||||
sym = function_symbol (sym, 1);
|
||||
sym = function_symbol (sym, (specifier_t) { .is_overload = true });
|
||||
}
|
||||
space = sym->table->space;
|
||||
if (far)
|
||||
|
|
|
@ -241,7 +241,7 @@ function_definition
|
|||
spec.sym->type = parse_params (spec.sym->type, spec.params);
|
||||
auto sym = function_sym_type (spec, spec.sym);
|
||||
sym->params = spec.params;
|
||||
sym = function_symbol (sym, true);
|
||||
sym = function_symbol (sym, (specifier_t) { .is_overload = true });
|
||||
current_func = begin_function (sym, nullptr, current_symtab,
|
||||
false, spec.storage);
|
||||
current_symtab = current_func->locals;
|
||||
|
|
|
@ -183,7 +183,7 @@ method_symbol (class_type_t *class_type, method_t *method)
|
|||
//printf ("%s %s %s %ld\n", method->name, method->types, str->str,
|
||||
// str->size);
|
||||
sym = new_symbol_type (str->str, method->type);
|
||||
sym = function_symbol (sym, 0);
|
||||
sym = function_symbol (sym, (specifier_t) { .is_overload = false });
|
||||
sym->params = method->params;
|
||||
dstring_delete (str);
|
||||
return sym;
|
||||
|
@ -369,7 +369,7 @@ send_message (int super)
|
|||
symtab_t *save = current_symtab;
|
||||
current_symtab = pr.symtab;
|
||||
sym = new_symbol_type (sm_name, sm_type);
|
||||
sym = function_symbol (sym, 0);
|
||||
sym = function_symbol (sym, (specifier_t) { .is_overload = false });
|
||||
make_function (sym, 0, sym->table->space, sc_extern);
|
||||
current_symtab = save;
|
||||
}
|
||||
|
|
|
@ -665,7 +665,7 @@ qc_nocode_func
|
|||
const expr_t *expr = $4;
|
||||
sym->params = spec.sym->params;
|
||||
sym = function_sym_type (spec, sym);
|
||||
sym = function_symbol (sym, spec.is_overload);
|
||||
sym = function_symbol (sym, spec);
|
||||
build_builtin_function (sym, expr, 0, spec.storage);
|
||||
}
|
||||
| identifier '=' expr
|
||||
|
@ -684,7 +684,7 @@ qc_nocode_func
|
|||
sym->params = spec.sym->params;
|
||||
sym = function_sym_type (spec, sym);
|
||||
if (!local_expr && !is_field (spec.sym->type)) {
|
||||
sym = function_symbol (sym, spec.is_overload);
|
||||
sym = function_symbol (sym, spec);
|
||||
}
|
||||
if (!local_expr && !is_field (sym->type)) {
|
||||
// things might be a confused mess from earlier errors
|
||||
|
@ -711,7 +711,7 @@ qc_code_func
|
|||
symbol_t *sym = $1;
|
||||
sym->params = spec.sym->params;
|
||||
sym = function_sym_type (spec, sym);
|
||||
sym = function_symbol (sym, spec.is_overload);
|
||||
sym = function_symbol (sym, spec);
|
||||
current_func = begin_function (sym, 0, current_symtab, 0,
|
||||
spec.storage);
|
||||
current_symtab = current_func->locals;
|
||||
|
@ -1012,7 +1012,7 @@ function_body
|
|||
{
|
||||
specifier_t spec = default_type ($<spec>0, $<spec>0.sym);
|
||||
symbol_t *sym = function_sym_type (spec, spec.sym);
|
||||
$<symbol>$ = function_symbol (sym, spec.is_overload);
|
||||
$<symbol>$ = function_symbol (sym, spec);
|
||||
}
|
||||
save_storage
|
||||
{
|
||||
|
@ -1036,7 +1036,7 @@ function_body
|
|||
{
|
||||
specifier_t spec = default_type ($<spec>0, $<spec>0.sym);
|
||||
symbol_t *sym = function_sym_type (spec, spec.sym);
|
||||
sym = function_symbol (sym, spec.is_overload);
|
||||
sym = function_symbol (sym, spec);
|
||||
build_builtin_function (sym, $3, 0, spec.storage);
|
||||
}
|
||||
;
|
||||
|
|
|
@ -169,7 +169,7 @@ build_dotmain (symbol_t *program)
|
|||
dotmain->params = 0;
|
||||
dotmain->type = parse_params (&type_int, 0);
|
||||
dotmain->type = find_type (dotmain->type);
|
||||
dotmain = function_symbol (dotmain, 0);
|
||||
dotmain = function_symbol (dotmain, (specifier_t) { .is_overload = false });
|
||||
|
||||
exitcode = new_symbol_expr (symtab_lookup (current_symtab, "ExitCode"));
|
||||
|
||||
|
@ -252,7 +252,7 @@ program_head
|
|||
}
|
||||
$$->type = parse_params (&type_void, 0);
|
||||
$$->type = find_type ($$->type);
|
||||
$$ = function_symbol ($$, 0);
|
||||
$$ = function_symbol ($$, (specifier_t) { .is_overload = false });
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -339,7 +339,9 @@ subprogram_head
|
|||
$$->params = $3;
|
||||
$$->type = parse_params ($5, $3);
|
||||
$$->type = find_type ($$->type);
|
||||
$$ = function_symbol ($$, 0);
|
||||
$$ = function_symbol ($$, (specifier_t) {
|
||||
.is_overload = false
|
||||
});
|
||||
}
|
||||
}
|
||||
| PROCEDURE ID arguments
|
||||
|
@ -351,7 +353,9 @@ subprogram_head
|
|||
$$->params = $3;
|
||||
$$->type = parse_params (&type_void, $3);
|
||||
$$->type = find_type ($$->type);
|
||||
$$ = function_symbol ($$, 0);
|
||||
$$ = function_symbol ($$, (specifier_t) {
|
||||
.is_overload = false
|
||||
});
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
|
@ -293,7 +293,7 @@ declare_symbol (specifier_t spec, const expr_t *init, symtab_t *symtab)
|
|||
error (0, "function %s is initialized", s->name);
|
||||
}
|
||||
s->type = find_type (s->type);
|
||||
s = function_symbol (s, spec.is_overload);
|
||||
s = function_symbol (s, spec);
|
||||
} else {
|
||||
s->type = find_type (s->type);
|
||||
initialize_def (s, init, space, spec.storage, symtab);
|
||||
|
|
Loading…
Reference in a new issue