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.h>
25 // the parameter name (of the reentrant 'yyparse' function)
26 // data is a pointer to a 'SParserParam' structure
27 //#define YYPARSE_PARAM scanner
32 #define FOREACH_CTF_NODES(F) \
42 F(NODE_CTF_EXPRESSION) \
43 F(NODE_UNARY_EXPRESSION) \
45 F(NODE_TYPEALIAS_TARGET) \
46 F(NODE_TYPEALIAS_ALIAS) \
48 F(NODE_TYPE_SPECIFIER) \
49 F(NODE_TYPE_SPECIFIER_LIST) \
51 F(NODE_TYPE_DECLARATOR) \
52 F(NODE_FLOATING_POINT) \
57 F(NODE_STRUCT_OR_VARIANT_DECLARATION) \
63 FOREACH_CTF_NODES(ENTRY
)
70 * Parent node is only set on demand by specific visitor.
72 struct ctf_node
*parent
;
73 struct bt_list_head siblings
;
74 struct bt_list_head tmp_head
;
77 * We mark nodes visited in the generate-io-struct phase (last
78 * phase). We only mark the 1-depth level nodes as visited
79 * (never the root node, and not their sub-nodes). This allows
80 * skipping already visited nodes when doing incremental
91 * Children nodes are ctf_expression, typedef,
92 * typealias and type_specifier_list.
94 struct bt_list_head declaration_list
;
95 struct bt_list_head trace
;
96 struct bt_list_head env
;
97 struct bt_list_head stream
;
98 struct bt_list_head event
;
99 struct bt_list_head clock
;
100 struct bt_list_head callsite
;
104 * Children nodes are ctf_expression, typedef,
105 * typealias and type_specifier_list.
107 struct bt_list_head declaration_list
;
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
;
145 struct bt_list_head left
; /* Should be string */
146 struct bt_list_head right
; /* Unary exp. or type */
152 UNARY_SIGNED_CONSTANT
,
153 UNARY_UNSIGNED_CONSTANT
,
158 * string for identifier, id_type, keywords,
159 * string literals and character constants.
162 int64_t signed_constant
;
163 uint64_t unsigned_constant
;
164 struct ctf_node
*sbrac_exp
;
167 UNARY_LINK_UNKNOWN
= 0,
174 struct ctf_node
*type_specifier_list
;
175 struct bt_list_head type_declarators
;
177 /* new type is "alias", existing type "target" */
179 struct ctf_node
*type_specifier_list
;
180 struct bt_list_head type_declarators
;
183 struct ctf_node
*type_specifier_list
;
184 struct bt_list_head type_declarators
;
187 struct ctf_node
*target
;
188 struct ctf_node
*alias
;
192 TYPESPEC_UNKNOWN
= 0,
207 TYPESPEC_FLOATING_POINT
,
214 /* For struct, variant and enum */
215 struct ctf_node
*node
;
219 /* list of type_specifier */
220 struct bt_list_head head
;
221 } type_specifier_list
;
223 unsigned int const_qualifier
;
226 struct bt_list_head pointers
;
229 TYPEDEC_ID
, /* identifier */
230 TYPEDEC_NESTED
, /* (), array or sequence */
235 /* typedec has no pointer list */
236 struct ctf_node
*type_declarator
;
238 * unary expression (value) or
239 * type_specifier_list.
241 struct bt_list_head length
;
242 /* for abstract type declarator */
243 unsigned int abstract_array
;
246 struct ctf_node
*bitfield_len
;
249 /* Children nodes are ctf_expression. */
250 struct bt_list_head expressions
;
253 /* Children nodes are ctf_expression. */
254 struct bt_list_head expressions
;
257 /* Children nodes are ctf_expression. */
258 struct bt_list_head expressions
;
263 * Range list or single value node. Contains unary
266 struct bt_list_head values
;
271 * Either NULL, or points to unary expression or
272 * type_specifier_list.
274 struct ctf_node
*container_type
;
275 struct bt_list_head enumerator_list
;
279 struct ctf_node
*type_specifier_list
;
280 struct bt_list_head type_declarators
;
281 } struct_or_variant_declaration
;
285 /* list of typedef, typealias and declarations */
286 struct bt_list_head declaration_list
;
291 /* list of typedef, typealias and declarations */
292 struct bt_list_head declaration_list
;
294 struct bt_list_head min_align
; /* align() attribute */
300 struct ctf_node root
;
303 const char *node_type(struct ctf_node
*node
);
308 int ctf_visitor_print_xml(FILE *fd
, int depth
, struct ctf_node
*node
);
310 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
312 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
314 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
315 struct ctf_trace
*trace
, int byte_order
);
317 int ctf_destroy_metadata(struct ctf_trace
*trace
);
319 #endif /* _CTF_AST_H */