4 #include <libfirm/firm_types.h>
13 extern struct obstack ast_obstack;
39 declaration_t *declarations;
42 struct expression_base_t {
43 expression_type_t type;
45 source_position_t source_position;
48 struct const_expression_t {
49 expression_base_t expression;
52 long double float_value;
56 struct string_literal_expression_t {
57 expression_base_t expression;
61 struct builtin_symbol_expression_t {
62 expression_base_t expression;
66 struct reference_expression_t {
67 expression_base_t expression;
69 declaration_t *declaration;
72 struct call_argument_t {
73 expression_t *expression;
74 call_argument_t *next;
77 struct call_expression_t {
78 expression_base_t expression;
79 expression_t *function;
80 call_argument_t *arguments;
87 UNEXPR_BITWISE_NEGATE,
91 UNEXPR_POSTFIX_INCREMENT,
92 UNEXPR_POSTFIX_DECREMENT,
93 UNEXPR_PREFIX_INCREMENT,
94 UNEXPR_PREFIX_DECREMENT,
96 UNEXPR_CAST_IMPLICIT /* compiler generated cast */
97 } unary_expression_type_t;
99 struct unary_expression_t {
100 expression_base_t expression;
101 unary_expression_type_t type;
117 BINEXPR_GREATEREQUAL,
131 BINEXPR_SHIFTLEFT_ASSIGN,
132 BINEXPR_SHIFTRIGHT_ASSIGN,
133 BINEXPR_BITWISE_AND_ASSIGN,
134 BINEXPR_BITWISE_XOR_ASSIGN,
135 BINEXPR_BITWISE_OR_ASSIGN,
137 } binary_expression_type_t;
139 struct binary_expression_t {
140 expression_base_t expression;
141 binary_expression_type_t type;
146 struct select_expression_t {
147 expression_base_t expression;
148 expression_t *compound;
151 declaration_t *compound_entry;
154 struct array_access_expression_t {
155 expression_base_t expression;
156 expression_t *array_ref;
158 bool flipped; /* index/ref was written in a 5[a] way */
161 struct sizeof_expression_t {
162 expression_base_t expression;
164 expression_t *size_expression;
167 struct designator_t {
169 expression_t *array_access;
173 struct offsetof_expression_t {
174 expression_base_t expression;
176 designator_t *designator;
179 struct va_arg_expression_t {
180 expression_base_t expression;
185 struct conditional_expression_t {
186 expression_base_t expression;
187 expression_t *condition;
188 expression_t *true_expression;
189 expression_t *false_expression;
192 struct statement_expression_t {
193 expression_base_t expression;
194 statement_t *statement;
197 struct classify_type_expression_t {
198 expression_base_t expression;
199 expression_t *type_expression;
203 expression_type_t type;
204 expression_base_t base;
205 const_expression_t conste;
206 string_literal_expression_t string;
207 builtin_symbol_expression_t builtin_symbol;
208 reference_expression_t reference;
209 call_expression_t call;
210 unary_expression_t unary;
211 binary_expression_t binary;
212 select_expression_t select;
213 array_access_expression_t array_access;
214 sizeof_expression_t sizeofe;
215 offsetof_expression_t offsetofe;
216 va_arg_expression_t va_arge;
217 conditional_expression_t conditional;
218 statement_expression_t statement;
219 classify_type_expression_t classify_type;
224 STORAGE_CLASS_TYPEDEF,
225 STORAGE_CLASS_EXTERN,
226 STORAGE_CLASS_STATIC,
228 STORAGE_CLASS_REGISTER,
229 STORAGE_CLASS_ENUM_ENTRY,
230 STORAGE_CLASS_THREAD,
231 STORAGE_CLASS_THREAD_EXTERN,
232 STORAGE_CLASS_THREAD_STATIC
233 } storage_class_tag_t;
248 } initializer_type_t;
250 struct initializer_base_t {
251 initializer_type_t type;
254 struct initializer_value_t {
255 initializer_base_t initializer;
259 struct initializer_list_t {
260 initializer_base_t initializer;
262 initializer_t *initializers[];
265 struct initializer_string_t {
266 initializer_base_t initializer;
270 union initializer_t {
271 initializer_type_t type;
272 initializer_base_t base;
273 initializer_value_t value;
274 initializer_list_t list;
275 initializer_string_t string;
278 struct declaration_t {
279 unsigned char namespc;
280 unsigned char storage_class;
281 unsigned int address_taken : 1;
282 unsigned int is_inline : 1;
285 source_position_t source_position;
288 statement_t *statement;
289 initializer_t *initializer;
290 expression_t *enum_value;
293 context_t *parent_context;
295 /** next declaration in a context */
297 /** next declaration with same symbol */
298 declaration_t *symbol_next;
300 unsigned char declaration_type; /* used in ast2firm module */
302 unsigned int value_number; /* used in ast2firm module */
303 ir_entity *entity; /* used in ast2firm module */
304 ir_node *block; /* used in ast2firm module */
305 tarval *enum_val; /* used in ast2firm module */
313 STATEMENT_DECLARATION,
316 STATEMENT_EXPRESSION,
321 STATEMENT_CASE_LABEL,
328 struct statement_base_t {
329 statement_type_t type;
331 source_position_t source_position;
334 struct return_statement_t {
335 statement_base_t statement;
336 expression_t *return_value;
339 struct compound_statement_t {
340 statement_base_t statement;
341 statement_t *statements;
345 struct declaration_statement_t {
346 statement_base_t statement;
347 declaration_t *declarations_begin;
348 declaration_t *declarations_end;
351 struct if_statement_t {
352 statement_base_t statement;
353 expression_t *condition;
354 statement_t *true_statement;
355 statement_t *false_statement;
358 struct switch_statement_t {
359 statement_base_t statement;
360 expression_t *expression;
364 struct goto_statement_t {
365 statement_base_t statement;
366 declaration_t *label;
369 struct case_label_statement_t {
370 statement_base_t statement;
371 expression_t *expression;
372 statement_t *label_statement;
375 struct label_statement_t {
376 statement_base_t statement;
377 declaration_t *label;
378 statement_t *label_statement;
381 struct expression_statement_t {
382 statement_base_t statement;
383 expression_t *expression;
386 struct while_statement_t {
387 statement_base_t statement;
388 expression_t *condition;
392 struct do_while_statement_t {
393 statement_base_t statement;
394 expression_t *condition;
398 struct for_statement_t {
399 statement_base_t statement;
400 expression_t *initialisation;
401 expression_t *condition;
407 struct asm_constraint_t {
408 const char *constraints;
409 expression_t *expression;
411 asm_constraint_t *next;
414 struct asm_clobber_t {
419 struct asm_statement_t {
420 statement_base_t statement;
421 const char *asm_text;
422 asm_constraint_t *inputs;
423 asm_constraint_t *outputs;
424 asm_clobber_t *clobbers;
429 statement_type_t type;
430 statement_base_t base;
431 return_statement_t returns;
432 compound_statement_t compound;
433 declaration_statement_t declaration;
435 switch_statement_t switchs;
436 goto_statement_t gotos;
437 case_label_statement_t case_label;
438 label_statement_t label;
439 expression_statement_t expression;
440 while_statement_t whiles;
441 do_while_statement_t do_while;
442 for_statement_t fors;
443 asm_statement_t asms;
446 struct translation_unit_t {
451 void *_allocate_ast(size_t size)
453 return obstack_alloc(&ast_obstack, size);
456 #define allocate_ast(size) _allocate_ast(size)