X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type_t.h;h=b61ab777260d05d275f6fa4e3911721f4795bdd3;hb=d25522be2467160d61327fef47c4d564d59340e9;hp=4767d513928f2b3ad46959d231be8ab27c17243e;hpb=557d5a86be9428156b887e4494e574de2d9400ac;p=cparser diff --git a/type_t.h b/type_t.h index 4767d51..b61ab77 100644 --- a/type_t.h +++ b/type_t.h @@ -1,6 +1,10 @@ #ifndef TYPE_T_H #define TYPE_T_H +#include + +#include + #include "type.h" #include "symbol.h" #include "token_t.h" @@ -15,13 +19,18 @@ typedef enum { TYPE_COMPOUND_STRUCT, TYPE_COMPOUND_UNION, TYPE_ENUM, - TYPE_METHOD, + TYPE_FUNCTION, TYPE_POINTER, - TYPE_BUILTIN + TYPE_ARRAY, + TYPE_BUILTIN, + TYPE_TYPEDEF, + TYPE_TYPEOF } type_type_t; +/* note that the constant values represent the rank of the types as defined + * in § 6.3.1 */ typedef enum { - ATOMIC_TYPE_INVALID, + ATOMIC_TYPE_INVALID = 0, ATOMIC_TYPE_VOID, ATOMIC_TYPE_CHAR, ATOMIC_TYPE_SCHAR, @@ -51,15 +60,17 @@ typedef enum { } atomic_type_type_t; typedef enum { + TYPE_QUALIFIER_NONE = 0, TYPE_QUALIFIER_CONST = 1 << 0, TYPE_QUALIFIER_RESTRICT = 1 << 1, TYPE_QUALIFIER_VOLATILE = 1 << 2, - TYPE_QUALIFIER_INLINE = 1 << 3, } type_qualifier_t; struct type_t { - type_type_t type; - unsigned qualifiers; + type_type_t type; + type_qualifier_t qualifiers; + + ir_type *firm_type; }; struct atomic_type_t { @@ -70,19 +81,7 @@ struct atomic_type_t { struct builtin_type_t { type_t type; symbol_t *symbol; -}; - -struct enum_entry_t { - symbol_t *symbol; - expression_t *value; - enum_entry_t *next; -}; - -struct enum_type_t { - type_t type; - symbol_t *symbol; - enum_entry_t *entries; - source_position_t source_position; + type_t *real_type; }; struct pointer_type_t { @@ -90,25 +89,54 @@ struct pointer_type_t { type_t *points_to; }; -struct method_parameter_type_t { - type_t *type; - symbol_t *symbol; - method_parameter_type_t *next; +struct array_type_t { + type_t type; + type_t *element_type; + bool is_static; + bool is_variable; + expression_t *size; +}; + +struct function_parameter_t { + type_t *type; + function_parameter_t *next; }; -struct method_type_t { - type_t type; - type_t *result_type; - method_parameter_type_t *parameter_types; - int variadic; - int unspecified_parameters; +struct function_type_t { + type_t type; + type_t *result_type; + function_parameter_t *parameters; + bool variadic; + bool unspecified_parameters; }; struct compound_type_t { - type_t type; - symbol_t *symbol; - context_t context; - source_position_t source_position; + type_t type; + /** the declaration of the compound type, it's context field + * contains the compound entries. */ + declaration_t *declaration; }; +struct enum_type_t { + type_t type; + /** the declaration of the enum type. You can find the enum entries by + * walking the declaration->context_next list until you don't find + * STORAGE_CLASS_ENUM_ENTRY declarations anymore */ + declaration_t *declaration; +}; + +struct typedef_type_t { + type_t type; + declaration_t *declaration; +}; + +struct typeof_type_t { + type_t type; + expression_t *expression; + type_t *typeof_type; +}; + +type_t *make_atomic_type(atomic_type_type_t type, type_qualifier_t qualifiers); +type_t *make_pointer_type(type_t *points_to, type_qualifier_t qualifiers); + #endif