X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-parent-links.c;h=104afb717ddad5e78fb2dcbe87c9dabc0c0fb3eb;hp=44e2031535839ff3d9fac0e707dfa737e22b8715;hb=104147cd176d0b6f635777f34a7df15a33a45c15;hpb=67905e421502703d87176702b4844f70fd60ded4 diff --git a/formats/ctf/metadata/ctf-visitor-parent-links.c b/formats/ctf/metadata/ctf-visitor-parent-links.c index 44e20315..104afb71 100644 --- a/formats/ctf/metadata/ctf-visitor-parent-links.c +++ b/formats/ctf/metadata/ctf-visitor-parent-links.c @@ -14,6 +14,14 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ #include @@ -24,12 +32,13 @@ #include #include #include +#include #include #include "ctf-scanner.h" #include "ctf-parser.h" #include "ctf-ast.h" -#define printf_dbg(fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args) +#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args) static int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) @@ -60,13 +69,6 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) if (ret) return ret; break; - case UNARY_NESTED: - node->u.unary_expression.u.nested_exp->parent = node; - ret = ctf_visitor_unary_expression(fd, depth + 1, - node->u.unary_expression.u.nested_exp); - if (ret) - return ret; - break; case UNARY_UNKNOWN: default: @@ -80,6 +82,8 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) static int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) { + int ret; + switch (node->u.type_specifier.type) { case TYPESPEC_VOID: case TYPESPEC_CHAR: @@ -92,9 +96,21 @@ int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node) case TYPESPEC_UNSIGNED: case TYPESPEC_BOOL: case TYPESPEC_COMPLEX: + case TYPESPEC_IMAGINARY: case TYPESPEC_CONST: case TYPESPEC_ID_TYPE: break; + case TYPESPEC_FLOATING_POINT: + case TYPESPEC_INTEGER: + case TYPESPEC_STRING: + case TYPESPEC_STRUCT: + case TYPESPEC_VARIANT: + case TYPESPEC_ENUM: + node->u.type_specifier.node->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, node->u.type_specifier.node); + if (ret) + return ret; + break; case TYPESPEC_UNKNOWN: default: @@ -113,14 +129,12 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) depth++; - if (!cds_list_empty(&node->u.type_declarator.pointers)) { - cds_list_for_each_entry(iter, &node->u.type_declarator.pointers, - siblings) { - iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); - if (ret) - return ret; - } + bt_list_for_each_entry(iter, &node->u.type_declarator.pointers, + siblings) { + iter->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, iter); + if (ret) + return ret; } switch (node->u.type_declarator.type) { @@ -134,12 +148,14 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node) if (ret) return ret; } - if (node->u.type_declarator.u.nested.length) { - node->u.type_declarator.u.nested.length->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, - node->u.type_declarator.u.nested.length); - if (ret) - return ret; + if (!node->u.type_declarator.u.nested.abstract_array) { + bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length, + siblings) { + iter->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, iter); + if (ret) + return ret; + } } if (node->u.type_declarator.bitfield_len) { node->u.type_declarator.bitfield_len = node; @@ -166,39 +182,37 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) switch (node->type) { case NODE_ROOT: - cds_list_for_each_entry(iter, &node->u.root._typedef, - siblings) { + bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.root.typealias, - siblings) { + bt_list_for_each_entry(iter, &node->u.root.trace, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.root.declaration_specifier, siblings) { + bt_list_for_each_entry(iter, &node->u.root.stream, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.root.trace, siblings) { + bt_list_for_each_entry(iter, &node->u.root.event, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.root.stream, siblings) { + bt_list_for_each_entry(iter, &node->u.root.clock, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.root.event, siblings) { + bt_list_for_each_entry(iter, &node->u.root.callsite, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -207,7 +221,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) break; case NODE_EVENT: - cds_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { + bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -215,7 +229,15 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_STREAM: - cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { + bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) { + iter->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, iter); + if (ret) + return ret; + } + break; + case NODE_ENV: + bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -223,42 +245,39 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_TRACE: - cds_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { + bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } break; - - case NODE_CTF_EXPRESSION: - depth++; - cds_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) { + case NODE_CLOCK: + bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) { + break; + case NODE_CALLSITE: + bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - depth--; break; - case NODE_UNARY_EXPRESSION: - return ctf_visitor_unary_expression(fd, depth, node); - case NODE_TYPEDEF: + case NODE_CTF_EXPRESSION: depth++; - cds_list_for_each_entry(iter, &node->u._typedef.declaration_specifier, siblings) { + bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) { + bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -266,15 +285,30 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } depth--; break; - case NODE_TYPEALIAS_TARGET: + case NODE_UNARY_EXPRESSION: + return ctf_visitor_unary_expression(fd, depth, node); + + case NODE_TYPEDEF: depth++; - cds_list_for_each_entry(iter, &node->u.typealias_target.declaration_specifier, siblings) { + node->u._typedef.type_specifier_list->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, node->u._typedef.type_specifier_list); + if (ret) + return ret; + bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) { + depth--; + break; + case NODE_TYPEALIAS_TARGET: + depth++; + node->u.typealias_target.type_specifier_list->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, node->u.typealias_target.type_specifier_list); + if (ret) + return ret; + bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -284,13 +318,11 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) break; case NODE_TYPEALIAS_ALIAS: depth++; - cds_list_for_each_entry(iter, &node->u.typealias_alias.declaration_specifier, siblings) { - iter->parent = node; - ret = ctf_visitor_parent_links(fd, depth + 1, iter); - if (ret) - return ret; - } - cds_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) { + node->u.typealias_alias.type_specifier_list->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, node->u.typealias_alias.type_specifier_list); + if (ret) + return ret; + bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -309,6 +341,15 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) return ret; break; + case NODE_TYPE_SPECIFIER_LIST: + bt_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) { + iter->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, iter); + if (ret) + return ret; + } + break; + case NODE_TYPE_SPECIFIER: ret = ctf_visitor_type_specifier(fd, depth, node); if (ret) @@ -323,7 +364,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) break; case NODE_FLOATING_POINT: - cds_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) { + bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -331,7 +372,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_INTEGER: - cds_list_for_each_entry(iter, &node->u.integer.expressions, siblings) { + bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -339,7 +380,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_STRING: - cds_list_for_each_entry(iter, &node->u.string.expressions, siblings) { + bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -347,10 +388,7 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_ENUMERATOR: - if (node->u.enumerator.id) - fprintf(fd, " id=\"%s\"", node->u.enumerator.id); - fprintf(fd, ">\n"); - cds_list_for_each_entry(iter, &node->u.enumerator.values, siblings) { + bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -358,21 +396,14 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) } break; case NODE_ENUM: - if (node->u._struct.name) - fprintf(fd, "\n", - node->u._enum.enum_id); - else - fprintf(fd, "\n"); depth++; - if (node->u._enum.container_type) { - node->u._enum.container_type->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, node->u._enum.container_type); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { + bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) @@ -381,31 +412,35 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) depth--; break; case NODE_STRUCT_OR_VARIANT_DECLARATION: - cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.declaration_specifier, siblings) { + node->u.struct_or_variant_declaration.type_specifier_list->parent = node; + ret = ctf_visitor_parent_links(fd, depth + 1, + node->u.struct_or_variant_declaration.type_specifier_list); + if (ret) + return ret; + bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) { + break; + case NODE_VARIANT: + bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } break; - case NODE_VARIANT: - if (node->u.variant.choice) - fprintf(fd, " choice=\"%s\"", node->u.variant.choice); - cds_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) { + case NODE_STRUCT: + bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret) return ret; } - break; - case NODE_STRUCT: - cds_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) { + bt_list_for_each_entry(iter, &node->u._struct.min_align, + siblings) { iter->parent = node; ret = ctf_visitor_parent_links(fd, depth + 1, iter); if (ret)