more work on parser, stdio.h is fully parsed now
[cparser] / type_t.h
1 #ifndef TYPE_T_H
2 #define TYPE_T_H
3
4 #include "type.h"
5 #include "symbol.h"
6 #include "lexer_t.h"
7 #include "adt/obst.h"
8
9 struct obstack *type_obst;
10
11 typedef enum {
12         TYPE_INVALID,
13         TYPE_ATOMIC,
14         TYPE_COMPOUND_STRUCT,
15         TYPE_COMPOUND_UNION,
16         TYPE_ENUM,
17         TYPE_METHOD,
18         TYPE_POINTER,
19         TYPE_BUILTIN
20 } type_type_t;
21
22 typedef enum {
23         ATOMIC_TYPE_INVALID,
24         ATOMIC_TYPE_VOID,
25         ATOMIC_TYPE_CHAR,
26         ATOMIC_TYPE_SCHAR,
27         ATOMIC_TYPE_UCHAR,
28         ATOMIC_TYPE_SHORT,
29         ATOMIC_TYPE_USHORT,
30         ATOMIC_TYPE_INT,
31         ATOMIC_TYPE_UINT,
32         ATOMIC_TYPE_LONG,
33         ATOMIC_TYPE_ULONG,
34         ATOMIC_TYPE_LONGLONG,
35         ATOMIC_TYPE_ULONGLONG,
36         ATOMIC_TYPE_FLOAT,
37         ATOMIC_TYPE_DOUBLE,
38         ATOMIC_TYPE_LONG_DOUBLE,
39         ATOMIC_TYPE_BOOL,
40 #ifdef PROVIDE_COMPLEX
41         ATOMIC_TYPE_FLOAT_COMPLEX,
42         ATOMIC_TYPE_DOUBLE_COMPLEX,
43         ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
44 #endif
45 #ifdef PROVIDE_IMAGINARY
46         ATOMIC_TYPE_FLOAT_IMAGINARY,
47         ATOMIC_TYPE_DOUBLE_IMAGINARY,
48         ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY,
49 #endif
50 } atomic_type_type_t;
51
52 typedef enum {
53         TYPE_QUALIFIER_CONST    = 1 << 0,
54         TYPE_QUALIFIER_RESTRICT = 1 << 1,
55         TYPE_QUALIFIER_VOLATILE = 1 << 2,
56         TYPE_QUALIFIER_INLINE   = 1 << 3,
57 } type_qualifier_t;
58
59 struct type_t {
60         type_type_t  type;
61         unsigned     qualifiers;
62 };
63
64 struct atomic_type_t {
65         type_t              type;
66         atomic_type_type_t  atype;
67 };
68
69 struct builtin_type_t {
70         type_t    type;
71         symbol_t *symbol;
72 };
73
74 struct enum_type_t {
75         type_t             type;
76         symbol_t          *symbol;
77         /* TODO: list of enum members */
78         source_position_t  source_position;
79 };
80
81 struct pointer_type_t {
82         type_t   type;
83         type_t  *points_to;
84 };
85
86 struct method_parameter_type_t {
87         type_t                  *type;
88         method_parameter_type_t *next;
89 };
90
91 struct method_type_t {
92         type_t                   type;
93         type_t                  *result_type;
94         method_parameter_type_t *parameter_types;
95         const char              *abi_style;
96 };
97
98 struct compound_entry_t {
99         type_t            *type;
100         symbol_t          *symbol;
101         compound_entry_t  *next;
102         source_position_t  source_position;
103 };
104
105 struct compound_type_t {
106         type_t             type;
107         compound_entry_t  *entries;
108         symbol_t          *symbol;
109         source_position_t  source_position;
110 };
111
112 #endif