+int visit_type_specifier(FILE *fd, struct ctf_node *type_specifier, GString *str)
+{
+ assert(type_specifier->type == NODE_TYPE_SPECIFIER);
+
+ switch (type_specifier->u.type_specifier.type) {
+ case TYPESPEC_VOID:
+ g_string_append(str, "void");
+ break;
+ case TYPESPEC_CHAR:
+ g_string_append(str, "char");
+ break;
+ case TYPESPEC_SHORT:
+ g_string_append(str, "short");
+ break;
+ case TYPESPEC_INT:
+ g_string_append(str, "int");
+ break;
+ case TYPESPEC_LONG:
+ g_string_append(str, "long");
+ break;
+ case TYPESPEC_FLOAT:
+ g_string_append(str, "float");
+ break;
+ case TYPESPEC_DOUBLE:
+ g_string_append(str, "double");
+ break;
+ case TYPESPEC_SIGNED:
+ g_string_append(str, "signed");
+ break;
+ case TYPESPEC_UNSIGNED:
+ g_string_append(str, "unsigned");
+ break;
+ case TYPESPEC_BOOL:
+ g_string_append(str, "bool");
+ break;
+ case TYPESPEC_COMPLEX:
+ g_string_append(str, "_Complex");
+ break;
+ case TYPESPEC_IMAGINARY:
+ g_string_append(str, "_Imaginary");
+ break;
+ case TYPESPEC_CONST:
+ g_string_append(str, "const");
+ break;
+ case TYPESPEC_ID_TYPE:
+ if (type_specifier->u.type_specifier.id_type)
+ g_string_append(str, type_specifier->u.type_specifier.id_type);
+ break;
+ case TYPESPEC_STRUCT:
+ {
+ struct ctf_node *node = type_specifier->u.type_specifier.node;
+
+ if (!node->u._struct.name) {
+ fprintf(fd, "[error] %s: unexpected empty variant name\n", __func__);
+ return -EINVAL;
+ }
+ g_string_append(str, "struct ");
+ g_string_append(str, node->u._struct.name);
+ break;
+ }
+ case TYPESPEC_VARIANT:
+ {
+ struct ctf_node *node = type_specifier->u.type_specifier.node;
+
+ if (!node->u.variant.name) {
+ fprintf(fd, "[error] %s: unexpected empty variant name\n", __func__);
+ return -EINVAL;
+ }
+ g_string_append(str, "variant ");
+ g_string_append(str, node->u.variant.name);
+ break;
+ }
+ case TYPESPEC_ENUM:
+ {
+ struct ctf_node *node = type_specifier->u.type_specifier.node;
+
+ if (!node->u._enum.enum_id) {
+ fprintf(fd, "[error] %s: unexpected empty enum ID\n", __func__);
+ return -EINVAL;
+ }
+ g_string_append(str, "enum ");
+ g_string_append(str, node->u._enum.enum_id);
+ break;
+ }
+ case TYPESPEC_FLOATING_POINT:
+ case TYPESPEC_INTEGER:
+ case TYPESPEC_STRING:
+ default:
+ fprintf(fd, "[error] %s: unknown specifier\n", __func__);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static
+int visit_type_specifier_list(FILE *fd, struct ctf_node *type_specifier_list, GString *str)