diff options
author | Quinn Stephens <quinn@osmora.org> | 2024-11-02 08:28:59 -0400 |
---|---|---|
committer | Quinn Stephens <quinn@osmora.org> | 2024-11-02 08:28:59 -0400 |
commit | 2ae50e907a7042aecb00bcff7643859d3f657895 (patch) | |
tree | 5f5edbb87a3f906a033b73a3c0315866bba32e79 /compiler/main.c | |
parent | a515dfb3b8f8e999362db7a6b52b3104c03b750a (diff) |
More type parsing
Signed-off-by: Quinn Stephens <quinn@osmora.org>
Diffstat (limited to 'compiler/main.c')
-rw-r--r-- | compiler/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/main.c b/compiler/main.c index da261bc..ada6243 100644 --- a/compiler/main.c +++ b/compiler/main.c @@ -174,6 +174,14 @@ parse_args(int argc, char **argv) } static void +print_ptrs(int n_ptrs) +{ + for (int n = 0; n < n_ptrs; n++) { + putchar('*'); + } +} + +static void print_alias(struct type *typ) { printf("alias (%lu bytes, %d pointer(s))", typ->size, typ->n_ptrs); @@ -207,7 +215,7 @@ print_struct(struct type *typ) { struct struct_member *mem; - printf("struct {\n"); + printf("struct (%lu bytes) {\n", typ->size); for (size_t r = 0; r < typ->members.n_rows; r++) { mem = (struct struct_member*)typ->members.rows[r].head; @@ -216,7 +224,9 @@ print_struct(struct type *typ) } do { - printf(" %.*s %.*s; (%d pointer(s))\n", (int)mem->typ->name_len, mem->typ->name, (int)mem->name_len, mem->name, mem->n_ptrs); + printf(" %.*s", (int)mem->typ->name_len, mem->typ->name); + print_ptrs(mem->n_ptrs); + printf(" %.*s;\n", (int)mem->name_len, mem->name); mem = (struct struct_member*)mem->hashmap_entry.list_entry.next; } while (mem != (struct struct_member*)&typ->members.rows[r]); |