X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type_t.h;h=b7511e691860f2109c308c1aecc1e30e7356ade6;hb=4b01aba61ad8d1c130517ae7bb51eea9b22e9a44;hp=2e0ece20e9e7069a8542c60b7d491bce1b5a4b07;hpb=3bc60b6a59aa640ba89ffaed8fb64247d977cbcc;p=cparser diff --git a/type_t.h b/type_t.h index 2e0ece2..b7511e6 100644 --- a/type_t.h +++ b/type_t.h @@ -2,6 +2,7 @@ #define TYPE_T_H #include +#include #include @@ -92,9 +93,9 @@ struct pointer_type_t { struct array_type_t { type_t type; type_t *element_type; + expression_t *size; bool is_static; bool is_variable; - expression_t *size; }; struct function_parameter_t { @@ -141,4 +142,33 @@ struct typeof_type_t { type_t *make_atomic_type(atomic_type_type_t type, type_qualifiers_t qualifiers); type_t *make_pointer_type(type_t *points_to, type_qualifiers_t qualifiers); +static inline bool is_typeref(const type_t *type) +{ + return type->type == TYPE_TYPEDEF || type->type == TYPE_TYPEOF; +} + +static inline bool is_type_atomic(const type_t *type, atomic_type_type_t atype) +{ + assert(!is_typeref(type)); + + if(type->type != TYPE_ATOMIC) + return false; + const atomic_type_t *atomic_type = (const atomic_type_t*) type; + + return atomic_type->atype == atype; +} + +static inline bool is_type_pointer(const type_t *type) +{ + assert(!is_typeref(type)); + return type->type == TYPE_POINTER; +} + +static inline bool is_type_compound(const type_t *type) +{ + assert(!is_typeref(type)); + return type->type == TYPE_COMPOUND_STRUCT + || type->type == TYPE_COMPOUND_UNION; +} + #endif