-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtype_t.h
157 lines (133 loc) · 3.1 KB
/
type_t.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef TYPE_T_H
#define TYPE_T_H
#include <stdbool.h>
#include "type.h"
#include "symbol.h"
#include "lexer.h"
#include "ast.h"
#include "ast_t.h"
#include "adt/obst.h"
#include <libfirm/typerep.h>
struct obstack *type_obst;
typedef enum {
TYPE_INVALID,
TYPE_ERROR,
TYPE_VOID,
TYPE_ATOMIC,
TYPE_COMPOUND_STRUCT,
TYPE_COMPOUND_UNION,
TYPE_FUNCTION,
TYPE_POINTER,
TYPE_ARRAY,
TYPE_TYPEOF,
TYPE_REFERENCE,
TYPE_REFERENCE_TYPE_VARIABLE,
TYPE_BIND_TYPEVARIABLES,
TYPE_LAST = TYPE_BIND_TYPEVARIABLES
} type_kind_t;
typedef enum {
ATOMIC_TYPE_INVALID,
ATOMIC_TYPE_BOOL,
ATOMIC_TYPE_BYTE,
ATOMIC_TYPE_UBYTE,
ATOMIC_TYPE_SHORT,
ATOMIC_TYPE_USHORT,
ATOMIC_TYPE_INT,
ATOMIC_TYPE_UINT,
ATOMIC_TYPE_LONG,
ATOMIC_TYPE_ULONG,
ATOMIC_TYPE_LONGLONG,
ATOMIC_TYPE_ULONGLONG,
ATOMIC_TYPE_FLOAT,
ATOMIC_TYPE_DOUBLE,
} atomic_type_kind_t;
struct type_base_t {
type_kind_t kind;
ir_type *firm_type;
};
struct atomic_type_t {
type_base_t base;
atomic_type_kind_t akind;
};
struct pointer_type_t {
type_base_t base;
type_t *points_to;
};
struct array_type_t {
type_base_t base;
type_t *element_type;
expression_t *size_expression;
};
struct typeof_type_t {
type_base_t base;
expression_t *expression;
};
struct type_argument_t {
type_t *type;
type_argument_t *next;
};
struct type_reference_t {
type_base_t base;
symbol_t *symbol;
source_position_t source_position;
type_argument_t *type_arguments;
type_variable_t *type_variable;
};
struct bind_typevariables_type_t {
type_base_t base;
type_argument_t *type_arguments;
compound_type_t *polymorphic_type;
};
struct function_parameter_type_t {
type_t *type;
function_parameter_type_t *next;
};
struct type_constraint_t {
symbol_t *concept_symbol;
concept_t *concept;
type_constraint_t *next;
};
struct function_type_t {
type_base_t base;
type_t *result_type;
function_parameter_type_t *parameter_types;
bool variable_arguments;
};
struct compound_entry_t {
type_t *type;
symbol_t *symbol;
compound_entry_t *next;
attribute_t *attributes;
source_position_t source_position;
ir_entity *entity;
};
struct compound_type_t {
type_base_t base;
compound_entry_t *entries;
symbol_t *symbol;
attribute_t *attributes;
type_variable_t *type_parameters;
context_t context;
source_position_t source_position;
};
union type_t
{
type_kind_t kind;
type_base_t base;
atomic_type_t atomic;
pointer_type_t pointer;
array_type_t array;
typeof_type_t typeof;
type_reference_t reference;
bind_typevariables_type_t bind_typevariables;
function_type_t function;
compound_type_t compound;
};
type_t *allocate_type(type_kind_t kind);
type_t *make_atomic_type(atomic_type_kind_t type);
type_t *make_pointer_type(type_t *type);
static inline bool is_type_array(const type_t *type)
{
return type->kind == TYPE_ARRAY;
}
#endif