aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-02-26 00:25:13 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2026-02-26 00:25:13 +0200
commit22f6ba2e3dac13d615fb63722c96dd4939208966 (patch)
treee7a92e9a1869b525efd3370eab74a1e7d2f6de2a
parentcb22d6ede6440112acb555470508ae4fa58412ab (diff)
downloadfwd-22f6ba2e3dac13d615fb63722c96dd4939208966.tar.gz
fwd-22f6ba2e3dac13d615fb63722c96dd4939208966.zip
fix extern closure call arg type
-rw-r--r--src/lower.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lower.c b/src/lower.c
index 3ed8f49..731dc2c 100644
--- a/src/lower.c
+++ b/src/lower.c
@@ -857,13 +857,17 @@ static const char *fwd_ctypestr(struct type *t)
return NULL;
}
-static int lower_extern_closure_call(struct state *state, struct type *rtype, size_t idx)
+static int lower_extern_closure_call(struct state *state, struct scope *scope, struct type *rtype, size_t idx)
{
char *q = buildstr("%s_call%zu", state->prefix, uniq(state));
char *ctx_buf = NULL; size_t ctx_size = 0;
FILE *ctx = open_memstream(&ctx_buf, &ctx_size);
- fprintf(ctx, "struct %s {\n fwd_start_t start;\n fwd_call_t closure;\n};\n", q);
+
+ char *type = lower_type_str(state, scope, rtype);
+ fprintf(ctx, "struct %s {\n fwd_start_t start;\n %s a0;\n};\n", q, type);
+ free(type);
+
fclose(ctx);
assert(ctx_buf);
@@ -966,7 +970,7 @@ static int lower_extern_proc(struct state *state, struct ast *proc)
fprintf(new_state.code, "assert(extern_args[0].type == %s);\n",
fwd_ctypestr(ctype));
- if (lower_extern_closure_call(&new_state, ctype, idx))
+ if (lower_extern_closure_call(&new_state, proc->scope, ctype, idx))
return -1;
} else {