Merge commit '39e34bdd05d53937aa0385f93ca1fd7d025abd23'

This commit is contained in:
Benjamin Vedder 2022-03-28 21:17:49 +02:00
commit 2eec9fcc3e
1 changed files with 21 additions and 19 deletions

View File

@ -1816,31 +1816,33 @@ static inline void cont_closure_application_args(eval_context_t *ctx) {
lbm_value params = (lbm_value)sptr[3]; lbm_value params = (lbm_value)sptr[3];
lbm_value args = (lbm_value)sptr[4]; lbm_value args = (lbm_value)sptr[4];
if (lbm_is_symbol_nil(params)) { // accepts no more params if (lbm_is_list(params)) {
lbm_stack_drop(&ctx->K, 5);
ctx->curr_env = clo_env;
ctx->curr_exp = exp;
ctx->app_cont = false;
} else {
lbm_value entry; lbm_value entry;
WITH_GC(entry,lbm_cons(lbm_car(params),ctx->r), NIL, NIL); WITH_GC(entry,lbm_cons(lbm_car(params),ctx->r), NIL, NIL);
lbm_value aug_env; lbm_value aug_env;
WITH_GC(aug_env,lbm_cons(entry, clo_env),entry,NIL); WITH_GC(aug_env,lbm_cons(entry, clo_env),entry,NIL);
clo_env = aug_env;
}
if (lbm_is_symbol_nil(args)) { bool a_nil = lbm_is_symbol_nil(args);
lbm_stack_drop(&ctx->K, 5); bool p_nil = lbm_is_symbol_nil(lbm_cdr(params));
ctx->curr_env = aug_env;
ctx->curr_exp = exp; if (a_nil && p_nil) {
ctx->app_cont = false; lbm_stack_drop(&ctx->K, 5);
} else { ctx->curr_env = clo_env;
sptr[2] = aug_env; ctx->curr_exp = exp;
sptr[3] = lbm_cdr(params); ctx->app_cont = false;
sptr[4] = lbm_cdr(args); } else if (a_nil || p_nil) {
lbm_push(&ctx->K, lbm_enc_u(CLOSURE_ARGS)); lbm_set_error_reason("Too many arguments.");
ctx->curr_exp = lbm_car(args); error_ctx(lbm_enc_sym(SYM_EERROR));
ctx->curr_env = arg_env; } else {
} sptr[2] = clo_env;
sptr[3] = lbm_cdr(params);
sptr[4] = lbm_cdr(args);
lbm_push(&ctx->K, lbm_enc_u(CLOSURE_ARGS));
ctx->curr_exp = lbm_car(args);
ctx->curr_env = arg_env;
} }
} }