mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[qfcc] Handle qc function field parameters
The type system rewrite had lost some of the checks for function fields. This puts the actual code in the one place and covers parameters as well as globals.
This commit is contained in:
parent
fa97074aff
commit
3a297c70b3
3 changed files with 27 additions and 21 deletions
|
@ -149,6 +149,8 @@ param_t *reverse_params (param_t *params);
|
|||
param_t *append_params (param_t *params, param_t *more_params);
|
||||
param_t *copy_params (param_t *params);
|
||||
struct type_s *parse_params (struct type_s *return_type, param_t *params);
|
||||
struct specifier_s parse_qc_params (struct specifier_s spec, param_t *params);
|
||||
|
||||
param_t *check_params (param_t *params);
|
||||
|
||||
enum storage_class_e;
|
||||
|
|
|
@ -218,6 +218,26 @@ parse_params (type_t *return_type, param_t *parms)
|
|||
return new;
|
||||
}
|
||||
|
||||
specifier_t
|
||||
parse_qc_params (specifier_t spec, param_t *params)
|
||||
{
|
||||
type_t **type;
|
||||
// .float () foo; is a field holding a function variable rather
|
||||
// than a function that returns a float field.
|
||||
for (type = &spec.type; *type && is_field (*type);
|
||||
type = &(*type)->t.fldptr.type) {
|
||||
}
|
||||
type_t *ret_type = *type;
|
||||
*type = 0;
|
||||
*type = parse_params (ret_type, params);
|
||||
set_func_type_attrs ((*type), spec);
|
||||
if (spec.type->type != ev_field) {
|
||||
spec.is_function = 1; //FIXME do proper void(*)() -> ev_func
|
||||
spec.params = params;
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
param_t *
|
||||
check_params (param_t *params)
|
||||
{
|
||||
|
|
|
@ -423,21 +423,7 @@ datadef
|
|||
| declspecs_ts qc_func_params
|
||||
{
|
||||
specifier_t spec = default_type ($1, 0);
|
||||
type_t **type;
|
||||
// .float () foo; is a field holding a function variable rather
|
||||
// than a function that returns a float field.
|
||||
for (type = &spec.type; *type && (*type)->type == ev_field;
|
||||
type = &(*type)->t.fldptr.type)
|
||||
;
|
||||
type_t *ret_type = *type;
|
||||
*type = 0;
|
||||
*type = parse_params (ret_type, $2);
|
||||
set_func_type_attrs ((*type), spec);
|
||||
if (spec.type->type != ev_field) {
|
||||
spec.is_function = 1; //FIXME do proper void(*)() -> ev_func
|
||||
spec.params = $2;
|
||||
}
|
||||
$<spec>$ = spec;
|
||||
$<spec>$ = parse_qc_params (spec, $2);
|
||||
}
|
||||
qc_func_decls
|
||||
| declspecs ';'
|
||||
|
@ -476,9 +462,8 @@ qc_first_param
|
|||
}
|
||||
| typespec_reserved qc_func_params identifier
|
||||
{
|
||||
specifier_t spec = default_type ($1, $3);
|
||||
$3->params = $2;
|
||||
spec.type = parse_params (spec.type, $2);
|
||||
specifier_t spec = default_type ($1, 0);
|
||||
spec = parse_qc_params (spec, $2);
|
||||
|
||||
$$ = new_param (0, spec.type, $3->name);
|
||||
}
|
||||
|
@ -492,9 +477,8 @@ qc_param
|
|||
}
|
||||
| typespec qc_func_params identifier
|
||||
{
|
||||
specifier_t spec = default_type ($1, $3);
|
||||
$3->params = $2;
|
||||
spec.type = parse_params (spec.type, $2);
|
||||
specifier_t spec = default_type ($1, 0);
|
||||
spec = parse_qc_params (spec, $2);
|
||||
|
||||
$$ = new_param (0, spec.type, $3->name);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue