4 #include <libfirm/firm_types.h>
12 extern struct obstack ast_obstack;
38 declaration_t *declarations;
42 expresion_type_t type;
44 source_position_t source_position;
48 expression_t expression;
51 long double float_value;
55 struct string_literal_t {
56 expression_t expression;
60 struct builtin_symbol_expression_t {
61 expression_t expression;
65 struct reference_expression_t {
66 expression_t expression;
68 declaration_t *declaration;
71 struct call_argument_t {
72 expression_t *expression;
73 call_argument_t *next;
76 struct call_expression_t {
77 expression_t expression;
78 expression_t *function;
79 call_argument_t *arguments;
86 UNEXPR_BITWISE_NEGATE,
90 UNEXPR_POSTFIX_INCREMENT,
91 UNEXPR_POSTFIX_DECREMENT,
92 UNEXPR_PREFIX_INCREMENT,
93 UNEXPR_PREFIX_DECREMENT,
95 } unary_expression_type_t;
97 struct unary_expression_t {
98 expression_t expression;
99 unary_expression_type_t type;
115 BINEXPR_GREATEREQUAL,
129 BINEXPR_SHIFTLEFT_ASSIGN,
130 BINEXPR_SHIFTRIGHT_ASSIGN,
131 BINEXPR_BITWISE_AND_ASSIGN,
132 BINEXPR_BITWISE_XOR_ASSIGN,
133 BINEXPR_BITWISE_OR_ASSIGN,
135 } binary_expression_type_t;
137 struct binary_expression_t {
138 expression_t expression;
139 binary_expression_type_t type;
144 struct select_expression_t {
145 expression_t expression;
146 expression_t *compound;
149 declaration_t *compound_entry;
152 struct array_access_expression_t {
153 expression_t expression;
154 expression_t *array_ref;
158 struct sizeof_expression_t {
159 expression_t expression;
161 expression_t *size_expression;
164 struct designator_t {
166 expression_t *array_access;
170 struct offsetof_expression_t {
171 expression_t expression;
173 designator_t *designator;
176 struct va_arg_expression_t {
177 expression_t expression;
182 struct conditional_expression_t {
183 expression_t expression;
184 expression_t *condition;
185 expression_t *true_expression;
186 expression_t *false_expression;
189 struct statement_expression_t {
190 expression_t expression;
191 statement_t *statement;
194 struct classify_type_expression_t {
195 expression_t expression;
196 expression_t *type_expression;
201 STORAGE_CLASS_TYPEDEF,
202 STORAGE_CLASS_EXTERN,
203 STORAGE_CLASS_STATIC,
205 STORAGE_CLASS_REGISTER,
206 STORAGE_CLASS_ENUM_ENTRY
221 } initializer_type_t;
223 struct initializer_t {
224 initializer_type_t type;
226 /* if type == INITIALIZER_VALUE */
228 /* if type == INITIALIZER_LIST */
231 initializer_t *initializers[1];
233 /* if type == INITIALIZER_STRING */
238 struct declaration_t {
239 unsigned char namespc;
240 unsigned char storage_class;
241 unsigned int address_taken : 1;
242 unsigned int is_inline : 1;
245 source_position_t source_position;
248 statement_t *statement;
249 initializer_t *initializer;
250 expression_t *enum_value;
253 context_t *parent_context;
255 /** next declaration in a context */
257 /** next declaration with same symbol */
258 declaration_t *symbol_next;
260 unsigned char declaration_type; /* used in ast2firm module */
262 unsigned int value_number; /* used in ast2firm module */
263 ir_entity *entity; /* used in ast2firm module */
264 ir_node *block; /* used in ast2firm module */
272 STATEMENT_DECLARATION,
275 STATEMENT_EXPRESSION,
280 STATEMENT_CASE_LABEL,
287 statement_type_t type;
289 source_position_t source_position;
291 /* if type == STATEMENT_COMPOUND */
293 statement_t *statements;
296 /* if type == STATEMENT_RETURN */
297 expression_t *return_value;
298 /* if type == STATEMENT_DECLARATION */
300 declaration_t *begin;
303 /* if type == STATEMENT_IF */
305 expression_t *condition;
306 statement_t *true_statement;
307 statement_t *false_statement;
309 /* if type == STATEMENT_SWITCH */
311 expression_t *expression;
314 /* if type == STATEMENT_EXPRESSION */
315 expression_t *expression;
316 /* if type == STATEMENT_GOTO */
317 declaration_t *goto_label;
318 /* if type == STATEMENT_LABEL */
320 declaration_t *label;
321 statement_t *label_statement;
323 /* if type == STATEMENT_CASE_LABEL */
325 expression_t *expression;
326 statement_t *label_statement;
328 /* if type == STATEMENT_WHILE or STATEMENT_DO_WHILE */
330 expression_t *condition;
333 /* if type == STATEMENT_FOR */
335 expression_t *initialisation;
336 expression_t *condition;
344 struct translation_unit_t {
349 void *_allocate_ast(size_t size)
351 return obstack_alloc(&ast_obstack, size);
354 #define allocate_ast(size) _allocate_ast(size)