7 * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
23 #include <babeltrace/list-internal.h>
24 #include <babeltrace/babeltrace.h>
25 #include <babeltrace/babeltrace-internal.h>
29 // the parameter name (of the reentrant 'yyparse' function)
30 // data is a pointer to a 'SParserParam' structure
31 //#define YYPARSE_PARAM scanner
35 struct ctf_visitor_generate_ir
;
37 #define EINCOMPLETE 1000
39 #define FOREACH_CTF_NODES(F) \
49 F(NODE_CTF_EXPRESSION) \
50 F(NODE_UNARY_EXPRESSION) \
52 F(NODE_TYPEALIAS_TARGET) \
53 F(NODE_TYPEALIAS_ALIAS) \
55 F(NODE_TYPE_SPECIFIER) \
56 F(NODE_TYPE_SPECIFIER_LIST) \
58 F(NODE_TYPE_DECLARATOR) \
59 F(NODE_FLOATING_POINT) \
64 F(NODE_STRUCT_OR_VARIANT_DECLARATION) \
70 FOREACH_CTF_NODES(ENTRY
)
77 * Parent node is only set on demand by specific visitor.
79 struct ctf_node
*parent
;
80 struct bt_list_head siblings
;
81 struct bt_list_head tmp_head
;
84 * We mark nodes visited in the generate-ir phase (last
85 * phase). We only mark the 1-depth level nodes as visited
86 * (never the root node, and not their sub-nodes). This allows
87 * skipping already visited nodes when doing incremental
98 * Children nodes are ctf_expression, typedef,
99 * typealias and type_specifier_list.
101 struct bt_list_head declaration_list
;
102 struct bt_list_head trace
;
103 struct bt_list_head env
;
104 struct bt_list_head stream
;
105 struct bt_list_head event
;
106 struct bt_list_head clock
;
107 struct bt_list_head callsite
;
111 * Children nodes are ctf_expression, typedef,
112 * typealias and type_specifier_list.
114 struct bt_list_head declaration_list
;
118 * Children nodes are ctf_expression, typedef,
119 * typealias and type_specifier_list.
121 struct bt_list_head declaration_list
;
125 * Children nodes are ctf_expression, typedef,
126 * typealias and type_specifier_list.
128 struct bt_list_head declaration_list
;
132 * Children nodes are ctf_expression, typedef,
133 * typealias and type_specifier_list.
135 struct bt_list_head declaration_list
;
139 * Children nodes are ctf_expression, typedef,
140 * typealias and type_specifier_list.
142 struct bt_list_head declaration_list
;
146 * Children nodes are ctf_expression, typedef,
147 * typealias and type_specifier_list.
149 struct bt_list_head declaration_list
;
152 struct bt_list_head left
; /* Should be string */
153 struct bt_list_head right
; /* Unary exp. or type */
159 UNARY_SIGNED_CONSTANT
,
160 UNARY_UNSIGNED_CONSTANT
,
165 * string for identifier, id_type, keywords,
166 * string literals and character constants.
169 int64_t signed_constant
;
170 uint64_t unsigned_constant
;
171 struct ctf_node
*sbrac_exp
;
174 UNARY_LINK_UNKNOWN
= 0,
181 struct ctf_node
*type_specifier_list
;
182 struct bt_list_head type_declarators
;
184 /* new type is "alias", existing type "target" */
186 struct ctf_node
*type_specifier_list
;
187 struct bt_list_head type_declarators
;
190 struct ctf_node
*type_specifier_list
;
191 struct bt_list_head type_declarators
;
194 struct ctf_node
*target
;
195 struct ctf_node
*alias
;
199 TYPESPEC_UNKNOWN
= 0,
214 TYPESPEC_FLOATING_POINT
,
221 /* For struct, variant and enum */
222 struct ctf_node
*node
;
226 /* list of type_specifier */
227 struct bt_list_head head
;
228 } type_specifier_list
;
230 unsigned int const_qualifier
;
233 struct bt_list_head pointers
;
236 TYPEDEC_ID
, /* identifier */
237 TYPEDEC_NESTED
, /* (), array or sequence */
242 /* typedec has no pointer list */
243 struct ctf_node
*type_declarator
;
245 * unary expression (value) or
246 * type_specifier_list.
248 struct bt_list_head length
;
249 /* for abstract type declarator */
250 unsigned int abstract_array
;
253 struct ctf_node
*bitfield_len
;
256 /* Children nodes are ctf_expression. */
257 struct bt_list_head expressions
;
260 /* Children nodes are ctf_expression. */
261 struct bt_list_head expressions
;
264 /* Children nodes are ctf_expression. */
265 struct bt_list_head expressions
;
270 * Range list or single value node. Contains unary
273 struct bt_list_head values
;
278 * Either NULL, or points to unary expression or
279 * type_specifier_list.
281 struct ctf_node
*container_type
;
282 struct bt_list_head enumerator_list
;
286 struct ctf_node
*type_specifier_list
;
287 struct bt_list_head type_declarators
;
288 } struct_or_variant_declaration
;
292 /* list of typedef, typealias and declarations */
293 struct bt_list_head declaration_list
;
298 /* list of typedef, typealias and declarations */
299 struct bt_list_head declaration_list
;
301 struct bt_list_head min_align
; /* align() attribute */
307 struct ctf_node root
;
310 const char *node_type(struct ctf_node
*node
);
313 struct ctf_visitor_generate_ir
*ctf_visitor_generate_ir_create(
314 const struct ctf_metadata_decoder_config
*config
,
317 void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir
*visitor
);
320 struct bt_trace
*ctf_visitor_generate_ir_get_trace(
321 struct ctf_visitor_generate_ir
*visitor
);
324 int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir
*visitor
,
325 struct ctf_node
*node
);
328 int ctf_visitor_semantic_check(int depth
, struct ctf_node
*node
);
331 int ctf_visitor_parent_links(int depth
, struct ctf_node
*node
);
333 #endif /* _CTF_AST_H */