- implemented decimal floating pointer numbers in lexer
[cparser] / type_t.h
1 #ifndef TYPE_T_H
2 #define TYPE_T_H
3
4 #include <stdbool.h>
5
6 #include "type.h"
7 #include "symbol.h"
8 #include "token_t.h"
9 #include "ast_t.h"
10 #include "adt/obst.h"
11
12 struct obstack *type_obst;
13
14 typedef enum {
15         TYPE_INVALID,
16         TYPE_ATOMIC,
17         TYPE_COMPOUND_STRUCT,
18         TYPE_COMPOUND_UNION,
19         TYPE_ENUM,
20         TYPE_METHOD,
21         TYPE_POINTER,
22         TYPE_ARRAY,
23         TYPE_BUILTIN
24 } type_type_t;
25
26 typedef enum {
27         ATOMIC_TYPE_INVALID,
28         ATOMIC_TYPE_VOID,
29         ATOMIC_TYPE_CHAR,
30         ATOMIC_TYPE_SCHAR,
31         ATOMIC_TYPE_UCHAR,
32         ATOMIC_TYPE_SHORT,
33         ATOMIC_TYPE_USHORT,
34         ATOMIC_TYPE_INT,
35         ATOMIC_TYPE_UINT,
36         ATOMIC_TYPE_LONG,
37         ATOMIC_TYPE_ULONG,
38         ATOMIC_TYPE_LONGLONG,
39         ATOMIC_TYPE_ULONGLONG,
40         ATOMIC_TYPE_FLOAT,
41         ATOMIC_TYPE_DOUBLE,
42         ATOMIC_TYPE_LONG_DOUBLE,
43         ATOMIC_TYPE_BOOL,
44 #ifdef PROVIDE_COMPLEX
45         ATOMIC_TYPE_FLOAT_COMPLEX,
46         ATOMIC_TYPE_DOUBLE_COMPLEX,
47         ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
48 #endif
49 #ifdef PROVIDE_IMAGINARY
50         ATOMIC_TYPE_FLOAT_IMAGINARY,
51         ATOMIC_TYPE_DOUBLE_IMAGINARY,
52         ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY,
53 #endif
54 } atomic_type_type_t;
55
56 typedef enum {
57         TYPE_QUALIFIER_CONST    = 1 << 0,
58         TYPE_QUALIFIER_RESTRICT = 1 << 1,
59         TYPE_QUALIFIER_VOLATILE = 1 << 2,
60         TYPE_QUALIFIER_INLINE   = 1 << 3,
61 } type_qualifier_t;
62
63 struct type_t {
64         type_type_t       type;
65         type_qualifier_t  qualifiers;
66 };
67
68 struct atomic_type_t {
69         type_t              type;
70         atomic_type_type_t  atype;
71 };
72
73 struct builtin_type_t {
74         type_t    type;
75         symbol_t *symbol;
76 };
77
78 struct enum_type_t {
79         type_t             type;
80         symbol_t          *symbol;
81         source_position_t  source_position;
82         enum_type_t       *next;
83         declaration_t     *entries_begin;
84         declaration_t     *entries_end;
85         bool               defined;
86 };
87
88 struct pointer_type_t {
89         type_t   type;
90         type_t  *points_to;
91 };
92
93 struct array_type_t {
94         type_t        type;
95         type_t       *element_type;
96         bool          is_static;
97         bool          is_variable;
98         expression_t *size;
99 };
100
101 struct method_parameter_t {
102         type_t             *type;
103         method_parameter_t *next;
104 };
105
106 struct method_type_t {
107         type_t              type;
108         type_t             *result_type;
109         method_parameter_t *parameters;
110         bool                variadic;
111         bool                unspecified_parameters;
112 };
113
114 struct compound_type_t {
115         type_t             type;
116         symbol_t          *symbol;
117         context_t          context;
118         source_position_t  source_position;
119         bool               defined;
120         compound_type_t   *next;
121 };
122
123 type_t *make_atomic_type(atomic_type_type_t type, type_qualifier_t qualifiers);
124 type_t *make_pointer_type(type_t *points_to, type_qualifier_t qualifiers);
125
126 #endif