4 #include <libfirm/firm_types.h>
13 extern struct obstack ast_obstack;
21 EXPR_WIDE_STRING_LITERAL,
41 declaration_t *declarations;
44 struct expression_base_t {
45 expression_type_t type;
47 source_position_t source_position;
50 struct const_expression_t {
51 expression_base_t expression;
54 long double float_value;
58 struct string_literal_expression_t {
59 expression_base_t expression;
63 struct wide_string_literal_expression_t {
64 expression_base_t expression;
68 struct builtin_symbol_expression_t {
69 expression_base_t expression;
73 struct reference_expression_t {
74 expression_base_t expression;
76 declaration_t *declaration;
79 struct call_argument_t {
80 expression_t *expression;
81 call_argument_t *next;
84 struct call_expression_t {
85 expression_base_t expression;
86 expression_t *function;
87 call_argument_t *arguments;
94 UNEXPR_BITWISE_NEGATE,
98 UNEXPR_POSTFIX_INCREMENT,
99 UNEXPR_POSTFIX_DECREMENT,
100 UNEXPR_PREFIX_INCREMENT,
101 UNEXPR_PREFIX_DECREMENT,
103 UNEXPR_CAST_IMPLICIT /* compiler generated cast */
104 } unary_expression_type_t;
106 struct unary_expression_t {
107 expression_base_t expression;
108 unary_expression_type_t type;
124 BINEXPR_GREATEREQUAL,
138 BINEXPR_SHIFTLEFT_ASSIGN,
139 BINEXPR_SHIFTRIGHT_ASSIGN,
140 BINEXPR_BITWISE_AND_ASSIGN,
141 BINEXPR_BITWISE_XOR_ASSIGN,
142 BINEXPR_BITWISE_OR_ASSIGN,
144 } binary_expression_type_t;
146 struct binary_expression_t {
147 expression_base_t expression;
148 binary_expression_type_t type;
153 struct select_expression_t {
154 expression_base_t expression;
155 expression_t *compound;
158 declaration_t *compound_entry;
161 struct array_access_expression_t {
162 expression_base_t expression;
163 expression_t *array_ref;
165 bool flipped; /* index/ref was written in a 5[a] way */
168 struct sizeof_expression_t {
169 expression_base_t expression;
171 expression_t *size_expression;
174 struct designator_t {
176 expression_t *array_access;
180 struct offsetof_expression_t {
181 expression_base_t expression;
183 designator_t *designator;
186 struct va_start_expression_t {
187 expression_base_t expression;
189 declaration_t *parameter;
192 struct va_arg_expression_t {
193 expression_base_t expression;
197 struct conditional_expression_t {
198 expression_base_t expression;
199 expression_t *condition;
200 expression_t *true_expression;
201 expression_t *false_expression;
204 struct statement_expression_t {
205 expression_base_t expression;
206 statement_t *statement;
209 struct classify_type_expression_t {
210 expression_base_t expression;
211 expression_t *type_expression;
215 expression_type_t type;
216 expression_base_t base;
217 const_expression_t conste;
218 string_literal_expression_t string;
219 wide_string_literal_expression_t wide_string;
220 builtin_symbol_expression_t builtin_symbol;
221 reference_expression_t reference;
222 call_expression_t call;
223 unary_expression_t unary;
224 binary_expression_t binary;
225 select_expression_t select;
226 array_access_expression_t array_access;
227 sizeof_expression_t sizeofe;
228 offsetof_expression_t offsetofe;
229 va_start_expression_t va_starte;
230 va_arg_expression_t va_arge;
231 conditional_expression_t conditional;
232 statement_expression_t statement;
233 classify_type_expression_t classify_type;
238 STORAGE_CLASS_TYPEDEF,
239 STORAGE_CLASS_EXTERN,
240 STORAGE_CLASS_STATIC,
242 STORAGE_CLASS_REGISTER,
243 STORAGE_CLASS_ENUM_ENTRY,
244 STORAGE_CLASS_THREAD,
245 STORAGE_CLASS_THREAD_EXTERN,
246 STORAGE_CLASS_THREAD_STATIC
247 } storage_class_tag_t;
261 INITIALIZER_WIDE_STRING
262 } initializer_type_t;
264 struct initializer_base_t {
265 initializer_type_t type;
268 struct initializer_value_t {
269 initializer_base_t initializer;
273 struct initializer_list_t {
274 initializer_base_t initializer;
276 initializer_t *initializers[];
279 struct initializer_string_t {
280 initializer_base_t initializer;
284 struct initializer_wide_string_t {
285 initializer_base_t initializer;
286 wide_string_t string;
289 union initializer_t {
290 initializer_type_t type;
291 initializer_base_t base;
292 initializer_value_t value;
293 initializer_list_t list;
294 initializer_string_t string;
295 initializer_wide_string_t wide_string;
298 struct declaration_t {
299 unsigned char namespc;
300 unsigned char storage_class;
301 unsigned int address_taken : 1;
302 unsigned int is_inline : 1;
305 source_position_t source_position;
308 statement_t *statement;
309 initializer_t *initializer;
310 expression_t *enum_value;
313 context_t *parent_context;
315 /** next declaration in a context */
317 /** next declaration with same symbol */
318 declaration_t *symbol_next;
320 unsigned char declaration_type; /* used in ast2firm module */
322 unsigned int value_number; /* used in ast2firm module */
323 ir_entity *entity; /* used in ast2firm module */
324 ir_node *block; /* used in ast2firm module */
325 tarval *enum_val; /* used in ast2firm module */
333 STATEMENT_DECLARATION,
336 STATEMENT_EXPRESSION,
341 STATEMENT_CASE_LABEL,
348 struct statement_base_t {
349 statement_type_t type;
351 source_position_t source_position;
354 struct return_statement_t {
355 statement_base_t statement;
356 expression_t *return_value;
359 struct compound_statement_t {
360 statement_base_t statement;
361 statement_t *statements;
365 struct declaration_statement_t {
366 statement_base_t statement;
367 declaration_t *declarations_begin;
368 declaration_t *declarations_end;
371 struct if_statement_t {
372 statement_base_t statement;
373 expression_t *condition;
374 statement_t *true_statement;
375 statement_t *false_statement;
378 struct switch_statement_t {
379 statement_base_t statement;
380 expression_t *expression;
384 struct goto_statement_t {
385 statement_base_t statement;
386 declaration_t *label;
389 struct case_label_statement_t {
390 statement_base_t statement;
391 expression_t *expression;
392 statement_t *label_statement;
395 struct label_statement_t {
396 statement_base_t statement;
397 declaration_t *label;
398 statement_t *label_statement;
401 struct expression_statement_t {
402 statement_base_t statement;
403 expression_t *expression;
406 struct while_statement_t {
407 statement_base_t statement;
408 expression_t *condition;
412 struct do_while_statement_t {
413 statement_base_t statement;
414 expression_t *condition;
418 struct for_statement_t {
419 statement_base_t statement;
420 expression_t *initialisation;
421 expression_t *condition;
427 struct asm_constraint_t {
428 const char *constraints;
429 expression_t *expression;
431 asm_constraint_t *next;
434 struct asm_clobber_t {
439 struct asm_statement_t {
440 statement_base_t statement;
441 const char *asm_text;
442 asm_constraint_t *inputs;
443 asm_constraint_t *outputs;
444 asm_clobber_t *clobbers;
449 statement_type_t type;
450 statement_base_t base;
451 return_statement_t returns;
452 compound_statement_t compound;
453 declaration_statement_t declaration;
455 switch_statement_t switchs;
456 goto_statement_t gotos;
457 case_label_statement_t case_label;
458 label_statement_t label;
459 expression_statement_t expression;
460 while_statement_t whiles;
461 do_while_statement_t do_while;
462 for_statement_t fors;
463 asm_statement_t asms;
466 struct translation_unit_t {
471 void *_allocate_ast(size_t size)
473 return obstack_alloc(&ast_obstack, size);
476 #define allocate_ast(size) _allocate_ast(size)