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/ctf-ir/trace.h>
25 #include <babeltrace/babeltrace-internal.h>
27 // the parameter name (of the reentrant 'yyparse' function)
28 // data is a pointer to a 'SParserParam' structure
29 //#define YYPARSE_PARAM scanner
33 struct ctf_visitor_generate_ir
;
35 #define EINCOMPLETE 1000
37 #define FOREACH_CTF_NODES(F) \
47 F(NODE_CTF_EXPRESSION) \
48 F(NODE_UNARY_EXPRESSION) \
50 F(NODE_TYPEALIAS_TARGET) \
51 F(NODE_TYPEALIAS_ALIAS) \
53 F(NODE_TYPE_SPECIFIER) \
54 F(NODE_TYPE_SPECIFIER_LIST) \
56 F(NODE_TYPE_DECLARATOR) \
57 F(NODE_FLOATING_POINT) \
62 F(NODE_STRUCT_OR_VARIANT_DECLARATION) \
68 FOREACH_CTF_NODES(ENTRY
)
75 * Parent node is only set on demand by specific visitor.
77 struct ctf_node
*parent
;
78 struct bt_list_head siblings
;
79 struct bt_list_head tmp_head
;
82 * We mark nodes visited in the generate-ir phase (last
83 * phase). We only mark the 1-depth level nodes as visited
84 * (never the root node, and not their sub-nodes). This allows
85 * skipping already visited nodes when doing incremental
96 * Children nodes are ctf_expression, typedef,
97 * typealias and type_specifier_list.
99 struct bt_list_head declaration_list
;
100 struct bt_list_head trace
;
101 struct bt_list_head env
;
102 struct bt_list_head stream
;
103 struct bt_list_head event
;
104 struct bt_list_head clock
;
105 struct bt_list_head callsite
;
109 * Children nodes are ctf_expression, typedef,
110 * typealias and type_specifier_list.
112 struct bt_list_head declaration_list
;
116 * Children nodes are ctf_expression, typedef,
117 * typealias and type_specifier_list.
119 struct bt_list_head declaration_list
;
123 * Children nodes are ctf_expression, typedef,
124 * typealias and type_specifier_list.
126 struct bt_list_head declaration_list
;
130 * Children nodes are ctf_expression, typedef,
131 * typealias and type_specifier_list.
133 struct bt_list_head declaration_list
;
137 * Children nodes are ctf_expression, typedef,
138 * typealias and type_specifier_list.
140 struct bt_list_head declaration_list
;
144 * Children nodes are ctf_expression, typedef,
145 * typealias and type_specifier_list.
147 struct bt_list_head declaration_list
;
150 struct bt_list_head left
; /* Should be string */
151 struct bt_list_head right
; /* Unary exp. or type */
157 UNARY_SIGNED_CONSTANT
,
158 UNARY_UNSIGNED_CONSTANT
,
163 * string for identifier, id_type, keywords,
164 * string literals and character constants.
167 int64_t signed_constant
;
168 uint64_t unsigned_constant
;
169 struct ctf_node
*sbrac_exp
;
172 UNARY_LINK_UNKNOWN
= 0,
179 struct ctf_node
*type_specifier_list
;
180 struct bt_list_head type_declarators
;
182 /* new type is "alias", existing type "target" */
184 struct ctf_node
*type_specifier_list
;
185 struct bt_list_head type_declarators
;
188 struct ctf_node
*type_specifier_list
;
189 struct bt_list_head type_declarators
;
192 struct ctf_node
*target
;
193 struct ctf_node
*alias
;
197 TYPESPEC_UNKNOWN
= 0,
212 TYPESPEC_FLOATING_POINT
,
219 /* For struct, variant and enum */
220 struct ctf_node
*node
;
224 /* list of type_specifier */
225 struct bt_list_head head
;
226 } type_specifier_list
;
228 unsigned int const_qualifier
;
231 struct bt_list_head pointers
;
234 TYPEDEC_ID
, /* identifier */
235 TYPEDEC_NESTED
, /* (), array or sequence */
240 /* typedec has no pointer list */
241 struct ctf_node
*type_declarator
;
243 * unary expression (value) or
244 * type_specifier_list.
246 struct bt_list_head length
;
247 /* for abstract type declarator */
248 unsigned int abstract_array
;
251 struct ctf_node
*bitfield_len
;
254 /* Children nodes are ctf_expression. */
255 struct bt_list_head expressions
;
258 /* Children nodes are ctf_expression. */
259 struct bt_list_head expressions
;
262 /* Children nodes are ctf_expression. */
263 struct bt_list_head expressions
;
268 * Range list or single value node. Contains unary
271 struct bt_list_head values
;
276 * Either NULL, or points to unary expression or
277 * type_specifier_list.
279 struct ctf_node
*container_type
;
280 struct bt_list_head enumerator_list
;
284 struct ctf_node
*type_specifier_list
;
285 struct bt_list_head type_declarators
;
286 } struct_or_variant_declaration
;
290 /* list of typedef, typealias and declarations */
291 struct bt_list_head declaration_list
;
296 /* list of typedef, typealias and declarations */
297 struct bt_list_head declaration_list
;
299 struct bt_list_head min_align
; /* align() attribute */
305 struct ctf_node root
;
308 const char *node_type(struct ctf_node
*node
);
311 struct ctf_visitor_generate_ir
*ctf_visitor_generate_ir_create(FILE *efd
,
312 uint64_t clock_class_offset_ns
);
314 void ctf_visitor_generate_ir_destroy(struct ctf_visitor_generate_ir
*visitor
);
317 struct bt_ctf_trace
*ctf_visitor_generate_ir_get_trace(
318 struct ctf_visitor_generate_ir
*visitor
);
321 int ctf_visitor_generate_ir_visit_node(struct ctf_visitor_generate_ir
*visitor
,
322 struct ctf_node
*node
);
325 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
328 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
330 #endif /* _CTF_AST_H */