rename method to function
[cparser] / type_t.h
1 #ifndef TYPE_T_H
2 #define TYPE_T_H
3
4 #include <stdbool.h>
5
6 #include <libfirm/firm_types.h>
7
8 #include "type.h"
9 #include "symbol.h"
10 #include "token_t.h"
11 #include "ast_t.h"
12 #include "adt/obst.h"
13
14 struct obstack *type_obst;
15
16 typedef enum {
17         TYPE_INVALID,
18         TYPE_ATOMIC,
19         TYPE_COMPOUND_STRUCT,
20         TYPE_COMPOUND_UNION,
21         TYPE_ENUM,
22         TYPE_FUNCTION,
23         TYPE_POINTER,
24         TYPE_ARRAY,
25         TYPE_BUILTIN,
26         TYPE_TYPEDEF,
27         TYPE_TYPEOF
28 } type_type_t;
29
30 typedef enum {
31         ATOMIC_TYPE_INVALID,
32         ATOMIC_TYPE_VOID,
33         ATOMIC_TYPE_CHAR,
34         ATOMIC_TYPE_SCHAR,
35         ATOMIC_TYPE_UCHAR,
36         ATOMIC_TYPE_SHORT,
37         ATOMIC_TYPE_USHORT,
38         ATOMIC_TYPE_INT,
39         ATOMIC_TYPE_UINT,
40         ATOMIC_TYPE_LONG,
41         ATOMIC_TYPE_ULONG,
42         ATOMIC_TYPE_LONGLONG,
43         ATOMIC_TYPE_ULONGLONG,
44         ATOMIC_TYPE_FLOAT,
45         ATOMIC_TYPE_DOUBLE,
46         ATOMIC_TYPE_LONG_DOUBLE,
47         ATOMIC_TYPE_BOOL,
48 #ifdef PROVIDE_COMPLEX
49         ATOMIC_TYPE_FLOAT_COMPLEX,
50         ATOMIC_TYPE_DOUBLE_COMPLEX,
51         ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
52 #endif
53 #ifdef PROVIDE_IMAGINARY
54         ATOMIC_TYPE_FLOAT_IMAGINARY,
55         ATOMIC_TYPE_DOUBLE_IMAGINARY,
56         ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY,
57 #endif
58 } atomic_type_type_t;
59
60 typedef enum {
61         TYPE_QUALIFIER_CONST    = 1 << 0,
62         TYPE_QUALIFIER_RESTRICT = 1 << 1,
63         TYPE_QUALIFIER_VOLATILE = 1 << 2,
64         TYPE_QUALIFIER_INLINE   = 1 << 3,
65 } type_qualifier_t;
66
67 struct type_t {
68         type_type_t       type;
69         type_qualifier_t  qualifiers;
70
71         ir_type          *firm_type;
72 };
73
74 struct atomic_type_t {
75         type_t              type;
76         atomic_type_type_t  atype;
77 };
78
79 struct builtin_type_t {
80         type_t    type;
81         symbol_t *symbol;
82         type_t   *real_type;
83 };
84
85 struct pointer_type_t {
86         type_t   type;
87         type_t  *points_to;
88 };
89
90 struct array_type_t {
91         type_t        type;
92         type_t       *element_type;
93         bool          is_static;
94         bool          is_variable;
95         expression_t *size;
96 };
97
98 struct function_parameter_t {
99         type_t               *type;
100         function_parameter_t *next;
101 };
102
103 struct function_type_t {
104         type_t               type;
105         type_t              *result_type;
106         function_parameter_t *parameters;
107         bool                 variadic;
108         bool                 unspecified_parameters;
109 };
110
111 struct compound_type_t {
112         type_t         type;
113         /** the declaration of the compound type, it's context field
114          * contains the compound entries. */
115         declaration_t *declaration;
116 };
117
118 struct enum_type_t {
119         type_t         type;
120         /** the declaration of the enum type. You can find the enum entries by
121          * walking the declaration->context_next list until you don't find
122          * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
123         declaration_t *declaration;
124 };
125
126 struct typedef_type_t {
127         type_t         type;
128         declaration_t *declaration;
129 };
130
131 struct typeof_type_t {
132         type_t        type;
133         expression_t *expression;
134         type_t       *typeof_type;
135 };
136
137 type_t *make_atomic_type(atomic_type_type_t type, type_qualifier_t qualifiers);
138 type_t *make_pointer_type(type_t *points_to, type_qualifier_t qualifiers);
139
140 #endif