diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lower.c | 10 |
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 { |
