-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstructs.h
250 lines (227 loc) · 5.58 KB
/
structs.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#ifndef __STRUCTS_H
#define __STRUCTS_H
struct list_struct {
sm_ref node;
struct list_struct *next;
};
typedef enum {
spl_selection_statement,
spl_assignment_expression,
spl_reference_type_decl,
spl_type_specifier,
spl_constant,
spl_label_statement,
spl_array_type_decl,
spl_compound_statement,
spl_field,
spl_struct_type_decl,
spl_element_ref,
spl_declaration,
spl_identifier,
spl_operator,
spl_return_statement,
spl_field_ref,
spl_subroutine_call,
spl_expression_statement,
spl_cast,
spl_iteration_statement,
spl_last_node_type
} spl_node_type;
typedef struct {
sm_ref conditional;
sm_ref then_part;
sm_ref else_part;
srcpos lx_srcpos;
} selection_statement;
typedef struct {
int cg_type;
sm_ref right;
srcpos lx_srcpos;
sm_ref left;
} assignment_expression;
typedef struct {
int cg_referenced_size;
int cg_referenced_type;
char* name;
sm_list type_spec;
sm_ref sm_complex_referenced_type;
int kernel_ref;
srcpos lx_srcpos;
} reference_type_decl;
typedef struct {
int token;
srcpos lx_srcpos;
sm_ref created_type_decl;
} type_specifier;
typedef struct {
int token;
char* const_val;
srcpos lx_srcpos;
} constant;
typedef struct {
char* name;
sm_ref statement;
} label_statement;
typedef struct {
sm_ref sm_complex_element_type;
int cg_element_type;
sm_ref element_ref;
sm_ref size_expr;
sm_ref sm_dynamic_size;
int cg_element_size;
sm_list type_spec;
int cg_static_size;
srcpos lx_srcpos;
int static_var;
} array_type_decl;
typedef struct {
sm_list decls;
sm_list statements;
} compound_statement;
typedef struct {
char* string_type;
sm_ref sm_complex_type;
char* name;
int cg_offset;
int cg_type;
sm_list type_spec;
int cg_size;
} field;
typedef struct {
char* id;
sm_list fields;
int cg_size;
srcpos lx_srcpos;
} struct_type_decl;
typedef struct {
sm_ref sm_complex_element_type;
sm_ref sm_containing_structure_ref;
int cg_element_type;
int this_index_dimension;
sm_ref expression;
srcpos lx_srcpos;
sm_ref array_ref;
} element_ref;
typedef struct {
char* id;
sm_ref sm_complex_type;
int is_typedef;
int cg_oprnd;
sm_ref init_value;
sm_list params;
int closure_id;
int addr_taken;
void* cg_address;
int is_extern;
int cg_type;
sm_list type_spec;
int static_var;
srcpos lx_srcpos;
int param_num;
int is_subroutine;
} declaration;
typedef struct {
sm_ref sm_declaration;
char* id;
int cg_type;
srcpos lx_srcpos;
} identifier;
typedef struct {
int operation_type;
int result_type;
sm_ref right;
srcpos lx_srcpos;
sm_ref left;
} operator;
typedef struct {
sm_ref expression;
srcpos lx_srcpos;
int cg_func_type;
} return_statement;
typedef struct {
char* lx_field;
sm_ref sm_field_ref;
srcpos lx_srcpos;
sm_ref struct_ref;
} field_ref;
typedef struct {
sm_list arguments;
srcpos lx_srcpos;
sm_ref sm_func_ref;
} subroutine_call;
typedef struct {
sm_ref expression;
} expression_statement;
typedef struct {
sm_ref sm_complex_type;
int cg_type;
sm_list type_spec;
sm_ref expression;
srcpos lx_srcpos;
} cast;
typedef struct {
sm_ref init_expr;
sm_ref test_expr;
sm_ref statement;
srcpos lx_srcpos;
sm_ref iter_expr;
} iteration_statement;
typedef union {
selection_statement selection_statement;
assignment_expression assignment_expression;
reference_type_decl reference_type_decl;
type_specifier type_specifier;
constant constant;
label_statement label_statement;
array_type_decl array_type_decl;
compound_statement compound_statement;
field field;
struct_type_decl struct_type_decl;
element_ref element_ref;
declaration declaration;
identifier identifier;
operator operator;
return_statement return_statement;
field_ref field_ref;
subroutine_call subroutine_call;
expression_statement expression_statement;
cast cast;
iteration_statement iteration_statement;
} sm_union;
struct sm_struct {
spl_node_type node_type;
int visited;
sm_union node;
};
#endif
extern sm_ref spl_new_selection_statement();
extern sm_ref spl_new_assignment_expression();
extern sm_ref spl_new_reference_type_decl();
extern sm_ref spl_new_type_specifier();
extern sm_ref spl_new_constant();
extern sm_ref spl_new_label_statement();
extern sm_ref spl_new_array_type_decl();
extern sm_ref spl_new_compound_statement();
extern sm_ref spl_new_field();
extern sm_ref spl_new_struct_type_decl();
extern sm_ref spl_new_element_ref();
extern sm_ref spl_new_declaration();
extern sm_ref spl_new_identifier();
extern sm_ref spl_new_operator();
extern sm_ref spl_new_return_statement();
extern sm_ref spl_new_field_ref();
extern sm_ref spl_new_subroutine_call();
extern sm_ref spl_new_expression_statement();
extern sm_ref spl_new_cast();
extern sm_ref spl_new_iteration_statement();
typedef void (*spl_apply_func)(sm_ref node, void *data);
typedef void (*spl_apply_list_func)(sm_list list, void *data);
extern void spl_apply(sm_ref node, spl_apply_func pre_func, spl_apply_func post_func, spl_apply_list_func list_func, void *data);
extern void spl_print(sm_ref node);
extern void spl_free(sm_ref node);
extern void spl_free_list(sm_list list, void *junk);
extern void spl_rfree(sm_ref node);
extern void spl_rfree_list(sm_list list, void *junk);
extern sm_ref spl_copy(sm_ref node);
extern sm_list spl_copy_list(sm_list list);
extern srcpos spl_get_srcpos(sm_ref expr);