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