mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-23 02:41:30 +00:00
Create and use more type checking functions.
This commit is contained in:
parent
8c2af5cff7
commit
211a7a8bbb
2 changed files with 11 additions and 5 deletions
|
@ -149,6 +149,7 @@ void print_type (const type_t *type);
|
|||
const char *encode_params (const type_t *type);
|
||||
void encode_type (struct dstring_s *encoding, const type_t *type);
|
||||
const char *type_get_encoding (const type_t *type);
|
||||
int is_void (const type_t *type);
|
||||
int is_enum (const type_t *type);
|
||||
int is_integral (const type_t *type);
|
||||
int is_float (const type_t *type);
|
||||
|
|
|
@ -649,6 +649,12 @@ encode_type (dstring_t *encoding, const type_t *type)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
is_void (const type_t *type)
|
||||
{
|
||||
return type->type == ev_void;
|
||||
}
|
||||
|
||||
int
|
||||
is_enum (const type_t *type)
|
||||
{
|
||||
|
@ -724,13 +730,12 @@ type_assignable (const type_t *dst, const type_t *src)
|
|||
if (dst->type == ev_field && src->type == ev_field)
|
||||
return 1;
|
||||
// pointer = array
|
||||
if (dst->type == ev_pointer
|
||||
&& src->type == ev_invalid && src->meta == ty_array) {
|
||||
if (is_pointer (dst) && is_array (src)) {
|
||||
if (dst->t.fldptr.type == src->t.array.type)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
if (dst->type != ev_pointer || src->type != ev_pointer)
|
||||
if (!is_pointer (dst) || !is_pointer (src))
|
||||
return is_scalar (dst) && is_scalar (src);
|
||||
|
||||
// pointer = pointer
|
||||
|
@ -743,9 +748,9 @@ type_assignable (const type_t *dst, const type_t *src)
|
|||
|
||||
dst = dst->t.fldptr.type;
|
||||
src = src->t.fldptr.type;
|
||||
if (dst->type == ev_void)
|
||||
if (is_void (dst))
|
||||
return 1;
|
||||
if (src->type == ev_void)
|
||||
if (is_void (src))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue