mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Allow types to be built from the outside in.
This is required for C style decl processing.
This commit is contained in:
parent
ac91e9376b
commit
1452da676d
2 changed files with 48 additions and 0 deletions
|
@ -128,6 +128,18 @@ extern struct symtab_s *quaternion_struct;
|
|||
struct dstring_s;
|
||||
|
||||
type_t *new_type (void);
|
||||
|
||||
/** Append a type to the end of a type chain.
|
||||
|
||||
The type chain must be made up of only field, pointer, function and array
|
||||
types, as other types do not have auxiliary type fields.
|
||||
|
||||
\param type The type chain to which the type will be appended.
|
||||
\param new The type to be appended. May be any type.
|
||||
\return The type chain with the type appended at the deepest
|
||||
level.
|
||||
*/
|
||||
type_t *append_type (type_t *type, type_t *new);
|
||||
type_t *find_type (type_t *new);
|
||||
void new_typedef (const char *name, type_t *type);
|
||||
type_t *field_type (type_t *aux);
|
||||
|
|
|
@ -120,6 +120,42 @@ new_type (void)
|
|||
return type;
|
||||
}
|
||||
|
||||
type_t *
|
||||
append_type (type_t *type, type_t *new)
|
||||
{
|
||||
type_t **t = &type;
|
||||
|
||||
while (*t) {
|
||||
switch ((*t)->type) {
|
||||
case ev_void:
|
||||
case ev_string:
|
||||
case ev_float:
|
||||
case ev_vector:
|
||||
case ev_entity:
|
||||
case ev_type_count:
|
||||
case ev_quat:
|
||||
case ev_integer:
|
||||
case ev_short:
|
||||
internal_error (0, "append to basic type");
|
||||
case ev_field:
|
||||
case ev_pointer:
|
||||
t = &(*t)->t.fldptr.type;
|
||||
break;
|
||||
case ev_func:
|
||||
t = &(*t)->t.func.type;
|
||||
break;
|
||||
case ev_invalid:
|
||||
if ((*t)->ty == ty_array)
|
||||
t = &(*t)->t.array.type;
|
||||
else
|
||||
internal_error (0, "append to object type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
*t = new;
|
||||
return type;
|
||||
}
|
||||
|
||||
static int
|
||||
types_same (type_t *a, type_t *b)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue