diff options
| author | 2022-08-07 15:26:53 +0200 | |
|---|---|---|
| committer | 2022-08-07 15:29:04 +0200 | |
| commit | 92bbf45f333bbf9190befc52a6bc114dc2957e41 (patch) | |
| tree | 87196fb07a02e1eb6cb5048da86dadd30a69ddc1 /bootstrap/dump.c | |
| parent | 0a4f81e86d21d056329a2b7b2186152e9b9c2375 (diff) | |
basic templates (generics)
Diffstat (limited to 'bootstrap/dump.c')
| -rw-r--r-- | bootstrap/dump.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/bootstrap/dump.c b/bootstrap/dump.c index 84c4bbe..dae457a 100644 --- a/bootstrap/dump.c +++ b/bootstrap/dump.c @@ -3,6 +3,8 @@ static void pritype(const struct type *ty) { + const char *kind; + assert(ty); if (ty->konst) epri("const "); @@ -44,13 +46,25 @@ pritype(const struct type *ty) { epri("%s", ty->enu.name ? ty->enu.name : "(anonymous enum)"); break; case TYstruct: - epri("%s", ty->agg.name ? ty->agg.name : "(anonymous struct)"); - break; + kind = "struct"; + goto agg; case TYunion: - epri("%s", ty->agg.name ? ty->agg.name : "(anonymous union)"); - break; + kind = "union"; + goto agg; case TYeunion: - epri("%s", ty->agg.name ? ty->agg.name : "(anonymous tagged union)"); + kind = "tagged union"; + agg: + epri("%s", ty->agg.name ? ty->agg.name : "(anonymous %s)", kind); + if (ty->agg.tpargs.n) { + epri("<"); + int n = ty->agg.tpargs.n; + for (int i = 0; i < n; ++i) { + epri("%t", ty->agg.tpargs.d[i].ty); + if (i < n - 1) + epri(", "); + } + epri("%bc", '>'); + } break; } } @@ -141,6 +155,10 @@ tok2str(struct tok tok) { } buf[i] = '\0'; strcat(buf, "'"); + } else if (tok.t == TKtype) { + return "<type parameter>"; + } else if (tok.t == TKexpr) { + return "<const parameter>"; } else { snprintf(buf, sizeof buf - 1, "`%c'", tok.t); } @@ -417,6 +435,8 @@ dumpdecl(const struct decl *decl, int ws) { } epri("}\n"); break; + case Dtepl: + assert(0); } } |