X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type.h;h=3304c1e469ee18a4da6a6f4ae08c838ec5c4a0af;hb=bafab880eb08fe9a867aae7e52fc290e09a915f2;hp=ca9a1134dbeec741e1be5b7ae32052658d9e1c46;hpb=10f7c1a8855a125dd841c2e4037f004ef1fec241;p=cparser diff --git a/type.h b/type.h index ca9a113..3304c1e 100644 --- a/type.h +++ b/type.h @@ -25,9 +25,13 @@ #include "ast.h" #include "symbol.h" +/** Type used to express sizes. */ +typedef unsigned long il_size_t; +typedef unsigned char il_alignment_t; + /* note that the constant values represent the rank of the types as defined * in § 6.3.1 */ -typedef enum { +typedef enum atomic_type_kind_t { ATOMIC_TYPE_INVALID = 0, ATOMIC_TYPE_VOID, ATOMIC_TYPE_CHAR, @@ -49,7 +53,7 @@ typedef enum { ATOMIC_TYPE_LAST = ATOMIC_TYPE_BOOL } atomic_type_kind_t; -typedef enum { +typedef enum atomic_type_flag_t { ATOMIC_TYPE_FLAG_NONE = 0, ATOMIC_TYPE_FLAG_SIGNED = 1 << 0, ATOMIC_TYPE_FLAG_INTEGER = 1 << 1, @@ -58,7 +62,7 @@ typedef enum { ATOMIC_TYPE_FLAG_COMPLEX = 1 << 4, } atomic_type_flag_t; -typedef enum { +typedef enum type_qualifier_t { TYPE_QUALIFIER_NONE = 0, TYPE_QUALIFIER_CONST = 1 << 0, TYPE_QUALIFIER_RESTRICT = 1 << 1, @@ -117,6 +121,11 @@ void inc_type_visited(void); */ bool is_type_integer(const type_t *type); +/** + * Returns true if the given type is an enum type. + */ +bool is_type_enum(const type_t *type); + /** * return true if type contains signed numbers */ @@ -127,6 +136,11 @@ bool is_type_signed(const type_t *type); */ bool is_type_float(const type_t *type); +/** + * returns true if type contains complex numbers + */ +bool is_type_complex(const type_t *type); + bool is_type_real(const type_t *type); /** @@ -152,8 +166,15 @@ bool is_type_object(const type_t *type); bool types_compatible(const type_t *type1, const type_t *type2); type_t *get_unqualified_type(type_t *type); +type_t *get_qualified_type(type_t*, type_qualifiers_t); type_t *skip_typeref(type_t *type); +/** + * Return the type qualifier set of a type. If skip_array_type + * is true, skip all array types. + */ +type_qualifiers_t get_type_qualifier(const type_t *type, bool skip_array_type); + /** * returns size of an atomic type kind in bytes */