X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fcontext_dump.c;h=f1386710aa3eebab1d91cb92a7ad54634b4346ab;hb=06c05f17db2d8475cd7564f409041af4f3827e25;hp=efa99c6bbebf0ed08fdd7d11cddd546a17e9201b;hpb=f47a5ea51e1026fb1600008de2e51e7d80c7a3d9;p=m6w6%2Fext-psi diff --git a/src/context_dump.c b/src/context_dump.c index efa99c6..f138671 100644 --- a/src/context_dump.c +++ b/src/context_dump.c @@ -16,34 +16,15 @@ static inline void dump_enum_items(int fd, decl_enum_items *items, unsigned leve #define is_anon_type(name, type) !strncmp(name, type "@", sizeof(type)) static inline void dump_decl_type(int fd, decl_type *t, unsigned level) { - size_t j; - switch (t->type) { case PSI_T_POINTER: dprintf(fd, "%s *", t->name); return; - case PSI_T_FUNCTION: - dump_decl_arg(fd, t->func->func, level); - dprintf(fd, "("); - if (t->func->args) { - for (j = 0; j < t->func->args->count; ++j) { - if (j) { - dprintf(fd, ", "); - } - dump_decl_arg(fd, t->func->args->args[j], level+1); - } - if (t->func->args->varargs) { - dprintf(fd, ", ..."); - } - } - dprintf(fd, ")"); - return; - case PSI_T_STRUCT: dprintf(fd, "struct "); if (!strncmp(t->name, "struct@", sizeof("struct"))) { - dump_struct_args(fd, t->strct->args, level); + dump_struct_args(fd, t->real.strct->args, level); return; } break; @@ -51,7 +32,7 @@ static inline void dump_decl_type(int fd, decl_type *t, unsigned level) { case PSI_T_ENUM: dprintf(fd, "enum "); if (!strncmp(t->name, "enum@", sizeof("enum"))) { - dump_enum_items(fd, t->enm->items, level); + dump_enum_items(fd, t->real.enm->items, level); return; } break; @@ -59,7 +40,7 @@ static inline void dump_decl_type(int fd, decl_type *t, unsigned level) { case PSI_T_UNION: dprintf(fd, "union "); if (!strncmp(t->name, "union@", sizeof("union"))) { - dump_struct_args(fd, t->unn->args, level); + dump_struct_args(fd, t->real.unn->args, level); return; } break; @@ -75,9 +56,27 @@ static inline void dump_decl_var(int fd, decl_var *v) { } static inline void dump_decl_arg(int fd, decl_arg *a, unsigned level) { - dump_decl_type(fd, a->type, level); + if (a->type->type == PSI_T_FUNCTION) { + dump_decl_type(fd, a->type->real.func->func->type, level); + dprintf(fd, " ("); + dump_decl_var(fd, a->var); + dprintf(fd, ")("); + if (a->type->real.func->args) { + size_t j; - if (a->type->type != PSI_T_FUNCTION) { + for (j = 0; j < a->type->real.func->args->count; ++j) { + if (j) { + dprintf(fd, ", "); + } + dump_decl_arg(fd, a->type->real.func->args->args[j], level+1); + } + if (a->type->real.func->args->varargs) { + dprintf(fd, ", ..."); + } + } + dprintf(fd, ")"); + } else { + dump_decl_type(fd, a->type, level); dprintf(fd, " "); dump_decl_var(fd, a->var); }