commit cdcbfb725db71f4b393ff8f97b2b0d8ed9f5fa31
parent e249adce2743ff9232689c2eaba9012fd37b5a5f
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 24 Jan 2021 15:08:02 -0500
typedefs: emit function types
Diffstat:
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/typedef.c b/src/typedef.c
@@ -176,7 +176,26 @@ emit_type(const struct type *type, FILE *out)
fprintf(out, "}");
break;
case TYPE_STORAGE_FUNCTION:
- assert(0); // TODO
+ if (type->func.flags & FN_NORETURN) {
+ fprintf(out, "@noreturn ");
+ }
+ fprintf(out, "fn(");
+ for (const struct type_func_param *param = type->func.params;
+ param; param = param->next) {
+ if (param->next) {
+ emit_type(param->type, out);
+ fprintf(out, ", ");
+ } else if (type->func.variadism == VARIADISM_HARE) {
+ emit_type(param->type->array.members, out);
+ fprintf(out, "...");
+ } else if (type->func.variadism == VARIADISM_C) {
+ emit_type(param->type, out);
+ fprintf(out, ", ...");
+ }
+ }
+ fprintf(out, ") ");
+ emit_type(type->func.result, out);
+ break;
}
}