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>
30 // the parameter name (of the reentrant 'yyparse' function)
31 // data is a pointer to a 'SParserParam' structure
32 //#define YYPARSE_PARAM scanner
36 struct ctf_visitor_generate_ir
;
38 #define EINCOMPLETE 1000
40 #define FOREACH_CTF_NODES(F) \
50 F(NODE_CTF_EXPRESSION) \
51 F(NODE_UNARY_EXPRESSION) \
53 F(NODE_TYPEALIAS_TARGET) \
54 F(NODE_TYPEALIAS_ALIAS) \
56 F(NODE_TYPE_SPECIFIER) \
57 F(NODE_TYPE_SPECIFIER_LIST) \
59 F(NODE_TYPE_DECLARATOR) \
60 F(NODE_FLOATING_POINT) \
65 F(NODE_STRUCT_OR_VARIANT_DECLARATION) \
71 FOREACH_CTF_NODES(ENTRY
)
78 * Parent node is only set on demand by specific visitor.
80 struct ctf_node
*parent
;
81 struct bt_list_head siblings
;
82 struct bt_list_head tmp_head
;
85 * We mark nodes visited in the generate-ir phase (last
86 * phase). We only mark the 1-depth level nodes as visited
87 * (never the root node, and not their sub-nodes). This allows
88 * skipping already visited nodes when doing incremental
99 * Children nodes are ctf_expression, field_class_def,
100 * field_class_alias and field_class_specifier_list.
102 struct bt_list_head declaration_list
;
103 struct bt_list_head trace
;
104 struct bt_list_head env
;
105 struct bt_list_head stream
;
106 struct bt_list_head event
;
107 struct bt_list_head clock
;
108 struct bt_list_head callsite
;
112 * Children nodes are ctf_expression, field_class_def,
113 * field_class_alias and field_class_specifier_list.
115 struct bt_list_head declaration_list
;
119 * Children nodes are ctf_expression, field_class_def,
120 * field_class_alias and field_class_specifier_list.
122 struct bt_list_head declaration_list
;
126 * Children nodes are ctf_expression, field_class_def,
127 * field_class_alias and field_class_specifier_list.
129 struct bt_list_head declaration_list
;
133 * Children nodes are ctf_expression, field_class_def,
134 * field_class_alias and field_class_specifier_list.
136 struct bt_list_head declaration_list
;
140 * Children nodes are ctf_expression, field_class_def,
141 * field_class_alias and field_class_specifier_list.
143 struct bt_list_head declaration_list
;
147 * Children nodes are ctf_expression, field_class_def,
148 * field_class_alias and field_class_specifier_list.
150 struct bt_list_head declaration_list
;
153 struct bt_list_head left
; /* Should be string */
154 struct bt_list_head right
; /* Unary exp. or type */
160 UNARY_SIGNED_CONSTANT
,
161 UNARY_UNSIGNED_CONSTANT
,
166 * string for identifier, id_type, keywords,
167 * string literals and character constants.
170 int64_t signed_constant
;
171 uint64_t unsigned_constant
;
172 struct ctf_node
*sbrac_exp
;
175 UNARY_LINK_UNKNOWN
= 0,
182 struct ctf_node
*field_class_specifier_list
;
183 struct bt_list_head field_class_declarators
;
185 /* new type is "alias", existing type "target" */
187 struct ctf_node
*field_class_specifier_list
;
188 struct bt_list_head field_class_declarators
;
189 } field_class_alias_target
;
191 struct ctf_node
*field_class_specifier_list
;
192 struct bt_list_head field_class_declarators
;
193 } field_class_alias_name
;
195 struct ctf_node
*target
;
196 struct ctf_node
*alias
;
200 TYPESPEC_UNKNOWN
= 0,
215 TYPESPEC_FLOATING_POINT
,
222 /* For struct, variant and enum */
223 struct ctf_node
*node
;
225 } field_class_specifier
;
227 /* list of field_class_specifier */
228 struct bt_list_head head
;
229 } field_class_specifier_list
;
231 unsigned int const_qualifier
;
234 struct bt_list_head pointers
;
237 TYPEDEC_ID
, /* identifier */
238 TYPEDEC_NESTED
, /* (), array or sequence */
243 /* typedec has no pointer list */
244 struct ctf_node
*field_class_declarator
;
246 * unary expression (value) or
247 * field_class_specifier_list.
249 struct bt_list_head length
;
250 /* for abstract type declarator */
251 unsigned int abstract_array
;
254 struct ctf_node
*bitfield_len
;
255 } field_class_declarator
;
257 /* Children nodes are ctf_expression. */
258 struct bt_list_head expressions
;
261 /* Children nodes are ctf_expression. */
262 struct bt_list_head expressions
;
265 /* Children nodes are ctf_expression. */
266 struct bt_list_head expressions
;
271 * Range list or single value node. Contains unary
274 struct bt_list_head values
;
279 * Either NULL, or points to unary expression or
280 * field_class_specifier_list.
282 struct ctf_node
*container_field_class
;
283 struct bt_list_head enumerator_list
;
287 struct ctf_node
*field_class_specifier_list
;
288 struct bt_list_head field_class_declarators
;
289 } struct_or_variant_declaration
;
294 * list of field_class_def, field_class_alias and
297 struct bt_list_head declaration_list
;
303 * list of field_class_def, field_class_alias and
306 struct bt_list_head declaration_list
;
308 struct bt_list_head min_align
; /* align() attribute */
314 struct ctf_node root
;
317 const char *node_type(struct ctf_node
*node
);
320 struct ctf_visitor_generate_ir
*ctf_visitor_generate_ir_create(
321 const struct ctf_metadata_decoder_config
*config
);
323 void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir
*visitor
);
326 bt_trace_class
*ctf_visitor_generate_ir_get_ir_trace_class(
327 struct ctf_visitor_generate_ir
*visitor
);
330 struct ctf_trace_class
*ctf_visitor_generate_ir_borrow_ctf_trace_class(
331 struct ctf_visitor_generate_ir
*visitor
);
334 int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir
*visitor
,
335 struct ctf_node
*node
);
338 int ctf_visitor_semantic_check(int depth
, struct ctf_node
*node
);
341 int ctf_visitor_parent_links(int depth
, struct ctf_node
*node
);
343 #endif /* _CTF_AST_H */