- add alignment to types and declarations
[cparser] / types.c
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #include "type_t.h"
21 #include "types.h"
22
23 /** The error type. */
24 type_t *type_error_type;
25
26 type_t *type_char;
27 type_t *type_double;
28 type_t *type_float;
29 type_t *type_int;
30 type_t *type_long_double;
31 type_t *type_long_long;
32 type_t *type_long;
33 type_t *type_short;
34 type_t *type_signed_char;
35 type_t *type_unsigned_int;
36 type_t *type_unsigned_long_long;
37 type_t *type_unsigned_long;
38 type_t *type_void;
39
40 type_t *type_char_ptr;
41 type_t *type_int_ptr;
42 type_t *type_long_long_ptr;
43 type_t *type_long_ptr;
44 type_t *type_short_ptr;
45 type_t *type_signed_char_ptr;
46 type_t *type_void_ptr;
47
48 type_t *type_char_ptr_ptr;
49
50 type_t *type_intmax_t;
51 type_t *type_ptrdiff_t;
52 type_t *type_size_t;
53 type_t *type_ssize_t;
54 type_t *type_uintmax_t;
55 type_t *type_uptrdiff_t;
56 type_t *type_wchar_t;
57 type_t *type_wint_t;
58
59 type_t *type_intmax_t_ptr;
60 type_t *type_ptrdiff_t_ptr;
61 type_t *type_ssize_t_ptr;
62 type_t *type_wchar_t_ptr;
63
64
65 void init_basic_types(void)
66 {
67         static const type_base_t error = { TYPE_ERROR, TYPE_QUALIFIER_NONE, 0, { NULL, 0 }, NULL };
68
69         type_error_type         = (type_t*)&error;
70         type_signed_char        = make_atomic_type(ATOMIC_TYPE_SCHAR,       TYPE_QUALIFIER_NONE);
71         type_short              = make_atomic_type(ATOMIC_TYPE_SHORT,       TYPE_QUALIFIER_NONE);
72         type_int                = make_atomic_type(ATOMIC_TYPE_INT,         TYPE_QUALIFIER_NONE);
73         type_unsigned_int       = make_atomic_type(ATOMIC_TYPE_UINT,        TYPE_QUALIFIER_NONE);
74         type_long               = make_atomic_type(ATOMIC_TYPE_LONG,        TYPE_QUALIFIER_NONE);
75         type_unsigned_long      = make_atomic_type(ATOMIC_TYPE_ULONG,       TYPE_QUALIFIER_NONE);
76         type_long_long          = make_atomic_type(ATOMIC_TYPE_LONGLONG,    TYPE_QUALIFIER_NONE);
77         type_unsigned_long_long = make_atomic_type(ATOMIC_TYPE_ULONGLONG,   TYPE_QUALIFIER_NONE);
78         type_long_double        = make_atomic_type(ATOMIC_TYPE_LONG_DOUBLE, TYPE_QUALIFIER_NONE);
79         type_double             = make_atomic_type(ATOMIC_TYPE_DOUBLE,      TYPE_QUALIFIER_NONE);
80         type_float              = make_atomic_type(ATOMIC_TYPE_FLOAT,       TYPE_QUALIFIER_NONE);
81         type_char               = make_atomic_type(ATOMIC_TYPE_CHAR,        TYPE_QUALIFIER_NONE);
82         type_void               = make_atomic_type(ATOMIC_TYPE_VOID,        TYPE_QUALIFIER_NONE);
83
84         type_void_ptr           = make_pointer_type(type_void,              TYPE_QUALIFIER_NONE);
85         type_char_ptr           = make_pointer_type(type_char,              TYPE_QUALIFIER_NONE);
86         type_signed_char_ptr    = make_pointer_type(type_signed_char,       TYPE_QUALIFIER_NONE);
87         type_short_ptr          = make_pointer_type(type_short,             TYPE_QUALIFIER_NONE);
88         type_int_ptr            = make_pointer_type(type_int,               TYPE_QUALIFIER_NONE);
89         type_long_ptr           = make_pointer_type(type_long,              TYPE_QUALIFIER_NONE);
90         type_long_long_ptr      = make_pointer_type(type_long_long,         TYPE_QUALIFIER_NONE);
91
92         type_char_ptr_ptr       = make_pointer_type(type_char_ptr,          TYPE_QUALIFIER_NONE);
93 }