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>
24 #include <babeltrace/ctf-ir/trace.h>
26 // the parameter name (of the reentrant 'yyparse' function)
27 // data is a pointer to a 'SParserParam' structure
28 //#define YYPARSE_PARAM scanner
33 #define FOREACH_CTF_NODES(F) \
43 F(NODE_CTF_EXPRESSION) \
44 F(NODE_UNARY_EXPRESSION) \
46 F(NODE_TYPEALIAS_TARGET) \
47 F(NODE_TYPEALIAS_ALIAS) \
49 F(NODE_TYPE_SPECIFIER) \
50 F(NODE_TYPE_SPECIFIER_LIST) \
52 F(NODE_TYPE_DECLARATOR) \
53 F(NODE_FLOATING_POINT) \
58 F(NODE_STRUCT_OR_VARIANT_DECLARATION) \
64 FOREACH_CTF_NODES(ENTRY
)
71 * Parent node is only set on demand by specific visitor.
73 struct ctf_node
*parent
;
74 struct bt_list_head siblings
;
75 struct bt_list_head tmp_head
;
78 * We mark nodes visited in the generate-ir phase (last
79 * phase). We only mark the 1-depth level nodes as visited
80 * (never the root node, and not their sub-nodes). This allows
81 * skipping already visited nodes when doing incremental
92 * Children nodes are ctf_expression, typedef,
93 * typealias and type_specifier_list.
95 struct bt_list_head declaration_list
;
96 struct bt_list_head trace
;
97 struct bt_list_head env
;
98 struct bt_list_head stream
;
99 struct bt_list_head event
;
100 struct bt_list_head clock
;
101 struct bt_list_head callsite
;
105 * Children nodes are ctf_expression, typedef,
106 * typealias and type_specifier_list.
108 struct bt_list_head declaration_list
;
112 * Children nodes are ctf_expression, typedef,
113 * typealias and type_specifier_list.
115 struct bt_list_head declaration_list
;
119 * Children nodes are ctf_expression, typedef,
120 * typealias and type_specifier_list.
122 struct bt_list_head declaration_list
;
126 * Children nodes are ctf_expression, typedef,
127 * typealias and type_specifier_list.
129 struct bt_list_head declaration_list
;
133 * Children nodes are ctf_expression, typedef,
134 * typealias and type_specifier_list.
136 struct bt_list_head declaration_list
;
140 * Children nodes are ctf_expression, typedef,
141 * typealias and type_specifier_list.
143 struct bt_list_head declaration_list
;
146 struct bt_list_head left
; /* Should be string */
147 struct bt_list_head right
; /* Unary exp. or type */
153 UNARY_SIGNED_CONSTANT
,
154 UNARY_UNSIGNED_CONSTANT
,
159 * string for identifier, id_type, keywords,
160 * string literals and character constants.
163 int64_t signed_constant
;
164 uint64_t unsigned_constant
;
165 struct ctf_node
*sbrac_exp
;
168 UNARY_LINK_UNKNOWN
= 0,
175 struct ctf_node
*type_specifier_list
;
176 struct bt_list_head type_declarators
;
178 /* new type is "alias", existing type "target" */
180 struct ctf_node
*type_specifier_list
;
181 struct bt_list_head type_declarators
;
184 struct ctf_node
*type_specifier_list
;
185 struct bt_list_head type_declarators
;
188 struct ctf_node
*target
;
189 struct ctf_node
*alias
;
193 TYPESPEC_UNKNOWN
= 0,
208 TYPESPEC_FLOATING_POINT
,
215 /* For struct, variant and enum */
216 struct ctf_node
*node
;
220 /* list of type_specifier */
221 struct bt_list_head head
;
222 } type_specifier_list
;
224 unsigned int const_qualifier
;
227 struct bt_list_head pointers
;
230 TYPEDEC_ID
, /* identifier */
231 TYPEDEC_NESTED
, /* (), array or sequence */
236 /* typedec has no pointer list */
237 struct ctf_node
*type_declarator
;
239 * unary expression (value) or
240 * type_specifier_list.
242 struct bt_list_head length
;
243 /* for abstract type declarator */
244 unsigned int abstract_array
;
247 struct ctf_node
*bitfield_len
;
250 /* Children nodes are ctf_expression. */
251 struct bt_list_head expressions
;
254 /* Children nodes are ctf_expression. */
255 struct bt_list_head expressions
;
258 /* Children nodes are ctf_expression. */
259 struct bt_list_head expressions
;
264 * Range list or single value node. Contains unary
267 struct bt_list_head values
;
272 * Either NULL, or points to unary expression or
273 * type_specifier_list.
275 struct ctf_node
*container_type
;
276 struct bt_list_head enumerator_list
;
280 struct ctf_node
*type_specifier_list
;
281 struct bt_list_head type_declarators
;
282 } struct_or_variant_declaration
;
286 /* list of typedef, typealias and declarations */
287 struct bt_list_head declaration_list
;
292 /* list of typedef, typealias and declarations */
293 struct bt_list_head declaration_list
;
295 struct bt_list_head min_align
; /* align() attribute */
301 struct ctf_node root
;
304 const char *node_type(struct ctf_node
*node
);
309 int ctf_visitor_generate_ir(FILE *efd
, struct ctf_node
*node
,
310 struct bt_ctf_trace
**trace
, uint64_t clock_offset_ns
);
313 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
316 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
319 int ctf_destroy_metadata(struct ctf_trace
*trace
);
321 #endif /* _CTF_AST_H */