X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=types.c;h=0842ba2781cd9d04b5f8499e49352398b326f037;hb=4ed62106009e45b119248dccc16eb2b8d65827b2;hp=ef89ac4f4b4d9ec084bae686b1564d5e32115798;hpb=10f7c1a8855a125dd841c2e4037f004ef1fec241;p=cparser diff --git a/types.c b/types.c index ef89ac4..0842ba2 100644 --- a/types.c +++ b/types.c @@ -20,11 +20,14 @@ #include "type_t.h" #include "types.h" #include "lang_features.h" +#include "entity_t.h" /** The error type. */ type_t *type_error_type; +type_t *type_bool; type_t *type_char; +type_t *type_const_char; type_t *type_double; type_t *type_float; type_t *type_int; @@ -32,13 +35,16 @@ type_t *type_long_double; type_t *type_long_long; type_t *type_long; type_t *type_short; +type_t *type_unsigned_short; type_t *type_signed_char; +type_t *type_unsigned_char; type_t *type_unsigned_int; type_t *type_unsigned_long_long; type_t *type_unsigned_long; type_t *type_void; type_t *type_char_ptr; +type_t *type_const_char_ptr; type_t *type_int_ptr; type_t *type_long_long_ptr; type_t *type_long_ptr; @@ -55,12 +61,14 @@ type_t *type_ssize_t; type_t *type_uintmax_t; type_t *type_uptrdiff_t; type_t *type_wchar_t; +type_t *type_const_wchar_t; type_t *type_wint_t; type_t *type_intmax_t_ptr; type_t *type_ptrdiff_t_ptr; type_t *type_ssize_t_ptr; type_t *type_wchar_t_ptr; +type_t *type_const_wchar_t_ptr; /* microsoft types */ atomic_type_kind_t int8_type_kind = ATOMIC_TYPE_INVALID; @@ -86,13 +94,15 @@ type_t *type_unsigned_int64; void init_basic_types(void) { - static const type_base_t error = { TYPE_ERROR, TYPE_QUALIFIER_NONE, - TYPE_MODIFIER_NONE, 0, { NULL, 0 }, - NULL }; + static const type_base_t error = { TYPE_ERROR, 0, TYPE_QUALIFIER_NONE, + TYPE_MODIFIER_NONE, 0, NULL }; type_error_type = (type_t*)&error; + type_bool = make_atomic_type(ATOMIC_TYPE_BOOL, TYPE_QUALIFIER_NONE); type_signed_char = make_atomic_type(ATOMIC_TYPE_SCHAR, TYPE_QUALIFIER_NONE); + type_unsigned_char = make_atomic_type(ATOMIC_TYPE_UCHAR, TYPE_QUALIFIER_NONE); type_short = make_atomic_type(ATOMIC_TYPE_SHORT, TYPE_QUALIFIER_NONE); + type_unsigned_short = make_atomic_type(ATOMIC_TYPE_USHORT, TYPE_QUALIFIER_NONE); type_int = make_atomic_type(ATOMIC_TYPE_INT, TYPE_QUALIFIER_NONE); type_unsigned_int = make_atomic_type(ATOMIC_TYPE_UINT, TYPE_QUALIFIER_NONE); type_long = make_atomic_type(ATOMIC_TYPE_LONG, TYPE_QUALIFIER_NONE); @@ -106,7 +116,7 @@ void init_basic_types(void) type_void = make_atomic_type(ATOMIC_TYPE_VOID, TYPE_QUALIFIER_NONE); /* microsoft types */ - if(c_mode & _MS) { + if (c_mode & _MS) { int8_type_kind = find_signed_int_atomic_type_kind_for_size(1); type_int8 = make_atomic_type(int8_type_kind, TYPE_QUALIFIER_NONE); int16_type_kind = find_signed_int_atomic_type_kind_for_size(2); @@ -135,4 +145,27 @@ void init_basic_types(void) type_long_long_ptr = make_pointer_type(type_long_long, TYPE_QUALIFIER_NONE); type_char_ptr_ptr = make_pointer_type(type_char_ptr, TYPE_QUALIFIER_NONE); + + /* const character types */ + type_const_char = make_atomic_type(ATOMIC_TYPE_CHAR, TYPE_QUALIFIER_CONST); + type_const_char_ptr = make_pointer_type(type_const_char, TYPE_QUALIFIER_NONE); + + /* other types */ + type_intmax_t = type_long_long; + type_size_t = type_unsigned_long; + type_ssize_t = type_long; + type_ptrdiff_t = type_long; + type_uintmax_t = type_unsigned_long_long; + type_uptrdiff_t = type_unsigned_long; + type_wchar_t = make_atomic_type(wchar_atomic_kind, TYPE_QUALIFIER_NONE); + type_wint_t = type_int; + type_const_wchar_t + = make_atomic_type(wchar_atomic_kind, TYPE_QUALIFIER_CONST); + + type_intmax_t_ptr = make_pointer_type(type_intmax_t, TYPE_QUALIFIER_NONE); + type_ptrdiff_t_ptr = make_pointer_type(type_ptrdiff_t, TYPE_QUALIFIER_NONE); + type_ssize_t_ptr = make_pointer_type(type_ssize_t, TYPE_QUALIFIER_NONE); + type_wchar_t_ptr = make_pointer_type(type_wchar_t, TYPE_QUALIFIER_NONE); + type_const_wchar_t_ptr + = make_pointer_type(type_const_wchar_t, TYPE_QUALIFIER_NONE); }