[ NODE_TYPEALIAS_ALIAS ] = "NODE_TYPEALIAS_ALIAS",
[ NODE_TYPEALIAS ] = "NODE_TYPEALIAS",
[ NODE_TYPE_SPECIFIER ] = "NODE_TYPE_SPECIFIER",
+ [ NODE_TYPE_SPECIFIER_LIST ] = "NODE_TYPE_SPECIFIER_LIST",
[ NODE_POINTER ] = "NODE_POINTER",
[ NODE_TYPE_DECLARATOR ] = "NODE_TYPE_DECLARATOR",
[ NODE_FLOATING_POINT ] = "NODE_FLOATING_POINT",
break;
case NODE_TYPEDEF:
- CDS_INIT_LIST_HEAD(&node->u._typedef.declaration_specifier);
CDS_INIT_LIST_HEAD(&node->u._typedef.type_declarators);
break;
case NODE_TYPEALIAS_TARGET:
- CDS_INIT_LIST_HEAD(&node->u.typealias_target.declaration_specifier);
CDS_INIT_LIST_HEAD(&node->u.typealias_target.type_declarators);
break;
case NODE_TYPEALIAS_ALIAS:
- CDS_INIT_LIST_HEAD(&node->u.typealias_alias.declaration_specifier);
CDS_INIT_LIST_HEAD(&node->u.typealias_alias.type_declarators);
break;
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
break;
+ case NODE_TYPE_SPECIFIER_LIST:
+ CDS_INIT_LIST_HEAD(&node->u.type_specifier_list.head);
+ break;
case NODE_POINTER:
break;
case NODE_TYPE_DECLARATOR:
CDS_INIT_LIST_HEAD(&node->u.enumerator.values);
break;
case NODE_ENUM:
- CDS_INIT_LIST_HEAD(&node->u._enum.container_type);
CDS_INIT_LIST_HEAD(&node->u._enum.enumerator_list);
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- CDS_INIT_LIST_HEAD(&node->u.struct_or_variant_declaration.declaration_specifier);
CDS_INIT_LIST_HEAD(&node->u.struct_or_variant_declaration.type_declarators);
break;
case NODE_VARIANT:
case NODE_TYPEALIAS_ALIAS:
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_TYPE_DECLARATOR:
case NODE_ENUMERATOR:
{
switch (parent->type) {
case NODE_ROOT:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.root._typedef);
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_list);
break;
case NODE_EVENT:
_cds_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list);
case NODE_TYPEALIAS_ALIAS:
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_TYPE_DECLARATOR:
case NODE_ENUMERATOR:
{
switch (parent->type) {
case NODE_ROOT:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.root.typealias);
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_list);
break;
case NODE_EVENT:
_cds_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list);
case NODE_TYPEALIAS_ALIAS:
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_TYPE_DECLARATOR:
case NODE_ENUMERATOR:
static int reparent_type_specifier(struct ctf_node *node,
struct ctf_node *parent)
+{
+ switch (parent->type) {
+ case NODE_TYPE_SPECIFIER_LIST:
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.type_specifier_list.head);
+ break;
+
+ case NODE_TYPE_SPECIFIER:
+ case NODE_EVENT:
+ case NODE_STREAM:
+ case NODE_TRACE:
+ case NODE_VARIANT:
+ case NODE_STRUCT:
+ case NODE_TYPEDEF:
+ case NODE_TYPEALIAS_TARGET:
+ case NODE_TYPEALIAS_ALIAS:
+ case NODE_TYPE_DECLARATOR:
+ case NODE_ENUM:
+ case NODE_STRUCT_OR_VARIANT_DECLARATION:
+ case NODE_TYPEALIAS:
+ case NODE_FLOATING_POINT:
+ case NODE_INTEGER:
+ case NODE_STRING:
+ case NODE_CTF_EXPRESSION:
+ case NODE_POINTER:
+ case NODE_ENUMERATOR:
+ case NODE_UNARY_EXPRESSION:
+ return -EPERM;
+
+ case NODE_UNKNOWN:
+ default:
+ fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
+ (int) parent->type);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int reparent_type_specifier_list(struct ctf_node *node,
+ struct ctf_node *parent)
{
switch (parent->type) {
case NODE_ROOT:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_specifier);
+ cds_list_add_tail(&node->siblings, &parent->u.root.declaration_list);
break;
case NODE_EVENT:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list);
+ cds_list_add_tail(&node->siblings, &parent->u.event.declaration_list);
break;
case NODE_STREAM:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
+ cds_list_add_tail(&node->siblings, &parent->u.stream.declaration_list);
break;
case NODE_TRACE:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
+ cds_list_add_tail(&node->siblings, &parent->u.trace.declaration_list);
break;
case NODE_VARIANT:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list);
+ cds_list_add_tail(&node->siblings, &parent->u.variant.declaration_list);
break;
case NODE_STRUCT:
- _cds_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list);
+ cds_list_add_tail(&node->siblings, &parent->u._struct.declaration_list);
break;
case NODE_TYPEDEF:
- _cds_list_splice_tail(&node->tmp_head, &parent->u._typedef.declaration_specifier);
+ parent->u._typedef.type_specifier_list = node;
break;
case NODE_TYPEALIAS_TARGET:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.typealias_target.declaration_specifier);
+ parent->u.typealias_target.type_specifier_list = node;
break;
case NODE_TYPEALIAS_ALIAS:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.typealias_alias.declaration_specifier);
+ parent->u.typealias_alias.type_specifier_list = node;
break;
case NODE_TYPE_DECLARATOR:
parent->u.type_declarator.type = TYPEDEC_NESTED;
- CDS_INIT_LIST_HEAD(&parent->u.type_declarator.u.nested.length);
- _cds_list_splice_tail(&node->tmp_head, &parent->u.type_declarator.u.nested.length);
+ parent->u.type_declarator.u.nested.length = node;
break;
case NODE_ENUM:
- _cds_list_splice_tail(&node->tmp_head, &parent->u._enum.container_type);
+ parent->u._enum.container_type = node;
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- _cds_list_splice_tail(&node->tmp_head, &parent->u.struct_or_variant_declaration.declaration_specifier);
+ parent->u.struct_or_variant_declaration.type_specifier_list = node;
break;
+ case NODE_TYPE_SPECIFIER:
case NODE_TYPEALIAS:
case NODE_FLOATING_POINT:
case NODE_INTEGER:
case NODE_STRING:
case NODE_CTF_EXPRESSION:
- case NODE_TYPE_SPECIFIER:
case NODE_POINTER:
case NODE_ENUMERATOR:
case NODE_UNARY_EXPRESSION:
case NODE_STRING:
case NODE_CTF_EXPRESSION:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_ENUMERATOR:
case NODE_UNARY_EXPRESSION:
case NODE_EVENT:
if (parent->type == NODE_ROOT) {
_cds_list_splice_tail(&node->tmp_head, &parent->u.root.event);
- } else
+ } else {
return -EPERM;
+ }
break;
case NODE_STREAM:
if (parent->type == NODE_ROOT) {
_cds_list_splice_tail(&node->tmp_head, &parent->u.root.stream);
- } else
+ } else {
return -EPERM;
+ }
break;
case NODE_TRACE:
if (parent->type == NODE_ROOT) {
_cds_list_splice_tail(&node->tmp_head, &parent->u.root.trace);
- } else
+ } else {
return -EPERM;
+ }
break;
case NODE_CTF_EXPRESSION:
case NODE_TYPE_DECLARATOR:
return reparent_type_declarator(node, parent);
+ case NODE_TYPE_SPECIFIER_LIST:
+ return reparent_type_specifier_list(node, parent);
+
case NODE_TYPE_SPECIFIER:
+ return reparent_type_specifier(node, parent);
+
case NODE_FLOATING_POINT:
case NODE_INTEGER:
case NODE_STRING:
case NODE_ENUM:
case NODE_VARIANT:
case NODE_STRUCT:
- return reparent_type_specifier(node, parent);
+ return -EINVAL; /* Dealt with internally within grammar */
case NODE_ENUMERATOR:
if (parent->type == NODE_ENUM) {
_cds_list_splice_tail(&node->tmp_head, &parent->u._enum.enumerator_list);
- } else
+ } else {
return -EPERM;
+ }
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
switch (parent->type) {
CDS_INIT_LIST_HEAD(&ast->allocated_nodes);
ast->root.type = NODE_ROOT;
CDS_INIT_LIST_HEAD(&ast->root.tmp_head);
- CDS_INIT_LIST_HEAD(&ast->root.u.root._typedef);
- CDS_INIT_LIST_HEAD(&ast->root.u.root.typealias);
- CDS_INIT_LIST_HEAD(&ast->root.u.root.declaration_specifier);
+ CDS_INIT_LIST_HEAD(&ast->root.u.root.declaration_list);
CDS_INIT_LIST_HEAD(&ast->root.u.root.trace);
CDS_INIT_LIST_HEAD(&ast->root.u.root.stream);
CDS_INIT_LIST_HEAD(&ast->root.u.root.event);
{ $$ = $1; }
| declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u._typedef.declaration_specifier);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u._typedef.type_specifier_list = list;
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _cds_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
}
| TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u._typedef.type_specifier_list = list;
+ _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
| declaration_specifiers TYPEDEF type_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u._typedef.type_specifier_list = list;
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
| TYPEALIAS declaration_specifiers abstract_declarator_list COLON alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEALIAS);
$$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
$$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u.typealias.target->u.typealias_target.declaration_specifier);
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
+ _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
- _cds_list_splice_tail(&($5)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.declaration_specifier);
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
+ _cds_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
}
;
declaration_specifiers:
CONST
{
- $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_CONST;
+ struct ctf_node *node;
+
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ node = make_node(scanner, NODE_TYPE_SPECIFIER);
+ node->u.type_specifier.type = TYPESPEC_CONST;
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
| type_specifier
- { $$ = $1; }
+ {
+ struct ctf_node *node;
+
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ node = $1;
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ }
| declaration_specifiers CONST
{
struct ctf_node *node;
$$ = $1;
node = make_node(scanner, NODE_TYPE_SPECIFIER);
node->u.type_specifier.type = TYPESPEC_CONST;
- cds_list_add_tail(&node->siblings, &($$)->tmp_head);
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
| declaration_specifiers type_specifier
{
$$ = $1;
- cds_list_add_tail(&($2)->siblings, &($$)->tmp_head);
+ cds_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
}
;
}
| FLOATING_POINT LBRAC RBRAC
{
- $$ = make_node(scanner, NODE_FLOATING_POINT);
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
+ $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
}
| FLOATING_POINT LBRAC ctf_assignment_expression_list RBRAC
{
- $$ = make_node(scanner, NODE_FLOATING_POINT);
- if (set_parent_node($3, $$))
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
+ $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
+ if (set_parent_node($3, $$->u.type_specifier.node))
reparent_error(scanner, "floating point reparent error");
}
| INTEGER LBRAC RBRAC
{
- $$ = make_node(scanner, NODE_INTEGER);
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_INTEGER;
+ $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
}
| INTEGER LBRAC ctf_assignment_expression_list RBRAC
{
- $$ = make_node(scanner, NODE_INTEGER);
- if (set_parent_node($3, $$))
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_INTEGER;
+ $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
+ if (set_parent_node($3, $$->u.type_specifier.node))
reparent_error(scanner, "integer reparent error");
}
| STRING LBRAC RBRAC
{
- $$ = make_node(scanner, NODE_STRING);
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_STRING;
+ $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
}
| STRING LBRAC ctf_assignment_expression_list RBRAC
{
- $$ = make_node(scanner, NODE_STRING);
- if (set_parent_node($3, $$))
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_STRING;
+ $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
+ if (set_parent_node($3, $$->u.type_specifier.node))
reparent_error(scanner, "string reparent error");
}
| ENUM enum_type_specifier
- { $$ = $2; }
+ {
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_ENUM;
+ $$->u.type_specifier.node = $2;
+ }
| VARIANT variant_type_specifier
- { $$ = $2; }
+ {
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_VARIANT;
+ $$->u.type_specifier.node = $2;
+ $$ = $2;
+ }
| STRUCT struct_type_specifier
- { $$ = $2; }
+ {
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
+ $$->u.type_specifier.type = TYPESPEC_STRUCT;
+ $$->u.type_specifier.node = $2;
+ $$ = $2;
+ }
;
struct_type_specifier:
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $2;
_cds_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
| IDENTIFIER LBRAC enumerator_list RBRAC
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1->s;
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $3;
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u._enum.enumerator_list);
}
| ID_TYPE LBRAC enumerator_list RBRAC
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1->s;
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $3;
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u._enum.enumerator_list);
}
| LBRAC enumerator_list COMMA RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $2;
_cds_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
| IDENTIFIER LBRAC enumerator_list COMMA RBRAC
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1->s;
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $3;
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u._enum.enumerator_list);
}
| IDENTIFIER
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 0;
$$->u._enum.enum_id = $1->s;
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $3;
}
| ID_TYPE LBRAC enumerator_list COMMA RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1->s;
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $3;
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u._enum.enumerator_list);
}
| ID_TYPE
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 0;
$$->u._enum.enum_id = $1->s;
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.container_type);
+ ($$)->u._enum.container_type = $3;
}
;
struct_or_variant_declaration:
declaration_specifiers struct_or_variant_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
$$ = make_node(scanner, NODE_STRUCT_OR_VARIANT_DECLARATION);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u.struct_or_variant_declaration.declaration_specifier);
+ ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_cds_list_splice_tail(&($2)->tmp_head, &($$)->u.struct_or_variant_declaration.type_declarators);
}
| declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u._typedef.declaration_specifier);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u._typedef.type_specifier_list = list;
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _cds_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
}
| TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u._typedef.type_specifier_list = list;
+ _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
| declaration_specifiers TYPEDEF type_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
| TYPEALIAS declaration_specifiers abstract_declarator_list COLON alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEALIAS);
$$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
$$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u.typealias.target->u.typealias_target.declaration_specifier);
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
+ _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
- _cds_list_splice_tail(&($5)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.declaration_specifier);
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
+ _cds_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
}
;
alias_declaration_specifiers:
CONST
{
- $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- $$->u.type_specifier.type = TYPESPEC_CONST;
+ struct ctf_node *node;
+
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ node = make_node(scanner, NODE_TYPE_SPECIFIER);
+ node->u.type_specifier.type = TYPESPEC_CONST;
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
| type_specifier
- { $$ = $1; }
+ {
+ struct ctf_node *node;
+
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ node = $1;
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
+ }
| IDENTIFIER
{
+ struct ctf_node *node;
+
add_type(scanner, $1);
- $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
- ($$)->u.type_specifier.type = TYPESPEC_ID_TYPE;
- ($$)->u.type_specifier.id_type = yylval.gs->s;
+ $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ node = make_node(scanner, NODE_TYPE_SPECIFIER);
+ node->u.type_specifier.type = TYPESPEC_ID_TYPE;
+ node->u.type_specifier.id_type = yylval.gs->s;
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
| alias_declaration_specifiers CONST
{
$$ = $1;
node = make_node(scanner, NODE_TYPE_SPECIFIER);
node->u.type_specifier.type = TYPESPEC_CONST;
- cds_list_add_tail(&node->siblings, &($$)->tmp_head);
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
| alias_declaration_specifiers type_specifier
{
$$ = $1;
- cds_list_add_tail(&($2)->siblings, &($$)->tmp_head);
+ cds_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
}
| alias_declaration_specifiers IDENTIFIER
{
node = make_node(scanner, NODE_TYPE_SPECIFIER);
node->u.type_specifier.type = TYPESPEC_ID_TYPE;
node->u.type_specifier.id_type = yylval.gs->s;
- cds_list_add_tail(&node->siblings, &($$)->tmp_head);
+ cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
;
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $1;
- CDS_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ ($$)->u.type_declarator.u.nested.length = $3;
}
| direct_abstract_declarator LSBRAC RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $1;
- CDS_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ ($$)->u.type_declarator.u.nested.length = $3;
}
| direct_alias_abstract_declarator LSBRAC RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $1;
- CDS_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ ($$)->u.type_declarator.u.nested.length = $3;
}
;
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $1;
- CDS_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
+ ($$)->u.type_declarator.u.nested.length = $3;
}
;
reparent_error(scanner, "ctf_assignment_expression left expects string");
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u.ctf_expression.right);
}
- | unary_expression TYPEASSIGN type_specifier
+ | unary_expression TYPEASSIGN type_specifier /* Only allow struct */
{
+ struct ctf_node *list;
/*
* Because we have left and right, cannot use
* set_parent_node.
_cds_list_splice_tail(&($1)->tmp_head, &($$)->u.ctf_expression.left);
if ($1->u.unary_expression.type != UNARY_STRING)
reparent_error(scanner, "ctf_assignment_expression left expects string");
- cds_list_add(&($3)->siblings, &($3)->tmp_head);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.ctf_expression.right);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ cds_list_add_tail(&($3)->siblings, &list->u.type_specifier_list.head);
+ cds_list_add_tail(&list->siblings, &($$)->u.ctf_expression.right);
}
| declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list
{
+ struct ctf_node *list;
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
+ _cds_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.declaration_specifier);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_cds_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
}
| TYPEDEF declaration_specifiers type_declarator_list
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u._typedef.type_specifier_list = list;
+ _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
| declaration_specifiers TYPEDEF type_declarator_list
{
+ struct ctf_node *list;
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
$$ = make_node(scanner, NODE_TYPEDEF);
- _cds_list_splice_tail(&($1)->tmp_head, &($$)->u._typedef.declaration_specifier);
+ ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
| TYPEALIAS declaration_specifiers abstract_declarator_list COLON alias_declaration_specifiers alias_abstract_declarator_list
{
+ struct ctf_node *list;
+
$$ = make_node(scanner, NODE_TYPEALIAS);
$$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
$$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
- _cds_list_splice_tail(&($2)->tmp_head, &($$)->u.typealias.target->u.typealias_target.declaration_specifier);
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
+ _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
- _cds_list_splice_tail(&($5)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.declaration_specifier);
+
+ list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
+ $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
+ _cds_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_cds_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
}
;
}
static
-int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node)
+int ctf_visitor_type_specifier_list(FILE *fd, int depth, struct ctf_node *node)
{
switch (node->parent->type) {
case NODE_CTF_EXPRESSION:
case NODE_TYPEALIAS_ALIAS:
case NODE_ENUM:
case NODE_STRUCT_OR_VARIANT_DECLARATION:
+ case NODE_ROOT:
+ break; /* OK */
+
+ case NODE_EVENT:
+ case NODE_STREAM:
+ case NODE_TRACE:
+ case NODE_UNARY_EXPRESSION:
+ case NODE_TYPEALIAS:
+ case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
+ case NODE_POINTER:
+ case NODE_FLOATING_POINT:
+ case NODE_INTEGER:
+ case NODE_STRING:
+ case NODE_ENUMERATOR:
+ case NODE_VARIANT:
+ case NODE_STRUCT:
+ default:
+ goto errinval;
+ }
+ return 0;
+errinval:
+ fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__,
+ node_type(node->parent), node_type(node));
+ return -EINVAL; /* Incoherent structure */
+}
+
+static
+int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node)
+{
+ switch (node->parent->type) {
+ case NODE_TYPE_SPECIFIER_LIST:
break; /* OK */
+ case NODE_CTF_EXPRESSION:
+ case NODE_TYPE_DECLARATOR:
+ case NODE_TYPEDEF:
+ case NODE_TYPEALIAS_TARGET:
+ case NODE_TYPEALIAS_ALIAS:
+ case NODE_ENUM:
+ case NODE_STRUCT_OR_VARIANT_DECLARATION:
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
*/
if (node->u.type_declarator.type == TYPEDEC_NESTED)
goto errperm;
- if (cds_list_empty(&node->u.type_declarator.pointers))
- goto errperm;
+ switch (node->u.type_declarator.type) {
+ case TYPESPEC_FLOATING_POINT:
+ case TYPESPEC_INTEGER:
+ case TYPESPEC_STRING:
+ case TYPESPEC_STRUCT:
+ case TYPESPEC_VARIANT:
+ case TYPESPEC_ENUM:
+ if (cds_list_empty(&node->u.type_declarator.pointers))
+ goto errperm;
+ break;
+ default:
+ break;
+ }
if (node->u.type_declarator.type == TYPEDEC_ID &&
node->u.type_declarator.u.id != NULL)
goto errperm;
break;
case TYPEDEC_NESTED:
{
- int nr_nest_len;
-
if (node->u.type_declarator.u.nested.type_declarator) {
ret = _ctf_visitor_semantic_check(fd, depth + 1,
node->u.type_declarator.u.nested.type_declarator);
if (ret)
return ret;
}
- cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
- siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1,
- iter);
- if (ret)
- return ret;
- nr_nest_len++;
- if (iter->type == NODE_UNARY_EXPRESSION && nr_nest_len > 1) {
- goto errperm;
- }
- }
+ ret = _ctf_visitor_semantic_check(fd, depth + 1,
+ node->u.type_declarator.u.nested.length);
+ if (ret)
+ return ret;
if (node->u.type_declarator.bitfield_len) {
ret = _ctf_visitor_semantic_check(fd, depth + 1,
node->u.type_declarator.bitfield_len);
switch (node->type) {
case NODE_ROOT:
- cds_list_for_each_entry(iter, &node->u.root._typedef,
- siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- cds_list_for_each_entry(iter, &node->u.root.typealias,
- siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- cds_list_for_each_entry(iter, &node->u.root.declaration_specifier, siblings) {
+ cds_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
if (ret)
return ret;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_TYPE_DECLARATOR:
case NODE_ENUMERATOR:
case NODE_TYPEALIAS:
case NODE_STRUCT_OR_VARIANT_DECLARATION:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_TYPE_DECLARATOR:
case NODE_FLOATING_POINT:
}
depth++;
- cds_list_for_each_entry(iter, &node->u._typedef.declaration_specifier, siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
+ ret = _ctf_visitor_semantic_check(fd, depth + 1,
+ node->u._typedef.type_specifier_list);
+ if (ret)
+ return ret;
cds_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
if (ret)
}
depth++;
- cds_list_for_each_entry(iter, &node->u.typealias_target.declaration_specifier, siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
+ ret = _ctf_visitor_semantic_check(fd, depth + 1,
+ node->u.typealias_target.type_specifier_list);
+ if (ret)
+ return ret;
nr_declarators = 0;
cds_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
}
depth++;
- cds_list_for_each_entry(iter, &node->u.typealias_alias.declaration_specifier, siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
+ ret = _ctf_visitor_semantic_check(fd, depth + 1,
+ node->u.typealias_alias.type_specifier_list);
+ if (ret)
+ return ret;
nr_declarators = 0;
cds_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
case NODE_TYPEALIAS:
case NODE_STRUCT_OR_VARIANT_DECLARATION:
case NODE_TYPE_SPECIFIER:
+ case NODE_TYPE_SPECIFIER_LIST:
case NODE_POINTER:
case NODE_TYPE_DECLARATOR:
case NODE_FLOATING_POINT:
return ret;
break;
+ case NODE_TYPE_SPECIFIER_LIST:
+ ret = ctf_visitor_type_specifier_list(fd, depth, node);
+ if (ret)
+ return ret;
+ break;
case NODE_TYPE_SPECIFIER:
ret = ctf_visitor_type_specifier(fd, depth, node);
if (ret)
case NODE_FLOATING_POINT:
switch (node->parent->type) {
- case NODE_CTF_EXPRESSION:
- case NODE_TYPEDEF:
- case NODE_TYPEALIAS_TARGET:
- case NODE_TYPEALIAS_ALIAS:
- case NODE_STRUCT_OR_VARIANT_DECLARATION:
- break; /* OK */
-
- case NODE_ROOT:
- case NODE_EVENT:
- case NODE_STREAM:
- case NODE_TRACE:
- case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
- case NODE_POINTER:
- case NODE_TYPE_DECLARATOR:
- case NODE_FLOATING_POINT:
- case NODE_INTEGER:
- case NODE_STRING:
- case NODE_ENUMERATOR:
- case NODE_ENUM:
- case NODE_VARIANT:
- case NODE_STRUCT:
+ break; /* OK */
default:
goto errinval;
break;
case NODE_INTEGER:
switch (node->parent->type) {
- case NODE_CTF_EXPRESSION:
- case NODE_UNARY_EXPRESSION:
- case NODE_TYPEDEF:
- case NODE_TYPEALIAS_TARGET:
- case NODE_TYPEALIAS_ALIAS:
- case NODE_TYPE_DECLARATOR:
- case NODE_ENUM:
- case NODE_STRUCT_OR_VARIANT_DECLARATION:
- break; /* OK */
-
- case NODE_ROOT:
- case NODE_EVENT:
- case NODE_STREAM:
- case NODE_TRACE:
- case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
- case NODE_POINTER:
- case NODE_FLOATING_POINT:
- case NODE_INTEGER:
- case NODE_STRING:
- case NODE_ENUMERATOR:
- case NODE_VARIANT:
- case NODE_STRUCT:
+ break; /* OK */
default:
goto errinval;
break;
case NODE_STRING:
switch (node->parent->type) {
- case NODE_CTF_EXPRESSION:
- case NODE_TYPEDEF:
- case NODE_TYPEALIAS_TARGET:
- case NODE_TYPEALIAS_ALIAS:
- case NODE_STRUCT_OR_VARIANT_DECLARATION:
- break; /* OK */
-
- case NODE_ROOT:
- case NODE_EVENT:
- case NODE_STREAM:
- case NODE_TRACE:
- case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
- case NODE_POINTER:
- case NODE_TYPE_DECLARATOR:
- case NODE_FLOATING_POINT:
- case NODE_INTEGER:
- case NODE_STRING:
- case NODE_ENUMERATOR:
- case NODE_ENUM:
- case NODE_VARIANT:
- case NODE_STRUCT:
+ break; /* OK */
default:
goto errinval;
break;
case NODE_ENUM:
switch (node->parent->type) {
- case NODE_ROOT:
- case NODE_EVENT:
- case NODE_STREAM:
- case NODE_TRACE:
- case NODE_CTF_EXPRESSION:
- case NODE_TYPEDEF:
- case NODE_TYPEALIAS_TARGET:
- case NODE_TYPEALIAS_ALIAS:
- case NODE_TYPE_DECLARATOR:
- case NODE_STRUCT_OR_VARIANT_DECLARATION:
- break; /* OK */
-
- case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
- case NODE_POINTER:
- case NODE_FLOATING_POINT:
- case NODE_INTEGER:
- case NODE_STRING:
- case NODE_ENUMERATOR:
- case NODE_ENUM:
- case NODE_VARIANT:
- case NODE_STRUCT:
+ break; /* OK */
default:
goto errinval;
}
depth++;
- cds_list_for_each_entry(iter, &node->u._enum.container_type,
- siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
+ ret = _ctf_visitor_semantic_check(fd, depth + 1, node->u._enum.container_type);
+ if (ret)
+ return ret;
cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
default:
goto errinval;
}
- cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.declaration_specifier, siblings) {
- ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
+ ret = _ctf_visitor_semantic_check(fd, depth + 1,
+ node->u.struct_or_variant_declaration.type_specifier_list);
+ if (ret)
+ return ret;
cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
if (ret)
break;
case NODE_VARIANT:
switch (node->parent->type) {
- case NODE_ROOT:
- case NODE_EVENT:
- case NODE_STREAM:
- case NODE_TRACE:
- case NODE_CTF_EXPRESSION:
- case NODE_TYPEDEF:
- case NODE_TYPEALIAS_TARGET:
- case NODE_TYPEALIAS_ALIAS:
- case NODE_STRUCT_OR_VARIANT_DECLARATION:
- break; /* OK */
-
- case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
- case NODE_POINTER:
- case NODE_TYPE_DECLARATOR:
- case NODE_FLOATING_POINT:
- case NODE_INTEGER:
- case NODE_STRING:
- case NODE_ENUMERATOR:
- case NODE_ENUM:
- case NODE_VARIANT:
- case NODE_STRUCT:
+ break; /* OK */
default:
goto errinval;
case NODE_STRUCT:
switch (node->parent->type) {
- case NODE_ROOT:
- case NODE_EVENT:
- case NODE_STREAM:
- case NODE_TRACE:
- case NODE_CTF_EXPRESSION:
- case NODE_TYPEDEF:
- case NODE_TYPEALIAS_TARGET:
- case NODE_TYPEALIAS_ALIAS:
- case NODE_STRUCT_OR_VARIANT_DECLARATION:
- break; /* OK */
-
- case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
- case NODE_POINTER:
- case NODE_TYPE_DECLARATOR:
- case NODE_FLOATING_POINT:
- case NODE_INTEGER:
- case NODE_STRING:
- case NODE_ENUMERATOR:
- case NODE_ENUM:
- case NODE_VARIANT:
- case NODE_STRUCT:
+ break; /* OK */
default:
goto errinval;
return 0;
}
+static
+int ctf_visitor_print_type_specifier_list(FILE *fd, int depth, struct ctf_node *node)
+{
+ struct ctf_node *iter;
+ int ret;
+
+ print_tabs(fd, depth);
+ fprintf(fd, "<type_specifier_list>\n");
+ cds_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ print_tabs(fd, depth);
+ fprintf(fd, "</type_specifier_list>\n");
+ return 0;
+}
+
static
int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node)
{
print_tabs(fd, depth);
- fprintf(fd, "<type_specifier \"");
+
+ switch (node->u.type_specifier.type) {
+ case TYPESPEC_VOID:
+ case TYPESPEC_CHAR:
+ case TYPESPEC_SHORT:
+ case TYPESPEC_INT:
+ case TYPESPEC_LONG:
+ case TYPESPEC_FLOAT:
+ case TYPESPEC_DOUBLE:
+ case TYPESPEC_SIGNED:
+ case TYPESPEC_UNSIGNED:
+ case TYPESPEC_BOOL:
+ case TYPESPEC_COMPLEX:
+ case TYPESPEC_IMAGINARY:
+ case TYPESPEC_CONST:
+ case TYPESPEC_ID_TYPE:
+ fprintf(fd, "<type_specifier \"");
+ break;
+ case TYPESPEC_FLOATING_POINT:
+ case TYPESPEC_INTEGER:
+ case TYPESPEC_STRING:
+ case TYPESPEC_STRUCT:
+ case TYPESPEC_VARIANT:
+ case TYPESPEC_ENUM:
+ fprintf(fd, "<type_specifier>\n");
+ depth++;
+ break;
+ case TYPESPEC_UNKNOWN:
+ default:
+ fprintf(stderr, "[error] %s: unknown type specifier %d\n", __func__,
+ (int) node->u.type_specifier.type);
+ return -EINVAL;
+ }
switch (node->u.type_specifier.type) {
case TYPESPEC_VOID:
case TYPESPEC_ID_TYPE:
fprintf(fd, "%s", node->u.type_specifier.id_type);
break;
+ case TYPESPEC_FLOATING_POINT:
+ case TYPESPEC_INTEGER:
+ case TYPESPEC_STRING:
+ case TYPESPEC_STRUCT:
+ case TYPESPEC_VARIANT:
+ case TYPESPEC_ENUM:
+ return ctf_visitor_print_xml(fd, depth, node->u.type_specifier.node);
+ case TYPESPEC_UNKNOWN:
+ default:
+ fprintf(stderr, "[error] %s: unknown type specifier %d\n", __func__,
+ (int) node->u.type_specifier.type);
+ return -EINVAL;
+ }
+ switch (node->u.type_specifier.type) {
+ case TYPESPEC_VOID:
+ case TYPESPEC_CHAR:
+ case TYPESPEC_SHORT:
+ case TYPESPEC_INT:
+ case TYPESPEC_LONG:
+ case TYPESPEC_FLOAT:
+ case TYPESPEC_DOUBLE:
+ case TYPESPEC_SIGNED:
+ case TYPESPEC_UNSIGNED:
+ case TYPESPEC_BOOL:
+ case TYPESPEC_COMPLEX:
+ case TYPESPEC_IMAGINARY:
+ case TYPESPEC_CONST:
+ case TYPESPEC_ID_TYPE:
+ fprintf(fd, "\"/>\n");
+ break;
+ case TYPESPEC_FLOATING_POINT:
+ case TYPESPEC_INTEGER:
+ case TYPESPEC_STRING:
+ case TYPESPEC_STRUCT:
+ case TYPESPEC_VARIANT:
+ case TYPESPEC_ENUM:
+ print_tabs(fd, depth);
+ fprintf(fd, "</type_specifier>\n");
+ depth--;
+ break;
case TYPESPEC_UNKNOWN:
default:
fprintf(stderr, "[error] %s: unknown type specifier %d\n", __func__,
(int) node->u.type_specifier.type);
return -EINVAL;
}
- fprintf(fd, "\"/>\n");
+
return 0;
}
print_tabs(fd, depth);
fprintf(fd, "</type_declarator>\n");
}
- if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
+ if (node->u.type_declarator.u.nested.length) {
print_tabs(fd, depth);
fprintf(fd, "<length>\n");
- }
- cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
- siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ ret = ctf_visitor_print_xml(fd, depth + 1, node->u.type_declarator.u.nested.length);
if (ret)
return ret;
- }
- if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
print_tabs(fd, depth);
fprintf(fd, "</length>\n");
}
case NODE_ROOT:
print_tabs(fd, depth);
fprintf(fd, "<root>\n");
- cds_list_for_each_entry(iter, &node->u.root._typedef,
+ cds_list_for_each_entry(iter, &node->u.root.declaration_list,
siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
- cds_list_for_each_entry(iter, &node->u.root.typealias,
- siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- cds_list_for_each_entry(iter, &node->u.root.declaration_specifier, siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
cds_list_for_each_entry(iter, &node->u.root.trace, siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
print_tabs(fd, depth);
fprintf(fd, "<typedef>\n");
depth++;
- print_tabs(fd, depth);
- fprintf(fd, "<declaration_specifier>\n");
- cds_list_for_each_entry(iter, &node->u._typedef.declaration_specifier, siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- print_tabs(fd, depth);
- fprintf(fd, "</declaration_specifier>\n");
+ ret = ctf_visitor_print_xml(fd, depth + 1, node->u._typedef.type_specifier_list);
+ if (ret)
+ return ret;
print_tabs(fd, depth);
- fprintf(fd, "<type_declarators>\n");
+ fprintf(fd, "<type_declarator_list>\n");
cds_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
print_tabs(fd, depth);
- fprintf(fd, "</type_declarators>\n");
+ fprintf(fd, "</type_declarator_list>\n");
depth--;
print_tabs(fd, depth);
fprintf(fd, "</typedef>\n");
fprintf(fd, "<target>\n");
depth++;
- print_tabs(fd, depth);
- fprintf(fd, "<declaration_specifier>\n");
- cds_list_for_each_entry(iter, &node->u.typealias_target.declaration_specifier, siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- print_tabs(fd, depth);
- fprintf(fd, "</declaration_specifier>\n");
+ ret = ctf_visitor_print_xml(fd, depth, node->u.typealias_target.type_specifier_list);
+ if (ret)
+ return ret;
print_tabs(fd, depth);
- fprintf(fd, "<type_declarators>\n");
+ fprintf(fd, "<type_declarator_list>\n");
cds_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
print_tabs(fd, depth);
- fprintf(fd, "</type_declarators>\n");
+ fprintf(fd, "</type_declarator_list>\n");
depth--;
print_tabs(fd, depth);
fprintf(fd, "<alias>\n");
depth++;
- print_tabs(fd, depth);
- fprintf(fd, "<declaration_specifier>\n");
- cds_list_for_each_entry(iter, &node->u.typealias_alias.declaration_specifier, siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- print_tabs(fd, depth);
- fprintf(fd, "</declaration_specifier>\n");
+ ret = ctf_visitor_print_xml(fd, depth, node->u.typealias_alias.type_specifier_list);
+ if (ret)
+ return ret;
print_tabs(fd, depth);
- fprintf(fd, "<type_declarators>\n");
+ fprintf(fd, "<type_declarator_list>\n");
cds_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
print_tabs(fd, depth);
- fprintf(fd, "</type_declarators>\n");
+ fprintf(fd, "</type_declarator_list>\n");
depth--;
print_tabs(fd, depth);
fprintf(fd, "</typealias>\n");
break;
+ case NODE_TYPE_SPECIFIER_LIST:
+ ret = ctf_visitor_print_type_specifier_list(fd, depth, node);
+ if (ret)
+ return ret;
+ break;
+
case NODE_TYPE_SPECIFIER:
ret = ctf_visitor_print_type_specifier(fd, depth, node);
if (ret)
fprintf(fd, "<enum >\n");
depth++;
- if (!cds_list_empty(&node->u._enum.container_type)) {
+ if (node->u._enum.container_type) {
print_tabs(fd, depth);
fprintf(fd, "<container_type>\n");
}
- cds_list_for_each_entry(iter, &node->u._enum.container_type,
- siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- if (!cds_list_empty(&node->u._enum.container_type)) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, node->u._enum.container_type);
+ if (ret)
+ return ret;
+ if (node->u._enum.container_type) {
print_tabs(fd, depth);
fprintf(fd, "</container_type>\n");
}
fprintf(fd, "</enum>\n");
break;
case NODE_STRUCT_OR_VARIANT_DECLARATION:
- print_tabs(fd, depth);
- fprintf(fd, "<declaration_specifier>\n");
- cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.declaration_specifier, siblings) {
- ret = ctf_visitor_print_xml(fd, depth + 1, iter);
- if (ret)
- return ret;
- }
- print_tabs(fd, depth);
- fprintf(fd, "</declaration_specifier>\n");
+ ret = ctf_visitor_print_xml(fd, depth,
+ node->u.struct_or_variant_declaration.type_specifier_list);
+ if (ret)
+ return ret;
print_tabs(fd, depth);
- fprintf(fd, "<type_declarators>\n");
+ fprintf(fd, "<type_declarator_list>\n");
cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
ret = ctf_visitor_print_xml(fd, depth + 1, iter);
if (ret)
return ret;
}
print_tabs(fd, depth);
- fprintf(fd, "</type_declarators>\n");
+ fprintf(fd, "</type_declarator_list>\n");
break;
case NODE_VARIANT:
print_tabs(fd, depth);