commit 4cf1a4b2f1fed3860c33f8f279d11fe4247cabb5
parent 1afb5cb35bdda65a8f4aa5abc0e3022b0fb36685
Author: Andres Navarro <canavarro82@gmail.com>
Date: Sat, 16 Apr 2011 17:03:12 -0300
Removed implicit rooting & NAME & SI arguments in kmake_continuation
Diffstat:
16 files changed, 104 insertions(+), 137 deletions(-)
diff --git a/src/kcontinuation.c b/src/kcontinuation.c
@@ -12,54 +12,30 @@
#include "kmem.h"
#include "kgc.h"
-/* should be at least < GC_PROTECT_SIZE - 3 */
-#define CONT_MAX_ARGS 16
-
-TValue kmake_continuation(klisp_State *K, TValue parent, TValue name,
- TValue si, klisp_Cfunc fn, int32_t xcount, ...)
+TValue kmake_continuation(klisp_State *K, TValue parent, klisp_Cfunc fn,
+ int32_t xcount, ...)
{
va_list argp;
- klisp_assert(xcount < CONT_MAX_ARGS);
-
- TValue args[CONT_MAX_ARGS];
- va_start(argp, xcount);
- for (int i = 0; i < xcount; i++) {
- TValue val = va_arg(argp, TValue);
- krooted_tvs_push(K, val);
- args[i] = val;
- }
- va_end(argp);
-
- krooted_tvs_push(K, parent);
- krooted_tvs_push(K, name);
- krooted_tvs_push(K, si);
-
Continuation *new_cont = (Continuation *)
klispM_malloc(K, sizeof(Continuation) + sizeof(TValue) * xcount);
-
- for (int i = 0; i < xcount; i++) {
- TValue val = args[i];
- new_cont->extra[i] = val;
- krooted_tvs_pop(K);
- }
-
- krooted_tvs_pop(K);
- krooted_tvs_pop(K);
- krooted_tvs_pop(K);
-
/* header + gc_fields */
klispC_link(K, (GCObject *) new_cont, K_TCONTINUATION, 0);
/* continuation specific fields */
new_cont->mark = KFALSE;
- new_cont->name = name;
- new_cont->si = si;
+ new_cont->name = KNIL;
+ new_cont->si = KNIL;
new_cont->parent = parent;
new_cont->fn = fn;
new_cont->extra_size = xcount;
- /* new_cont->extra was already set */
+
+ va_start(argp, xcount);
+ for (int i = 0; i < xcount; i++) {
+ new_cont->extra[i] = va_arg(argp, TValue);
+ }
+ va_end(argp);
return gc2cont(new_cont);
}
diff --git a/src/kcontinuation.h b/src/kcontinuation.h
@@ -11,7 +11,7 @@
#include "kstate.h"
/* TODO: make some specialized constructors for 0, 1 and 2 parameters */
-TValue kmake_continuation(klisp_State *K, TValue parent, TValue name,
- TValue si, klisp_Cfunc fn, int xcount, ...);
+TValue kmake_continuation(klisp_State *K, TValue parent, klisp_Cfunc fn,
+ int xcount, ...);
#endif
diff --git a/src/keval.c b/src/keval.c
@@ -39,9 +39,8 @@ void eval_ls_cfn(klisp_State *K, TValue *xparams, TValue obj)
} else {
/* more arguments need to be evaluated */
/* GC: all objects are rooted at this point */
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- &eval_ls_cfn, 4, rest, env,
- tail, combiner);
+ TValue new_cont = kmake_continuation(K, kget_cc(K), &eval_ls_cfn, 4,
+ rest, env, tail, combiner);
kset_cc(K, new_cont);
ktail_eval(K, kcar(rest), env);
}
@@ -111,12 +110,12 @@ void combine_cfn(klisp_State *K, TValue *xparams, TValue obj)
/* make a copy of the operands (for storing arguments) */
TValue tail;
TValue arg_ls = make_arg_ls(K, operands, &tail);
- TValue comb_cont = kmake_continuation(
- K, kget_cc(K), KNIL, KNIL, &combine_cfn, 2, arg_ls, env);
+ TValue comb_cont = kmake_continuation(K, kget_cc(K), &combine_cfn,
+ 2, arg_ls, env);
- TValue els_cont = kmake_continuation(
- K, comb_cont, KNIL, KNIL, &eval_ls_cfn,
- 4, arg_ls, env, tail, tv2app(obj)->underlying);
+ TValue els_cont =
+ kmake_continuation(K, comb_cont, &eval_ls_cfn, 4, arg_ls, env,
+ tail, tv2app(obj)->underlying);
kset_cc(K, els_cont);
ktail_eval(K, kcar(arg_ls), env);
} else {
@@ -139,8 +138,8 @@ void keval_ofn(klisp_State *K, TValue *xparams, TValue obj, TValue env)
switch(ttype(obj)) {
case K_TPAIR: {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- &combine_cfn, 2, kcdr(obj), env);
+ TValue new_cont =
+ kmake_continuation(K, kget_cc(K), &combine_cfn, 2, kcdr(obj), env);
kset_cc(K, new_cont);
ktail_eval(K, kcar(obj), env);
break;
diff --git a/src/kgbooleans.c b/src/kgbooleans.c
@@ -119,7 +119,7 @@ void do_Sandp_Sorp(klisp_State *K, TValue *xparams, TValue obj)
/* This is the important part of tail context + bool check */
if (!ttisnil(ls) || !kis_bool_check_cont(kget_cc(K))) {
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_Sandp_Sorp,
+ kmake_continuation(K, kget_cc(K), do_Sandp_Sorp,
4, sname, term_bool, ls, denv);
/*
** Mark as a bool checking cont this is needed in the last operand
@@ -148,9 +148,8 @@ void Sandp_Sorp(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue ls = check_copy_list(K, ksymbol_buf(sname), ptree, false);
/* This will work even if ls is empty */
krooted_tvs_push(K, ls);
- TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_Sandp_Sorp,
- 4, sname, term_bool, ls, denv);
+ TValue new_cont = kmake_continuation(K, kget_cc(K), do_Sandp_Sorp, 4,
+ sname, term_bool, ls, denv);
krooted_tvs_pop(K);
/* there's no need to mark it as bool checking, no evaluation
is done in the dynamic extent of this cont */
diff --git a/src/kgcombiners.c b/src/kgcombiners.c
@@ -93,7 +93,7 @@ void do_vau(klisp_State *K, TValue *xparams, TValue obj, TValue denv)
nil sequence */
TValue tail = kcdr(body);
if (ttispair(tail)) {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, env);
kset_cc(K, new_cont);
}
@@ -449,7 +449,7 @@ void do_map(klisp_State *K, TValue *xparams, TValue obj)
TValue new_expr = kcons(K, kunwrap(app), first_ptree);
krooted_tvs_push(K, new_expr);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_map, 6, app,
+ kmake_continuation(K, kget_cc(K), do_map, 6, app,
ls, last_pair, i2tv(n), denv, KFALSE);
krooted_tvs_pop(K);
krooted_tvs_pop(K);
@@ -478,7 +478,7 @@ void do_map_cycle(klisp_State *K, TValue *xparams, TValue obj)
/* this continuation will close the cycle and return the list */
TValue encycle_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_map_encycle, 2,
+ kmake_continuation(K, kget_cc(K), do_map_encycle, 2,
dummy, last_apair);
krooted_tvs_push(K, encycle_cont);
@@ -486,7 +486,7 @@ void do_map_cycle(klisp_State *K, TValue *xparams, TValue obj)
signal dummyp = true to avoid creating a pair for
the inert value passed to the first continuation */
TValue new_cont =
- kmake_continuation(K, encycle_cont, KNIL, KNIL, do_map, 6, app, ls,
+ kmake_continuation(K, encycle_cont, do_map, 6, app, ls,
last_apair, cpairs, denv, KTRUE);
krooted_tvs_pop(K);
kset_cc(K, new_cont);
@@ -532,8 +532,8 @@ void map(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, dummy);
TValue ret_cont = (res_cpairs == 0)?
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_map_ret, 1, dummy)
- : kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_map_cycle, 4,
+ kmake_continuation(K, kget_cc(K), do_map_ret, 1, dummy)
+ : kmake_continuation(K, kget_cc(K), do_map_cycle, 4,
app, dummy, i2tv(res_cpairs), denv);
@@ -543,7 +543,7 @@ void map(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
signal dummyp = true to avoid creating a pair for
the inert value passed to the first continuation */
TValue new_cont =
- kmake_continuation(K, ret_cont, KNIL, KNIL, do_map, 6, app, lss, dummy,
+ kmake_continuation(K, ret_cont, do_map, 6, app, lss, dummy,
i2tv(res_apairs), denv, KTRUE);
krooted_tvs_pop(K);
diff --git a/src/kgcontinuations.c b/src/kgcontinuations.c
@@ -69,7 +69,7 @@ void extend_continuation(klisp_State *K, TValue *xparams, TValue ptree,
maybe_env : kmake_empty_environment(K);
krooted_tvs_push(K, env);
- TValue new_cont = kmake_continuation(K, cont, KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, cont,
do_extended_cont, 2, app, env);
krooted_tvs_pop(K);
kapply_cc(K, new_cont);
@@ -177,12 +177,12 @@ void guard_continuation(klisp_State *K, TValue *xparams, TValue ptree,
exit_guards);
krooted_tvs_push(K, exit_guards);
- TValue outer_cont = kmake_continuation(K, cont, KNIL, KNIL, do_pass_value,
+ TValue outer_cont = kmake_continuation(K, cont, do_pass_value,
2, entry_guards, denv);
krooted_tvs_push(K, outer_cont);
/* mark it as an outer continuation */
kset_outer_cont(outer_cont);
- TValue inner_cont = kmake_continuation(K, outer_cont, KNIL, KNIL,
+ TValue inner_cont = kmake_continuation(K, outer_cont,
do_pass_value, 2, exit_guards, denv);
/* mark it as an outer continuation */
kset_inner_cont(inner_cont);
@@ -260,7 +260,7 @@ void Slet_cc(klisp_State *K, TValue *xparams, TValue ptree,
nil sequence */
TValue tail = kcdr(ls);
if (ttispair(tail)) {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, new_env);
kset_cc(K, new_cont);
}
@@ -289,12 +289,12 @@ void guard_dynamic_extent(klisp_State *K, TValue *xparams, TValue ptree,
krooted_tvs_push(K, exit_guards);
/* GC: root continuations */
/* The current continuation is guarded */
- TValue outer_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_pass_value,
+ TValue outer_cont = kmake_continuation(K, kget_cc(K), do_pass_value,
1, entry_guards);
kset_outer_cont(outer_cont);
kset_cc(K, outer_cont); /* this implicitly roots outer_cont */
- TValue inner_cont = kmake_continuation(K, outer_cont, KNIL, KNIL,
+ TValue inner_cont = kmake_continuation(K, outer_cont,
do_pass_value, 1, exit_guards);
kset_inner_cont(inner_cont);
diff --git a/src/kgcontrol.c b/src/kgcontrol.c
@@ -37,7 +37,7 @@ void Sif(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
bind_3p(K, "$if", ptree, test, cons_c, alt_c);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, select_clause,
+ kmake_continuation(K, kget_cc(K), select_clause,
3, denv, cons_c, alt_c);
/*
** Mark as a bool checking cont, not necessary but avoids a continuation
@@ -83,8 +83,8 @@ void Ssequence(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue tail = kcdr(ls);
if (ttispair(tail)) {
krooted_tvs_push(K, ls);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- do_seq, 2, tail, denv);
+ TValue new_cont = kmake_continuation(K, kget_cc(K), do_seq, 2,
+ tail, denv);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
}
@@ -106,8 +106,8 @@ void do_seq(klisp_State *K, TValue *xparams, TValue obj)
TValue denv = xparams[1];
if (ttispair(tail)) {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- do_seq, 2, tail, denv);
+ TValue new_cont = kmake_continuation(K, kget_cc(K), do_seq, 2, tail,
+ denv);
kset_cc(K, new_cont);
}
ktail_eval(K, first, denv);
@@ -210,8 +210,8 @@ void do_cond(klisp_State *K, TValue *xparams, TValue obj)
} else {
TValue tail = kcdr(this_body);
if (ttispair(tail)) {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- do_seq, 2, tail, denv);
+ TValue new_cont = kmake_continuation(K, kget_cc(K), do_seq, 2,
+ tail, denv);
kset_cc(K, new_cont);
}
ktail_eval(K, kcar(this_body), denv);
@@ -222,7 +222,7 @@ void do_cond(klisp_State *K, TValue *xparams, TValue obj)
kapply_cc(K, KINERT);
} else {
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_cond, 4,
+ kmake_continuation(K, kget_cc(K), do_cond, 4,
kcar(bodies), kcdr(tests), kcdr(bodies),
denv);
/*
@@ -254,7 +254,7 @@ void Scond(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
/* pass a dummy body and a #f to the $cond continuation to
avoid code repetition here */
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_cond, 4,
+ kmake_continuation(K, kget_cc(K), do_cond, 4,
KNIL, tests, bodies, denv);
/* there is no need to mark this continuation with bool check
because it is just a dummy, no evaluation happens in its
@@ -300,7 +300,7 @@ void do_for_each(klisp_State *K, TValue *xparams, TValue obj)
/* have to unwrap the applicative to avoid extra evaluation of first */
TValue new_expr = kcons(K, kunwrap(app), first_ptree);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_for_each, 4,
+ kmake_continuation(K, kget_cc(K), do_for_each, 4,
app, ls, i2tv(n), denv);
krooted_tvs_pop(K);
kset_cc(K, new_cont);
@@ -339,7 +339,7 @@ void for_each(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
/* schedule all elements at once, the cycle is just ignored, this
will also return #inert once done. */
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_for_each, 4, app, lss,
+ kmake_continuation(K, kget_cc(K), do_for_each, 4, app, lss,
i2tv(res_pairs), denv);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
diff --git a/src/kgenv_mut.c b/src/kgenv_mut.c
@@ -36,7 +36,7 @@ void SdefineB(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, dptree);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_match, 3, dptree, denv,
def_sym);
kset_cc(K, new_cont);
@@ -73,7 +73,7 @@ void SsetB(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, formals);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_set_eval_obj, 4,
+ kmake_continuation(K, kget_cc(K), do_set_eval_obj, 4,
sname, formals, eval_exp, denv);
kset_cc(K, new_cont);
@@ -103,7 +103,7 @@ void do_set_eval_obj(klisp_State *K, TValue *xparams, TValue obj)
TValue env = obj;
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_match, 3,
+ kmake_continuation(K, kget_cc(K), do_match, 3,
formals, env, sname);
kset_cc(K, new_cont);
ktail_eval(K, eval_exp, denv);
@@ -187,7 +187,7 @@ void do_import(klisp_State *K, TValue *xparams, TValue obj)
} else {
TValue env = obj;
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_match, 3,
+ kmake_continuation(K, kget_cc(K), do_match, 3,
symbols, denv, sname);
kset_cc(K, new_cont);
ktail_eval(K, kcons(K, K->list_app, symbols), env);
@@ -214,13 +214,13 @@ void SprovideB(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
/* this will copy the bindings from new_env to denv */
krooted_tvs_push(K, new_env);
TValue import_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_import, 3,
+ kmake_continuation(K, kget_cc(K), do_import, 3,
sname, symbols, denv);
kset_cc(K, import_cont); /* this implicitly roots import_cont */
/* this will ignore the last value and pass the env to the
above continuation */
TValue ret_exp_cont =
- kmake_continuation(K, import_cont, KNIL, KNIL, do_return_value,
+ kmake_continuation(K, import_cont, do_return_value,
1, new_env);
kset_cc(K, ret_exp_cont); /* this implicitly roots ret_exp_cont */
@@ -234,7 +234,7 @@ void SprovideB(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
nil sequence */
TValue tail = kcdr(body);
if (ttispair(tail)) {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, new_env);
kset_cc(K, new_cont);
}
@@ -276,7 +276,7 @@ void SimportB(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, symbols);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_import, 3,
+ kmake_continuation(K, kget_cc(K), do_import, 3,
sname, symbols, denv);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
diff --git a/src/kgenvironments.c b/src/kgenvironments.c
@@ -183,7 +183,7 @@ void do_let(klisp_State *K, TValue *xparams, TValue obj)
nil sequence */
TValue tail = kcdr(body);
if (ttispair(tail)) {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, env);
kset_cc(K, new_cont);
}
@@ -193,7 +193,7 @@ void do_let(klisp_State *K, TValue *xparams, TValue obj)
TValue new_env = kmake_environment(K, env);
krooted_tvs_push(K, new_env);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
kcar(bindings), kcdr(bindings), kcdr(exprs),
new_env, b2tv(false), body);
krooted_tvs_pop(K);
@@ -225,7 +225,7 @@ void Slet(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_env = kmake_environment(K, denv);
krooted_tvs_push(K, new_env);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
bptree, KNIL, KNIL, new_env, b2tv(false), body);
kset_cc(K, new_cont);
@@ -281,7 +281,7 @@ void Sbindsp(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
symbols = check_copy_list(K, "$binds?", symbols, false);
krooted_tvs_push(K, symbols);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_bindsp,
+ TValue new_cont = kmake_continuation(K, kget_cc(K), do_bindsp,
2, symbols, i2tv(count));
krooted_tvs_pop(K);
kset_cc(K, new_cont);
@@ -333,7 +333,7 @@ void SletS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
if (ttisnil(bptree)) {
/* same as $let */
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
bptree, KNIL, KNIL, new_env, b2tv(false), body);
kset_cc(K, new_cont);
@@ -345,7 +345,7 @@ void SletS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
ktail_eval(K, expr, denv);
} else {
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
kcar(bptree), kcdr(bptree), kcdr(exprs),
new_env, b2tv(false), body);
kset_cc(K, new_cont);
@@ -381,7 +381,7 @@ void Sletrec(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, new_env);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
bptree, KNIL, KNIL, new_env, b2tv(true), body);
kset_cc(K, new_cont);
@@ -419,7 +419,7 @@ void SletrecS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
if (ttisnil(bptree)) {
/* same as $letrec */
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
bptree, KNIL, KNIL, new_env, b2tv(true), body);
kset_cc(K, new_cont);
@@ -432,7 +432,7 @@ void SletrecS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
ktail_eval(K, expr, new_env);
} else {
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
kcar(bptree), kcdr(bptree), kcdr(exprs),
new_env, b2tv(true), body);
kset_cc(K, new_cont);
@@ -469,7 +469,7 @@ void do_let_redirect(klisp_State *K, TValue *xparams, TValue obj)
TValue new_env = kmake_environment(K, obj);
krooted_tvs_push(K, new_env);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
bptree, KNIL, KNIL, new_env, b2tv(false), body);
kset_cc(K, new_cont);
@@ -500,7 +500,7 @@ void Slet_redirect(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, eexpr);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let_redirect, 5, sname,
+ kmake_continuation(K, kget_cc(K), do_let_redirect, 5, sname,
bptree, eexpr, denv, body);
kset_cc(K, new_cont);
@@ -538,7 +538,7 @@ void Slet_safe(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue new_env = kmake_environment(K, K->ground_env);
krooted_tvs_push(K, new_env);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname,
+ kmake_continuation(K, kget_cc(K), do_let, 7, sname,
bptree, KNIL, KNIL, new_env, b2tv(false), body);
kset_cc(K, new_cont);
@@ -559,7 +559,7 @@ void Sremote_eval(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
bind_2p(K, "$remote-eval", ptree, obj, env_exp);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_remote_eval, 1, obj);
kset_cc(K, new_cont);
@@ -607,7 +607,7 @@ void Sbindings_to_environment(klisp_State *K, TValue *xparams, TValue ptree,
TValue new_env = kmake_environment(K, KNIL);
krooted_tvs_push(K, new_env);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_b_to_env, 2, bptree, new_env);
kset_cc(K, new_cont);
TValue expr = kcons(K, K->list_app, exprs);
diff --git a/src/kghelpers.h b/src/kghelpers.h
@@ -395,7 +395,7 @@ void do_return_value(klisp_State *K, TValue *xparams, TValue obj);
/* GC: assumes parent & obj are rooted */
inline TValue make_return_value_cont(klisp_State *K, TValue parent, TValue obj)
{
- return kmake_continuation(K, parent, KNIL, KNIL, do_return_value, 1, obj);
+ return kmake_continuation(K, parent, do_return_value, 1, obj);
}
/* Some helpers for working with fixints (signed 32 bits) */
diff --git a/src/kgkd_vars.c b/src/kgkd_vars.c
@@ -101,7 +101,7 @@ inline TValue make_bind_continuation(klisp_State *K, TValue key,
TValue old_flag, TValue old_value,
TValue new_flag, TValue new_value)
{
- TValue unbind_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue unbind_cont = kmake_continuation(K, kget_cc(K),
do_unbind, 3, key, old_flag,
old_value);
krooted_tvs_push(K, unbind_cont);
@@ -132,11 +132,11 @@ inline TValue make_bind_continuation(klisp_State *K, TValue key,
/* this is needed for interception code */
TValue env = kmake_empty_environment(K);
krooted_tvs_push(K, env);
- TValue outer_cont = kmake_continuation(K, unbind_cont, KNIL, KNIL,
+ TValue outer_cont = kmake_continuation(K, unbind_cont,
do_pass_value, 2, entry_guards, env);
kset_outer_cont(outer_cont);
krooted_tvs_push(K, outer_cont);
- TValue inner_cont = kmake_continuation(K, outer_cont, KNIL, KNIL,
+ TValue inner_cont = kmake_continuation(K, outer_cont,
do_pass_value, 2, exit_guards, env);
kset_inner_cont(inner_cont);
diff --git a/src/kgpairs_lists.c b/src/kgpairs_lists.c
@@ -557,7 +557,7 @@ void do_filter(klisp_State *K, TValue *xparams, TValue obj)
TValue new_expr = klist(K, 2, kunwrap(app), first, KNIL);
krooted_tvs_push(K, new_expr);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_filter, 4, app,
+ kmake_continuation(K, kget_cc(K), do_filter, 4, app,
ls, last_pair, new_n);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
@@ -584,14 +584,14 @@ void do_filter_cycle(klisp_State *K, TValue *xparams, TValue obj)
/* this continuation will close the cycle and return the list */
TValue encycle_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_filter_encycle, 2,
+ kmake_continuation(K, kget_cc(K), do_filter_encycle, 2,
dummy, last_apair);
krooted_tvs_push(K, encycle_cont);
/* schedule the filtering of the elements of the cycle */
/* add inert before first element to be discarded when KFALSE
is received */
TValue new_cont =
- kmake_continuation(K, encycle_cont, KNIL, KNIL, do_filter, 4, app,
+ kmake_continuation(K, encycle_cont, do_filter, 4, app,
kcons(K, KINERT, ls), last_apair, cpairs);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
@@ -623,8 +623,8 @@ void filter(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
krooted_tvs_push(K, dummy);
TValue ret_cont = (cpairs == 0)?
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_ret_cdr, 1, dummy)
- : kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_filter_cycle, 3,
+ kmake_continuation(K, kget_cc(K), do_ret_cdr, 1, dummy)
+ : kmake_continuation(K, kget_cc(K), do_filter_cycle, 3,
app, dummy, i2tv(cpairs));
krooted_tvs_pop(K); /* already in cont */
@@ -632,7 +632,7 @@ void filter(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
/* add inert before first element to be discarded when KFALSE
is received */
TValue new_cont =
- kmake_continuation(K, ret_cont, KNIL, KNIL, do_filter, 4, app,
+ kmake_continuation(K, ret_cont, do_filter, 4, app,
kcons(K, KINERT, ls), dummy, i2tv(pairs-cpairs));
kset_cc(K, new_cont);
krooted_tvs_pop(K);
@@ -776,7 +776,7 @@ void do_reduce_prec(klisp_State *K, TValue *xparams, TValue obj)
TValue expr = klist(K, 2, kunwrap(prec), kcar(ls));
krooted_tvs_push(K, expr);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce_prec,
+ kmake_continuation(K, kget_cc(K), do_reduce_prec,
5, first_pair, ls, i2tv(cpairs-1), prec, denv);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
@@ -848,20 +848,20 @@ void do_reduce_cycle(klisp_State *K, TValue *xparams, TValue obj)
if (has_acyclic_partp) {
TValue acyclic_obj = obj;
TValue combine_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce_combine,
+ kmake_continuation(K, kget_cc(K), do_reduce_combine,
3, acyclic_obj, bin, denv);
kset_cc(K, combine_cont); /* implitly rooted */
} /* if there is no acyclic part, just let the result pass through */
TValue post_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce_postc,
+ kmake_continuation(K, kget_cc(K), do_reduce_postc,
2, postc, denv);
kset_cc(K, post_cont); /* implitly rooted */
/* pass one less so that pre_cont can pass the first argument
to the continuation */
TValue in_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce,
+ kmake_continuation(K, kget_cc(K), do_reduce,
4, kcdr(ls), i2tv(cpairs - 1), inc, denv);
kset_cc(K, in_cont);
@@ -871,7 +871,7 @@ void do_reduce_cycle(klisp_State *K, TValue *xparams, TValue obj)
/* pass ls as the first pair to be passed to the do_reduce
continuation */
TValue pre_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce_prec,
+ kmake_continuation(K, kget_cc(K), do_reduce_prec,
5, ls, dummy, i2tv(cpairs), prec, denv);
kset_cc(K, pre_cont);
krooted_tvs_pop(K);
@@ -905,7 +905,7 @@ void do_reduce(klisp_State *K, TValue *xparams, TValue obj)
krooted_tvs_push(K, expr);
TValue new_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce, 4,
+ kmake_continuation(K, kget_cc(K), do_reduce, 4,
kcdr(ls), i2tv(pairs-1), bin, denv);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
@@ -974,7 +974,7 @@ void reduce(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
}
/* make cycle reducing cont */
TValue cyc_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce_cycle, 8,
+ kmake_continuation(K, kget_cc(K), do_reduce_cycle, 8,
first_cycle_pair, i2tv(cpairs), bin, prec,
inc, postc, denv, b2tv(apairs != 0));
kset_cc(K, cyc_cont);
@@ -990,7 +990,7 @@ void reduce(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
and not a regular pair to allow the above case of
a one element list to signal no acyclic part */
TValue acyc_cont =
- kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_reduce, 4,
+ kmake_continuation(K, kget_cc(K), do_reduce, 4,
kcdr(ls), i2tv(apairs-1), bin, denv);
kset_cc(K, acyc_cont);
res = kcar(ls);
diff --git a/src/kgports.c b/src/kgports.c
@@ -68,7 +68,7 @@ void with_file(klisp_State *K, TValue *xparams, TValue ptree,
TValue new_port = kmake_port(K, filename, writep);
krooted_tvs_push(K, new_port);
/* make the continuation to close the file before returning */
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_close_file_ret, 1, new_port);
kset_cc(K, new_cont); /* cont implicitly rooted */
krooted_tvs_pop(K); /* new_port is in cont */
@@ -359,7 +359,7 @@ void call_with_file(klisp_State *K, TValue *xparams, TValue ptree,
TValue new_port = kmake_port(K, filename, writep);
krooted_tvs_push(K, new_port);
/* make the continuation to close the file before returning */
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_close_file_ret, 1, new_port);
kset_cc(K, new_cont); /* implicit rooting */
krooted_tvs_pop(K); /* new_port is in new_cont */
@@ -441,11 +441,11 @@ TValue make_guarded_read_cont(klisp_State *K, TValue parent, TValue port)
/* this is needed for interception code */
TValue env = kmake_empty_environment(K);
krooted_tvs_push(K, env);
- TValue outer_cont = kmake_continuation(K, parent, KNIL, KNIL,
+ TValue outer_cont = kmake_continuation(K, parent,
do_pass_value, 2, entry_guards, env);
kset_outer_cont(outer_cont);
krooted_tvs_push(K, outer_cont);
- TValue inner_cont = kmake_continuation(K, outer_cont, KNIL, KNIL,
+ TValue inner_cont = kmake_continuation(K, outer_cont,
do_pass_value, 2, exit_guards, env);
kset_inner_cont(inner_cont);
krooted_tvs_pop(K); krooted_tvs_pop(K); krooted_tvs_pop(K);
@@ -497,7 +497,7 @@ void load(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue tail = kcdr(ls);
if (ttispair(tail)) {
krooted_tvs_push(K, ls);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, denv);
kset_cc(K, new_cont);
krooted_tvs_pop(K); /* ls */
@@ -549,7 +549,7 @@ void get_module(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
TValue tail = kcdr(ls);
if (ttispair(tail)) {
krooted_tvs_push(K, ls);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
do_seq, 2, tail, env);
kset_cc(K, new_cont);
krooted_tvs_pop(K);
diff --git a/src/kgpromises.c b/src/kgpromises.c
@@ -50,7 +50,7 @@ void handle_result(klisp_State *K, TValue *xparams, TValue obj)
/* promise was already determined */
kapply_cc(K, expr);
} else {
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
+ TValue new_cont = kmake_continuation(K, kget_cc(K),
handle_result, 1, prom);
kset_cc(K, new_cont);
ktail_eval(K, expr, maybe_env);
@@ -78,8 +78,7 @@ void force(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
} else {
TValue expr = kpromise_exp(obj);
TValue env = kpromise_maybe_env(obj);
- TValue new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- handle_result, 1, obj);
+ TValue new_cont = kmake_continuation(K, kget_cc(K), handle_result, 1, obj);
kset_cc(K, new_cont);
ktail_eval(K, expr, env);
}
diff --git a/src/krepl.c b/src/krepl.c
@@ -74,12 +74,10 @@ inline void create_loop(klisp_State *K, TValue denv)
{
/* GC: the intermediate conts are protected by the
others */
- TValue loop_cont = kmake_continuation(
- K, K->root_cont, KNIL, KNIL, &loop_fn, 1, denv);
- TValue eval_cont = kmake_continuation(
- K, loop_cont, KNIL, KNIL, &eval_cfn, 1, denv);
- TValue read_cont = kmake_continuation(
- K, eval_cont, KNIL, KNIL, &read_fn, 0);
+ TValue loop_cont =
+ kmake_continuation(K, K->root_cont, &loop_fn, 1, denv);
+ TValue eval_cont = kmake_continuation(K, loop_cont, &eval_cfn, 1, denv);
+ TValue read_cont = kmake_continuation(K, eval_cont, &read_fn, 0);
kset_cc(K, read_cont);
kapply_cc(K, KINERT);
}
@@ -125,15 +123,11 @@ void kinit_repl(klisp_State *K)
krooted_tvs_push(K, std_env);
/* set up the continuations */
- TValue root_cont = kmake_continuation(K, KNIL, KNIL, KNIL,
- exit_fn, 0);
+ TValue root_cont = kmake_continuation(K, KNIL, exit_fn, 0);
krooted_tvs_push(K, root_cont);
- TValue error_cont = kmake_continuation(K, root_cont, KNIL, KNIL,
- error_fn, 1, std_env);
-
-
+ TValue error_cont = kmake_continuation(K, root_cont, error_fn, 1, std_env);
krooted_tvs_push(K, error_cont);
/* update the ground environment with these two conts */
diff --git a/src/kstate.c b/src/kstate.c
@@ -440,8 +440,8 @@ void kcall_cont(klisp_State *K, TValue dst_cont, TValue obj)
krooted_tvs_push(K, int_ls);
/* we have to contruct a continuation to do the interceptions
in order and finally call dst_cont if no divert occurs */
- new_cont = kmake_continuation(K, kget_cc(K), KNIL, KNIL,
- do_interception, 2, int_ls, dst_cont);
+ new_cont = kmake_continuation(K, kget_cc(K), do_interception,
+ 2, int_ls, dst_cont);
krooted_tvs_pop(K);
}