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
;
83 * Children nodes are ctf_expression, typedef,
84 * typealias and type_specifier_list.
86 struct bt_list_head declaration_list
;
87 struct bt_list_head trace
;
88 struct bt_list_head env
;
89 struct bt_list_head stream
;
90 struct bt_list_head event
;
91 struct bt_list_head clock
;
92 struct bt_list_head callsite
;
96 * Children nodes are ctf_expression, typedef,
97 * typealias and type_specifier_list.
99 struct bt_list_head declaration_list
;
103 * Children nodes are ctf_expression, typedef,
104 * typealias and type_specifier_list.
106 struct bt_list_head declaration_list
;
110 * Children nodes are ctf_expression, typedef,
111 * typealias and type_specifier_list.
113 struct bt_list_head declaration_list
;
117 * Children nodes are ctf_expression, typedef,
118 * typealias and type_specifier_list.
120 struct bt_list_head declaration_list
;
124 * Children nodes are ctf_expression, typedef,
125 * typealias and type_specifier_list.
127 struct bt_list_head declaration_list
;
131 * Children nodes are ctf_expression, typedef,
132 * typealias and type_specifier_list.
134 struct bt_list_head declaration_list
;
137 struct bt_list_head left
; /* Should be string */
138 struct bt_list_head right
; /* Unary exp. or type */
144 UNARY_SIGNED_CONSTANT
,
145 UNARY_UNSIGNED_CONSTANT
,
150 * string for identifier, id_type, keywords,
151 * string literals and character constants.
154 int64_t signed_constant
;
155 uint64_t unsigned_constant
;
156 struct ctf_node
*sbrac_exp
;
159 UNARY_LINK_UNKNOWN
= 0,
166 struct ctf_node
*type_specifier_list
;
167 struct bt_list_head type_declarators
;
169 /* new type is "alias", existing type "target" */
171 struct ctf_node
*type_specifier_list
;
172 struct bt_list_head type_declarators
;
175 struct ctf_node
*type_specifier_list
;
176 struct bt_list_head type_declarators
;
179 struct ctf_node
*target
;
180 struct ctf_node
*alias
;
184 TYPESPEC_UNKNOWN
= 0,
199 TYPESPEC_FLOATING_POINT
,
206 /* For struct, variant and enum */
207 struct ctf_node
*node
;
211 /* list of type_specifier */
212 struct bt_list_head head
;
213 } type_specifier_list
;
215 unsigned int const_qualifier
;
218 struct bt_list_head pointers
;
221 TYPEDEC_ID
, /* identifier */
222 TYPEDEC_NESTED
, /* (), array or sequence */
227 /* typedec has no pointer list */
228 struct ctf_node
*type_declarator
;
230 * unary expression (value) or
231 * type_specifier_list.
233 struct bt_list_head length
;
234 /* for abstract type declarator */
235 unsigned int abstract_array
;
238 struct ctf_node
*bitfield_len
;
241 /* Children nodes are ctf_expression. */
242 struct bt_list_head expressions
;
245 /* Children nodes are ctf_expression. */
246 struct bt_list_head expressions
;
249 /* Children nodes are ctf_expression. */
250 struct bt_list_head expressions
;
255 * Range list or single value node. Contains unary
258 struct bt_list_head values
;
263 * Either NULL, or points to unary expression or
264 * type_specifier_list.
266 struct ctf_node
*container_type
;
267 struct bt_list_head enumerator_list
;
271 struct ctf_node
*type_specifier_list
;
272 struct bt_list_head type_declarators
;
273 } struct_or_variant_declaration
;
277 /* list of typedef, typealias and declarations */
278 struct bt_list_head declaration_list
;
283 /* list of typedef, typealias and declarations */
284 struct bt_list_head declaration_list
;
286 struct bt_list_head min_align
; /* align() attribute */
292 struct ctf_node root
;
295 const char *node_type(struct ctf_node
*node
);
300 int ctf_visitor_print_xml(FILE *fd
, int depth
, struct ctf_node
*node
);
302 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
304 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
306 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
307 struct ctf_trace
*trace
, int byte_order
);
309 int ctf_destroy_metadata(struct ctf_trace
*trace
);
311 #endif /* _CTF_AST_H */