mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
pr_lex.c:
add PR_PrintType (and lotsa debug to PR_FindType) qc-parse.y: fix up one bit of type corruption, only to find another :/
This commit is contained in:
parent
c0915106e3
commit
bdc0ba32ca
2 changed files with 75 additions and 10 deletions
|
@ -720,6 +720,56 @@ PR_ParseName (void)
|
|||
return ident;
|
||||
}
|
||||
|
||||
void
|
||||
PR_PrintType (type_t *type)
|
||||
{
|
||||
int i;
|
||||
if (!type) {
|
||||
printf("(null)");
|
||||
return;
|
||||
}
|
||||
switch (type->type) {
|
||||
case ev_void:
|
||||
printf ("void");
|
||||
break;
|
||||
case ev_string:
|
||||
printf ("string");
|
||||
break;
|
||||
case ev_float:
|
||||
printf ("float");
|
||||
break;
|
||||
case ev_vector:
|
||||
printf ("vector");
|
||||
break;
|
||||
case ev_entity:
|
||||
printf ("entity");
|
||||
break;
|
||||
case ev_field:
|
||||
printf (".");
|
||||
PR_PrintType (type->aux_type);
|
||||
break;
|
||||
case ev_func:
|
||||
PR_PrintType (type->aux_type);
|
||||
printf ("(");
|
||||
for (i = 0; i < type->num_parms; i++) {
|
||||
PR_PrintType (type->parm_types[i]);
|
||||
if (i < type->num_parms - 1)
|
||||
printf (",");
|
||||
}
|
||||
if (type->num_parms == -1)
|
||||
printf ("...");
|
||||
printf (")");
|
||||
break;
|
||||
case ev_pointer:
|
||||
printf ("pointer to ");
|
||||
PR_PrintType (type->aux_type);
|
||||
break;
|
||||
default:
|
||||
printf ("unknown type %d", type->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
PR_FindType
|
||||
|
||||
|
@ -732,13 +782,27 @@ PR_FindType (type_t *type)
|
|||
def_t *def;
|
||||
type_t *check;
|
||||
int i;
|
||||
|
||||
extern int lineno;
|
||||
printf("%-5d ", lineno);
|
||||
PR_PrintType (type);
|
||||
puts("");
|
||||
for (check = pr.types; check; check = check->next) {
|
||||
PR_PrintType (check);
|
||||
puts("");
|
||||
}
|
||||
puts("");
|
||||
for (check = pr.types; check; check = check->next) {
|
||||
if (check->type != type->type
|
||||
|| check->aux_type != type->aux_type
|
||||
|| check->num_parms != type->num_parms)
|
||||
continue;
|
||||
|
||||
if (check->type != ev_func)
|
||||
return check;
|
||||
|
||||
if (check->num_parms == -1)
|
||||
return check;
|
||||
|
||||
for (i = 0; i < type->num_parms; i++)
|
||||
if (check->parm_types[i] != type->parm_types[i])
|
||||
break;
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct {
|
|||
%}
|
||||
|
||||
%union {
|
||||
scope_t *scope;
|
||||
scope_t scope;
|
||||
def_t *def;
|
||||
type_t *type;
|
||||
expr_t *expr;
|
||||
|
@ -108,17 +108,18 @@ def_item
|
|||
: def_name opt_initializer
|
||||
| '('
|
||||
{
|
||||
$<scope>$->scope = pr_scope;
|
||||
$<scope>$->type = current_type;
|
||||
$<scope>$->pscope = param_scope.scope_next;
|
||||
$<scope>$.scope = pr_scope;
|
||||
$<scope>$.type = current_type;
|
||||
$<scope>$.pscope = param_scope.scope_next;
|
||||
param_scope.scope_next = 0;
|
||||
pr_scope = ¶m_scope;
|
||||
}
|
||||
param_list
|
||||
{
|
||||
$$ = param_scope.scope_next;
|
||||
current_type = $<scope>2->type;
|
||||
param_scope.scope_next = $<scope>2->pscope;
|
||||
pr_scope = $<scope>2->scope;
|
||||
current_type = $<scope>2.type;
|
||||
param_scope.scope_next = $<scope>2.pscope;
|
||||
pr_scope = $<scope>2.scope;
|
||||
}
|
||||
')' { current_type = parse_params ($<def>4); } def_name opt_definition
|
||||
{
|
||||
|
@ -312,8 +313,8 @@ parse_params (def_t *parms)
|
|||
i = 1;
|
||||
do {
|
||||
//puts (parms->name);
|
||||
strcpy (pr_parm_names[new.num_parms - 1], parms->name);
|
||||
new.parm_types[new.num_parms - 1] = parms->type;
|
||||
strcpy (pr_parm_names[new.num_parms - i], parms->name);
|
||||
new.parm_types[new.num_parms - i] = parms->type;
|
||||
i++;
|
||||
parms = parms->next;
|
||||
} while (parms);
|
||||
|
|
Loading…
Reference in a new issue