diff options
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -185,10 +185,6 @@ static void fprint_expr(FILE *out, Expression *expr); /* returns the number of characters written, not including the null character */ static size_t type_to_str_(Type *t, char *buffer, size_t bufsize) { - /* if ((t->flags & TYPE_IS_RESOLVED) && t->was_expr) { */ - /* /\* TODO: improve this (see also: case TYPE_EXPR) *\/ */ - /* return str_copy(buffer, bufsize, "<type expression>"); */ - /* } */ switch (t->kind) { case TYPE_VOID: return str_copy(buffer, bufsize, "void"); @@ -228,14 +224,13 @@ static size_t type_to_str_(Type *t, char *buffer, size_t bufsize) { return written; } case TYPE_STRUCT: { - /* size_t written = str_copy(buffer, bufsize, "struct { "); */ - /* arr_foreach(t->struc->fields, Field, f) { */ - /* written += type_to_str_(f->type, buffer + written, bufsize - written); */ - /* written += str_copy(buffer + written, bufsize - written, "; "); */ - /* } */ - /* written += str_copy(buffer + written, bufsize - written, " }"); */ - /* TODO: show name or something (to allow circular dependencies)? */ - return str_copy(buffer, bufsize, "struct { ... }"); + if (t->struc->name) { + char *namestr = ident_to_str(t->struc->name); + size_t bytes = str_copy(buffer, bufsize, namestr); + free(namestr); + return bytes; + } + return str_copy(buffer, bufsize, "anonymous struct"); } case TYPE_ARR: { |