aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lower.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lower.c b/src/lower.c
index a31564f..e29365d 100644
--- a/src/lower.c
+++ b/src/lower.c
@@ -682,6 +682,12 @@ static int lower_param_copy(struct state *state, struct ast *param, FILE *f, siz
char *type = lower_type_str(param->t);
fprintf(f, " %s a%zu;\n", type, idx);
free(type);
+
+ indent(state);
+
+ char *p = mangle2(param);
+ fprintf(state->code, "ctx->%s = params->a%zu;\n", p, idx);
+ free(p);
return 0;
}
@@ -707,11 +713,6 @@ static int lower_param_copies(struct state *state, struct ast *params)
assert(param_buf);
add_type(state, param_buf);
-
- indent(state);
- fprintf(state->code, "*((struct %s_params *)&ctx->%s_start) ="
- " *((struct %s_params *)args);\n",
- state->prefix, state->prefix, state->prefix);
return 0;
}
@@ -766,6 +767,12 @@ static int lower_proc(struct state *state, struct ast *proc)
fprintf(new_state.code, "struct %s_ctx *ctx = &ctx_buf;\n", name);
}
+ if (proc_params(proc)) {
+ indent(&new_state);
+ fprintf(new_state.code, "struct %s_params *params = (struct %s_params *)args;\n",
+ name, name);
+ }
+
/* allocates parameter slots */
int ret = lower_params(&new_state, proc_params(proc));
assert(ret == 0);