harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 361cf2cdcc64a6fc1a8c6bf38864fe0b997876ef
parent f18d5152969b68aba46c3bf4cdd535f98871d47d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 20 Jan 2021 16:14:27 -0500

typedef: implement emit_global

Diffstat:
Msrc/typedef.c | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/typedef.c b/src/typedef.c @@ -52,7 +52,6 @@ static void emit_func(struct declaration *decl, FILE *out) { char *ident = identifier_unparse(&decl->ident); // TODO: Emit @symbol - const struct type *fntype = decl->func.type; fprintf(out, "export%s fn %s(", (fntype->func.flags & FN_NORETURN) ? " @noreturn" : "", @@ -72,6 +71,15 @@ emit_func(struct declaration *decl, FILE *out) free(ident); } +static void +emit_global(struct declaration *decl, FILE *out) +{ + char *ident = identifier_unparse(&decl->ident); // TODO: Emit @symbol + fprintf(out, "export let %s: ", ident); + emit_type(decl->global.type, out); + fprintf(out, ";\n"); +} + void emit_typedefs(struct unit *unit, FILE *out) { @@ -89,7 +97,8 @@ emit_typedefs(struct unit *unit, FILE *out) case DECL_TYPE: assert(0); // TODO case DECL_GLOBAL: - assert(0); // TODO + emit_global(decl, out); + break; case DECL_CONSTANT: assert(0); // TODO }