commit 9e9311de0eed67358355ce7623b5e6ee1a5b166a
parent 2678ff52c2291d65015da08f6e5d01a2ad49627a
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 20 Jan 2021 16:20:41 -0500
typedefs: emit type declarations
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/typedef.c b/src/typedef.c
@@ -80,6 +80,15 @@ emit_global(struct declaration *decl, FILE *out)
fprintf(out, ";\n");
}
+static void
+emit_type_decl(struct declaration *decl, FILE *out)
+{
+ char *ident = identifier_unparse(&decl->ident);
+ fprintf(out, "export type %s = ", ident);
+ emit_type(decl->_type, out);
+ fprintf(out, ";\n");
+}
+
void
emit_typedefs(struct unit *unit, FILE *out)
{
@@ -95,7 +104,8 @@ emit_typedefs(struct unit *unit, FILE *out)
emit_func(decl, out);
break;
case DECL_TYPE:
- assert(0); // TODO
+ emit_type_decl(decl, out);
+ break;
case DECL_GLOBAL:
emit_global(decl, out);
break;