4 #include <libfirm/firm_types.h>
13 extern struct obstack ast_obstack;
21 EXPR_WIDE_STRING_LITERAL,
40 declaration_t *declarations;
43 struct expression_base_t {
44 expression_type_t type;
46 source_position_t source_position;
49 struct const_expression_t {
50 expression_base_t expression;
53 long double float_value;
57 struct string_literal_expression_t {
58 expression_base_t expression;
62 struct wide_string_literal_expression_t {
63 expression_base_t expression;
67 struct builtin_symbol_expression_t {
68 expression_base_t expression;
72 struct reference_expression_t {
73 expression_base_t expression;
75 declaration_t *declaration;
78 struct call_argument_t {
79 expression_t *expression;
80 call_argument_t *next;
83 struct call_expression_t {
84 expression_base_t expression;
85 expression_t *function;
86 call_argument_t *arguments;
93 UNEXPR_BITWISE_NEGATE,
97 UNEXPR_POSTFIX_INCREMENT,
98 UNEXPR_POSTFIX_DECREMENT,
99 UNEXPR_PREFIX_INCREMENT,
100 UNEXPR_PREFIX_DECREMENT,
102 UNEXPR_CAST_IMPLICIT /* compiler generated cast */
103 } unary_expression_type_t;
105 struct unary_expression_t {
106 expression_base_t expression;
107 unary_expression_type_t type;
123 BINEXPR_GREATEREQUAL,
137 BINEXPR_SHIFTLEFT_ASSIGN,
138 BINEXPR_SHIFTRIGHT_ASSIGN,
139 BINEXPR_BITWISE_AND_ASSIGN,
140 BINEXPR_BITWISE_XOR_ASSIGN,
141 BINEXPR_BITWISE_OR_ASSIGN,
143 } binary_expression_type_t;
145 struct binary_expression_t {
146 expression_base_t expression;
147 binary_expression_type_t type;
152 struct select_expression_t {
153 expression_base_t expression;
154 expression_t *compound;
157 declaration_t *compound_entry;
160 struct array_access_expression_t {
161 expression_base_t expression;
162 expression_t *array_ref;
164 bool flipped; /* index/ref was written in a 5[a] way */
167 struct sizeof_expression_t {
168 expression_base_t expression;
170 expression_t *size_expression;
173 struct designator_t {
175 expression_t *array_access;
179 struct offsetof_expression_t {
180 expression_base_t expression;
182 designator_t *designator;
185 struct va_arg_expression_t {
186 expression_base_t expression;
191 struct conditional_expression_t {
192 expression_base_t expression;
193 expression_t *condition;
194 expression_t *true_expression;
195 expression_t *false_expression;
198 struct statement_expression_t {
199 expression_base_t expression;
200 statement_t *statement;
203 struct classify_type_expression_t {
204 expression_base_t expression;
205 expression_t *type_expression;
209 expression_type_t type;
210 expression_base_t base;
211 const_expression_t conste;
212 string_literal_expression_t string;
213 wide_string_literal_expression_t wide_string;
214 builtin_symbol_expression_t builtin_symbol;
215 reference_expression_t reference;
216 call_expression_t call;
217 unary_expression_t unary;
218 binary_expression_t binary;
219 select_expression_t select;
220 array_access_expression_t array_access;
221 sizeof_expression_t sizeofe;
222 offsetof_expression_t offsetofe;
223 va_arg_expression_t va_arge;
224 conditional_expression_t conditional;
225 statement_expression_t statement;
226 classify_type_expression_t classify_type;
231 STORAGE_CLASS_TYPEDEF,
232 STORAGE_CLASS_EXTERN,
233 STORAGE_CLASS_STATIC,
235 STORAGE_CLASS_REGISTER,
236 STORAGE_CLASS_ENUM_ENTRY,
237 STORAGE_CLASS_THREAD,
238 STORAGE_CLASS_THREAD_EXTERN,
239 STORAGE_CLASS_THREAD_STATIC
240 } storage_class_tag_t;
254 INITIALIZER_WIDE_STRING
255 } initializer_type_t;
257 struct initializer_base_t {
258 initializer_type_t type;
261 struct initializer_value_t {
262 initializer_base_t initializer;
266 struct initializer_list_t {
267 initializer_base_t initializer;
269 initializer_t *initializers[];
272 struct initializer_string_t {
273 initializer_base_t initializer;
277 struct initializer_wide_string_t {
278 initializer_base_t initializer;
279 wide_string_t string;
282 union initializer_t {
283 initializer_type_t type;
284 initializer_base_t base;
285 initializer_value_t value;
286 initializer_list_t list;
287 initializer_string_t string;
288 initializer_wide_string_t wide_string;
291 struct declaration_t {
292 unsigned char namespc;
293 unsigned char storage_class;
294 unsigned int address_taken : 1;
295 unsigned int is_inline : 1;
298 source_position_t source_position;
301 statement_t *statement;
302 initializer_t *initializer;
303 expression_t *enum_value;
306 context_t *parent_context;
308 /** next declaration in a context */
310 /** next declaration with same symbol */
311 declaration_t *symbol_next;
313 unsigned char declaration_type; /* used in ast2firm module */
315 unsigned int value_number; /* used in ast2firm module */
316 ir_entity *entity; /* used in ast2firm module */
317 ir_node *block; /* used in ast2firm module */
318 tarval *enum_val; /* used in ast2firm module */
326 STATEMENT_DECLARATION,
329 STATEMENT_EXPRESSION,
334 STATEMENT_CASE_LABEL,
341 struct statement_base_t {
342 statement_type_t type;
344 source_position_t source_position;
347 struct return_statement_t {
348 statement_base_t statement;
349 expression_t *return_value;
352 struct compound_statement_t {
353 statement_base_t statement;
354 statement_t *statements;
358 struct declaration_statement_t {
359 statement_base_t statement;
360 declaration_t *declarations_begin;
361 declaration_t *declarations_end;
364 struct if_statement_t {
365 statement_base_t statement;
366 expression_t *condition;
367 statement_t *true_statement;
368 statement_t *false_statement;
371 struct switch_statement_t {
372 statement_base_t statement;
373 expression_t *expression;
377 struct goto_statement_t {
378 statement_base_t statement;
379 declaration_t *label;
382 struct case_label_statement_t {
383 statement_base_t statement;
384 expression_t *expression;
385 statement_t *label_statement;
388 struct label_statement_t {
389 statement_base_t statement;
390 declaration_t *label;
391 statement_t *label_statement;
394 struct expression_statement_t {
395 statement_base_t statement;
396 expression_t *expression;
399 struct while_statement_t {
400 statement_base_t statement;
401 expression_t *condition;
405 struct do_while_statement_t {
406 statement_base_t statement;
407 expression_t *condition;
411 struct for_statement_t {
412 statement_base_t statement;
413 expression_t *initialisation;
414 expression_t *condition;
420 struct asm_constraint_t {
421 const char *constraints;
422 expression_t *expression;
424 asm_constraint_t *next;
427 struct asm_clobber_t {
432 struct asm_statement_t {
433 statement_base_t statement;
434 const char *asm_text;
435 asm_constraint_t *inputs;
436 asm_constraint_t *outputs;
437 asm_clobber_t *clobbers;
442 statement_type_t type;
443 statement_base_t base;
444 return_statement_t returns;
445 compound_statement_t compound;
446 declaration_statement_t declaration;
448 switch_statement_t switchs;
449 goto_statement_t gotos;
450 case_label_statement_t case_label;
451 label_statement_t label;
452 expression_statement_t expression;
453 while_statement_t whiles;
454 do_while_statement_t do_while;
455 for_statement_t fors;
456 asm_statement_t asms;
459 struct translation_unit_t {
464 void *_allocate_ast(size_t size)
466 return obstack_alloc(&ast_obstack, size);
469 #define allocate_ast(size) _allocate_ast(size)