X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=types.c;h=ef89ac4f4b4d9ec084bae686b1564d5e32115798;hb=4108d31ed34aee3c0841ae01b844420da8a3cdf1;hp=ff45f8abaa502be1fd221aa45d43c13e42b51317;hpb=e4084aa7af7195e56c3170d6c2140603f20e4f57;p=cparser diff --git a/types.c b/types.c index ff45f8a..ef89ac4 100644 --- a/types.c +++ b/types.c @@ -1,5 +1,25 @@ +/* + * This file is part of cparser. + * Copyright (C) 2007-2008 Matthias Braun + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ #include "type_t.h" #include "types.h" +#include "lang_features.h" /** The error type. */ type_t *type_error_type; @@ -42,10 +62,33 @@ type_t *type_ptrdiff_t_ptr; type_t *type_ssize_t_ptr; type_t *type_wchar_t_ptr; +/* microsoft types */ +atomic_type_kind_t int8_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t int16_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t int32_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t int64_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t int128_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t unsigned_int8_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t unsigned_int16_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t unsigned_int32_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t unsigned_int64_type_kind = ATOMIC_TYPE_INVALID; +atomic_type_kind_t unsigned_int128_type_kind = ATOMIC_TYPE_INVALID; + +type_t *type_int8; +type_t *type_int16; +type_t *type_int32; +type_t *type_int64; +type_t *type_unsigned_int8; +type_t *type_unsigned_int16; +type_t *type_unsigned_int32; +type_t *type_unsigned_int64; + void init_basic_types(void) { - static const type_base_t error = { TYPE_ERROR, TYPE_QUALIFIER_NONE, { NULL, 0 }, NULL }; + static const type_base_t error = { TYPE_ERROR, TYPE_QUALIFIER_NONE, + TYPE_MODIFIER_NONE, 0, { NULL, 0 }, + NULL }; type_error_type = (type_t*)&error; type_signed_char = make_atomic_type(ATOMIC_TYPE_SCHAR, TYPE_QUALIFIER_NONE); @@ -62,6 +105,27 @@ void init_basic_types(void) type_char = make_atomic_type(ATOMIC_TYPE_CHAR, TYPE_QUALIFIER_NONE); type_void = make_atomic_type(ATOMIC_TYPE_VOID, TYPE_QUALIFIER_NONE); + /* microsoft types */ + 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); + type_int16 = make_atomic_type(int16_type_kind, TYPE_QUALIFIER_NONE); + int32_type_kind = find_signed_int_atomic_type_kind_for_size(4); + type_int32 = make_atomic_type(int32_type_kind, TYPE_QUALIFIER_NONE); + int64_type_kind = find_signed_int_atomic_type_kind_for_size(8); + type_int64 = make_atomic_type(int64_type_kind, TYPE_QUALIFIER_NONE); + unsigned_int8_type_kind = find_unsigned_int_atomic_type_kind_for_size(1); + type_unsigned_int8 = make_atomic_type(unsigned_int8_type_kind, TYPE_QUALIFIER_NONE); + unsigned_int16_type_kind = find_unsigned_int_atomic_type_kind_for_size(2); + type_unsigned_int16 = make_atomic_type(unsigned_int16_type_kind, TYPE_QUALIFIER_NONE); + unsigned_int32_type_kind = find_unsigned_int_atomic_type_kind_for_size(4); + type_unsigned_int32 = make_atomic_type(unsigned_int32_type_kind, TYPE_QUALIFIER_NONE); + unsigned_int64_type_kind = find_unsigned_int_atomic_type_kind_for_size(8); + type_unsigned_int64 = make_atomic_type(unsigned_int64_type_kind, TYPE_QUALIFIER_NONE); + } + + /* pointer types */ type_void_ptr = make_pointer_type(type_void, TYPE_QUALIFIER_NONE); type_char_ptr = make_pointer_type(type_char, TYPE_QUALIFIER_NONE); type_signed_char_ptr = make_pointer_type(type_signed_char, TYPE_QUALIFIER_NONE);