commit 324776cf38b0ff856208a2edb78849f5fe53aaff
parent 207af60949a35641f556f5644702c2187f9e8bce
Author: Andres Navarro <canavarro82@gmail.com>
Date: Thu, 1 Dec 2011 23:37:35 -0300
Refactor: removed dummy lists, in preparation for new cleaner c interface
Diffstat:
14 files changed, 123 insertions(+), 180 deletions(-)
diff --git a/src/kenvironment.c b/src/kenvironment.c
@@ -55,7 +55,9 @@ TValue kmake_environment(klisp_State *K, TValue parents)
} else {
/* list of parents, for now, just append them */
krooted_tvs_push(K, gc2env(new_env)); /* keep the new env rooted */
- TValue tail = kget_dummy1(K); /* keep the list rooted */
+ TValue plist = kcons(K, KNIL, KNIL); /* keep the list rooted */
+ krooted_vars_push(K, &plist);
+ TValue tail = plist;
while(!ttisnil(parents)) {
TValue parent = kcar(parents);
TValue pkparents = env_keyed_parents(parent);
@@ -74,8 +76,9 @@ TValue kmake_environment(klisp_State *K, TValue parents)
}
parents = kcdr(parents);
}
- /* all alocation done */
- kparents = kcutoff_dummy1(K);
+ /* all alocation done */
+ kparents = kcdr(plist);
+ krooted_vars_pop(K);
krooted_tvs_pop(K);
/* if it's just one env switch from (env) to env. */
if (ttispair(kparents) && ttisnil(kcdr(kparents)))
diff --git a/src/kerror.c b/src/kerror.c
@@ -63,10 +63,6 @@ void clear_buffers(klisp_State *K)
ks_tbclear(K);
K->shared_dict = KNIL;
- UNUSED(kcutoff_dummy1(K));
- UNUSED(kcutoff_dummy2(K));
- UNUSED(kcutoff_dummy3(K));
-
krooted_tvs_clear(K);
krooted_vars_clear(K);
}
diff --git a/src/kgc.c b/src/kgc.c
@@ -627,8 +627,8 @@ static void markroot (klisp_State *K) {
markvalue(K, K->curr_port);
/* Mark all objects in the auxiliary stack,
- (all valid indexes are below top), all the objects in
- the two protected areas, and the three dummy pairs */
+ (all valid indexes are below top) and all the objects in
+ the two protected areas */
markvaluearray(K, K->sbuf, K->stop);
markvaluearray(K, K->rooted_tvs_buf, K->rooted_tvs_top);
/* the area protecting variables is an array of type TValue *[] */
@@ -637,9 +637,6 @@ static void markroot (klisp_State *K) {
markvalue(K, **ptr);
}
- markvalue(K, K->dummy_pair1);
- markvalue(K, K->dummy_pair2);
- markvalue(K, K->dummy_pair3);
K->gcstate = GCSpropagate;
}
diff --git a/src/kgcontrol.c b/src/kgcontrol.c
@@ -125,14 +125,19 @@ void Ssequence(klisp_State *K)
TValue split_check_cond_clauses(klisp_State *K, TValue clauses,
TValue *bodies)
{
- TValue last_car_pair = kget_dummy1(K);
- TValue last_cdr_pair = kget_dummy2(K);
+ TValue cars = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &cars);
+ TValue last_car_pair = cars;
+
+ TValue cdrs = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &cdrs);
+ TValue last_cdr_pair = cdrs;
TValue tail = clauses;
int32_t count = 0;
while(ttispair(tail) && !kis_marked(tail)) {
- count++;
+ ++count;
TValue first = kcar(tail);
if (!ttispair(first)) {
unmark_list(K, clauses);
@@ -164,25 +169,26 @@ TValue split_check_cond_clauses(klisp_State *K, TValue clauses,
if (!ttispair(tail) && !ttisnil(tail)) {
klispE_throw_simple(K, "expected list (clauses)");
return KNIL;
- } else {
- /*
- check all the bodies (should be lists), and
- make a copy of the list structure.
- couldn't be done before because this uses
- marks, count is used because it may be a cyclic list
- */
- tail = kget_dummy2_tail(K);
- while(count--) {
- TValue first = kcar(tail);
- /* this uses dummy3 */
- TValue copy = check_copy_list(K, first, false, NULL, NULL);
- kset_car(tail, copy);
- tail = kcdr(tail);
- }
+ }
- *bodies = kcutoff_dummy2(K);
- return kcutoff_dummy1(K);
+ /*
+ check all the bodies (should be lists), and
+ make a copy of the list structure.
+ couldn't be done before because this uses
+ marks, count is used because it may be a cyclic list
+ */
+ tail = kcdr(cdrs);
+ while(count--) {
+ TValue first = kcar(tail);
+ TValue copy = check_copy_list(K, first, false, NULL, NULL);
+ kset_car(tail, copy);
+ tail = kcdr(tail);
}
+
+ *bodies = kcdr(cdrs);
+ krooted_vars_pop(K);
+ krooted_vars_pop(K);
+ return kcdr(cars);
}
/* Helper for the $cond continuation */
diff --git a/src/kgenv_mut.c b/src/kgenv_mut.c
@@ -145,13 +145,15 @@ inline void unmark_maybe_symbol_list(klisp_State *K, TValue ls)
** Check that obj is a finite list of symbols with no duplicates and
** returns a copy of the list (cf. check_copy_ptree)
*/
-/* GC: Assumes obj is rooted, uses dummy1 */
+/* GC: Assumes obj is rooted */
TValue check_copy_symbol_list(klisp_State *K, TValue obj)
{
TValue tail = obj;
bool type_errorp = false;
bool repeated_errorp = false;
- TValue last_pair = kget_dummy1(K);
+ TValue slist = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &slist);
+ TValue last_pair = slist;
while(ttispair(tail) && !kis_marked(tail)) {
/* even if there is a type error continue checking the structure */
@@ -182,7 +184,8 @@ TValue check_copy_symbol_list(klisp_State *K, TValue obj)
} else if (repeated_errorp) {
klispE_throw_simple(K, "repeated symbols");
}
- return kcutoff_dummy1(K);
+ krooted_vars_pop(K);
+ return kcdr(slist);
}
void do_import(klisp_State *K)
diff --git a/src/kgenvironments.c b/src/kgenvironments.c
@@ -100,12 +100,16 @@ void make_environment(klisp_State *K)
** If bindings is not finite (or not a list) an error is signaled.
*/
-/* GC: assume bindings is rooted, uses dummys 1 & 2 */
+/* GC: assume bindings is rooted */
TValue split_check_let_bindings(klisp_State *K, TValue bindings,
TValue *exprs, bool starp)
{
- TValue last_car_pair = kget_dummy1(K);
- TValue last_cadr_pair = kget_dummy2(K);
+ TValue cars = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &cars);
+ TValue last_car_pair = cars;
+ TValue cadrs = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &cadrs);
+ TValue last_cadr_pair = cadrs;
TValue tail = bindings;
@@ -142,20 +146,21 @@ TValue split_check_let_bindings(klisp_State *K, TValue bindings,
if (starp) {
/* all bindings are consider individual ptrees in these 'let's,
replace each ptree with its copy (after checking of course) */
- tail = kget_dummy1_tail(K);
+ tail = kcdr(cars);
while(!ttisnil(tail)) {
TValue first = kcar(tail);
TValue copy = check_copy_ptree(K, first, KIGNORE);
kset_car(tail, copy);
tail = kcdr(tail);
}
- res = kget_dummy1_tail(K);
+ res = kcdr(cars);
} else {
/* all bindings are consider one ptree in these 'let's */
- res = check_copy_ptree(K, kget_dummy1_tail(K), KIGNORE);
+ res = check_copy_ptree(K, kcdr(cars), KIGNORE);
}
- *exprs = kcutoff_dummy2(K);
- UNUSED(kcutoff_dummy1(K));
+ *exprs = kcdr(cadrs);
+ krooted_vars_pop(K);
+ krooted_vars_pop(K);
return res;
}
}
diff --git a/src/kghelpers.c b/src/kghelpers.c
@@ -465,7 +465,9 @@ TValue check_copy_list(klisp_State *K, TValue obj, bool force_copy,
check_list(K, true, obj, pairs, cpairs);
return obj;
} else {
- TValue last_pair = kget_dummy3(K);
+ TValue copy = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, ©);
+ TValue last_pair = copy;
TValue tail = obj;
while(ttispair(tail) && !kis_marked(tail)) {
@@ -496,19 +498,22 @@ TValue check_copy_list(klisp_State *K, TValue obj, bool force_copy,
}
unmark_list(K, obj);
- unmark_list(K, kget_dummy3_tail(K));
+ unmark_list(K, kcdr(copy));
if (!ttispair(tail) && !ttisnil(tail)) {
klispE_throw_simple(K, "expected list");
return KINERT;
}
- return kcutoff_dummy3(K);
+ krooted_vars_pop(K);
+ return kcdr(copy);
}
}
TValue check_copy_env_list(klisp_State *K, TValue obj)
{
- TValue last_pair = kget_dummy3(K);
+ TValue copy = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, ©);
+ TValue last_pair = copy;
TValue tail = obj;
while(ttispair(tail) && !kis_marked(tail)) {
@@ -531,7 +536,8 @@ TValue check_copy_env_list(klisp_State *K, TValue obj)
klispE_throw_simple(K, "expected list");
return KINERT;
}
- return kcutoff_dummy3(K);
+ krooted_vars_pop(K);
+ return kcdr(copy);
}
/* Helpers for string, list->string, and string-map,
@@ -1398,16 +1404,20 @@ void map_for_each_get_metrics(klisp_State *K, TValue lss,
/* Return two lists, isomorphic to lss: one list of cars and one list
of cdrs (replacing the value of lss) */
-/* GC: assumes lss is rooted, and dummy1 & 2 are free in K */
+/* GC: assumes lss is rooted */
TValue map_for_each_get_cars_cdrs(klisp_State *K, TValue *lss,
int32_t apairs, int32_t cpairs)
{
TValue tail = *lss;
- TValue lp_cars = kget_dummy1(K);
+ TValue cars = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &cars);
+ TValue lp_cars = cars;
TValue lap_cars = lp_cars;
- TValue lp_cdrs = kget_dummy2(K);
+ TValue cdrs = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &cdrs);
+ TValue lp_cdrs = cdrs;
TValue lap_cdrs = lp_cdrs;
while(apairs != 0 || cpairs != 0) {
@@ -1452,8 +1462,10 @@ TValue map_for_each_get_cars_cdrs(klisp_State *K, TValue *lss,
}
}
- *lss = kcutoff_dummy2(K);
- return kcutoff_dummy1(K);
+ krooted_vars_pop(K);
+ krooted_vars_pop(K);
+ *lss = kcdr(cdrs);
+ return kcdr(cars);
}
/* Transpose lss so that the result is a list of lists, each one having
@@ -1465,8 +1477,9 @@ TValue map_for_each_transpose(klisp_State *K, TValue lss,
int32_t app_apairs, int32_t app_cpairs,
int32_t res_apairs, int32_t res_cpairs)
{
- /* reserve dummy1 & 2 to get_cars_cdrs */
- TValue lp = kget_dummy3(K);
+ TValue tlist = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &tlist);
+ TValue lp = tlist;
TValue lap = lp;
TValue cars = KNIL; /* put something for GC */
@@ -1512,7 +1525,8 @@ TValue map_for_each_transpose(klisp_State *K, TValue lss,
krooted_vars_pop(K);
krooted_vars_pop(K);
- return kcutoff_dummy3(K);
+ krooted_vars_pop(K);
+ return kcdr(tlist);
}
/* Continuations that are used in more than one file */
@@ -1756,7 +1770,7 @@ TValue make_bind_continuation(klisp_State *K, TValue key,
/* this unmarks root before throwing any error */
/* TODO: this isn't very clean, refactor */
-/* GC: assumes obj & root are rooted, dummy1 is in use */
+/* GC: assumes obj & root are rooted */
inline TValue check_copy_single_entry(klisp_State *K, char *name,
TValue obj, TValue root)
{
@@ -1794,7 +1808,9 @@ TValue check_copy_guards(klisp_State *K, char *name, TValue obj)
if (ttisnil(obj)) {
return obj;
} else {
- TValue last_pair = kget_dummy1(K);
+ TValue copy = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, ©);
+ TValue last_pair = copy;
TValue tail = obj;
while(ttispair(tail) && !kis_marked(tail)) {
@@ -1812,12 +1828,12 @@ TValue check_copy_guards(klisp_State *K, char *name, TValue obj)
/* dont close the cycle (if there is one) */
unmark_list(K, obj);
- TValue ret = kcutoff_dummy1(K);
if (!ttispair(tail) && !ttisnil(tail)) {
klispE_throw_simple(K, "expected list");
return KINERT;
}
- return ret;
+ krooted_vars_pop(K);
+ return kcdr(copy);
}
}
diff --git a/src/kghelpers.h b/src/kghelpers.h
@@ -351,13 +351,13 @@ void check_list(klisp_State *K, bool allow_infp, TValue obj,
/* TODO: add check_copy_typed_list */
/* check that obj is a list and make a copy if it is not immutable or
force_copy is true */
-/* GC: assumes obj is rooted, use dummy3 */
+/* GC: assumes obj is rooted */
TValue check_copy_list(klisp_State *K, TValue obj, bool force_copy,
int32_t *pairs, int32_t *cpairs);
/* check that obj is a list of environments and make a copy but don't keep
the cycles */
-/* GC: assume obj is rooted, uses dummy3 */
+/* GC: assume obj is rooted */
TValue check_copy_env_list(klisp_State *K, TValue obj);
/* The assimetry in error checking in the following functions
@@ -486,7 +486,7 @@ void map_for_each_get_metrics(
/* Return two lists, isomorphic to lss: one list of cars and one list
of cdrs (replacing the value of lss) */
-/* GC: Assumes lss is rooted, uses dummys 2 & 3 */
+/* GC: Assumes lss is rooted */
TValue map_for_each_get_cars_cdrs(klisp_State *K, TValue *lss,
int32_t apairs, int32_t cpairs);
@@ -494,8 +494,7 @@ TValue map_for_each_get_cars_cdrs(klisp_State *K, TValue *lss,
metrics (app_apairs, app_cpairs). The metrics of the returned list
should be (res_apairs, res_cpairs) */
-/* GC: Assumes lss is rooted, uses dummys 1, &
- (through get_cars_cdrs, 2, 3) */
+/* GC: Assumes lss is rooted */
TValue map_for_each_transpose(klisp_State *K, TValue lss,
int32_t app_apairs, int32_t app_cpairs,
int32_t res_apairs, int32_t res_cpairs);
diff --git a/src/kgpair_mut.c b/src/kgpair_mut.c
@@ -242,11 +242,13 @@ inline void appendB_clear_last_pairs(klisp_State *K, TValue ls)
objects (1 based) should be set to the next object in the list (this will
encycle! the result if necessary) */
-/* GC: Assumes lss is rooted, uses dummy1 */
+/* GC: Assumes lss is rooted */
TValue appendB_get_lss_endpoints(klisp_State *K, TValue lss, int32_t apairs,
int32_t cpairs)
{
- TValue last_pair = kget_dummy1(K);
+ TValue elist = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &elist);
+ TValue last_pair = elist;
TValue tail = lss;
/* this is a list of last pairs using the marks to link the pairs) */
TValue last_pairs = KNIL;
@@ -373,7 +375,8 @@ TValue appendB_get_lss_endpoints(klisp_State *K, TValue lss, int32_t apairs,
/* discard the first element (there is always one) because it
isn't necessary, the list is used to set the last pairs of
the objects to the correspoding next first pair */
- return kcdr(kcutoff_dummy1(K));
+ krooted_vars_pop(K);
+ return kcdr(kcdr(elist));
}
/* 6.4.1 append! */
diff --git a/src/kgpairs_lists.c b/src/kgpairs_lists.c
@@ -79,7 +79,9 @@ void listS(klisp_State *K)
klispE_throw_simple(K, "empty argument list");
return;
}
- TValue last_pair = kget_dummy1(K);
+ TValue res_obj = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &res_obj);
+ TValue last_pair = res_obj;
TValue tail = ptree;
/* First copy the list, but remembering the next to last pair */
@@ -100,7 +102,8 @@ void listS(klisp_State *K)
we need at least one pair for this to work. */
TValue next_to_last_pair = kcdr(last_pair);
kset_cdr(next_to_last_pair, kcar(last_pair));
- kapply_cc(K, kcutoff_dummy1(K));
+ krooted_vars_pop(K);
+ kapply_cc(K, kcdr(res_obj));
} else if (ttispair(tail)) { /* cyclic argument list */
klispE_throw_simple(K, "cyclic argument list");
return;
@@ -372,7 +375,7 @@ void list_ref(klisp_State *K)
(as the ret value) and the last_pair. If obj is nil, *last_pair remains
unmodified (this avoids having to check ttisnil before calling this) */
-/* GC: Assumes obj is rooted, uses dummy1 */
+/* GC: Assumes obj is rooted */
TValue append_check_copy_list(klisp_State *K, char *name, TValue obj,
TValue *last_pair_ptr)
{
@@ -380,7 +383,9 @@ TValue append_check_copy_list(klisp_State *K, char *name, TValue obj,
if (ttisnil(obj))
return obj;
- TValue last_pair = kget_dummy1(K);
+ TValue copy = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, ©);
+ TValue last_pair = copy;
TValue tail = obj;
while(ttispair(tail) && !kis_marked(tail)) {
@@ -400,7 +405,8 @@ TValue append_check_copy_list(klisp_State *K, char *name, TValue obj,
return KINERT;
}
*last_pair_ptr = last_pair;
- return kcutoff_dummy1(K);
+ krooted_vars_pop(K);
+ return (kcdr(copy));
}
/* 6.3.3 append */
@@ -417,8 +423,9 @@ void append(klisp_State *K)
check_list(K, true, ptree, &pairs, &cpairs);
int32_t apairs = pairs - cpairs;
- /* use dummy2, append_check_copy uses dummy1 */
- TValue last_pair = kget_dummy2(K);
+ TValue res_list = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &res_list);
+ TValue last_pair = res_list;
TValue lss = ptree;
TValue last_apair;
@@ -466,7 +473,8 @@ void append(klisp_State *K)
kset_cdr(last_cpair, first_cpair); /* encycle! */
}
}
- kapply_cc(K, kcutoff_dummy2(K));
+ krooted_vars_pop(K);
+ kapply_cc(K, kcdr(res_list));
}
/* 6.3.4 list-neighbors */
@@ -486,7 +494,9 @@ void list_neighbors(klisp_State *K)
TValue tail = ls;
int32_t count = cpairs? pairs - cpairs : pairs - 1;
- TValue last_pair = kget_dummy1(K);
+ TValue neighbors = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &neighbors);
+ TValue last_pair = neighbors;
TValue last_apair = last_pair; /* set after first loop */
bool doing_cycle = false;
@@ -516,7 +526,8 @@ void list_neighbors(klisp_State *K)
/* this will loop once more */
}
}
- kapply_cc(K, kcutoff_dummy1(K));
+ krooted_vars_pop(K);
+ kapply_cc(K, kcdr(neighbors));
}
/* Helpers for filter */
diff --git a/src/kpair.c b/src/kpair.c
@@ -37,8 +37,6 @@ TValue klist_g(klisp_State *K, bool m, int32_t n, ...)
klisp_assert(n < MAX_LIST_N);
- /* don't use any of the klisp dummys, because this is
- called from many places */
TValue dummy = kcons_g(K, m, KINERT, KNIL);
krooted_tvs_push(K, dummy);
TValue tail = dummy;
diff --git a/src/kpair.h b/src/kpair.h
@@ -102,67 +102,4 @@ TValue klist_g(klisp_State *K, bool m, int32_t n, ...);
#define klist(K_, n_, ...) (klist_g(K_, true, n_, __VA_ARGS__))
#define kimm_list(K_, n_, ...) (klist_g(K_, false, n_, __VA_ARGS__))
-/* TODO/REFACTOR: delete these functions, instead use
- a pushed var */
-
-inline TValue kget_dummy1(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair1) && ttisnil(kcdr(K->dummy_pair1)));
- return K->dummy_pair1;
-}
-
-inline TValue kget_dummy1_tail(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair1));
- return kcdr(K->dummy_pair1);
-}
-
-inline TValue kcutoff_dummy1(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair1));
- TValue res = kcdr(K->dummy_pair1);
- kset_cdr(K->dummy_pair1, KNIL);
- return res;
-}
-
-inline TValue kget_dummy2(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair2) && ttisnil(kcdr(K->dummy_pair2)));
- return K->dummy_pair2;
-}
-
-inline TValue kget_dummy2_tail(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair2));
- return kcdr(K->dummy_pair2);
-}
-
-inline TValue kcutoff_dummy2(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair2));
- TValue res = kcdr(K->dummy_pair2);
- kset_cdr(K->dummy_pair2, KNIL);
- return res;
-}
-
-inline TValue kget_dummy3(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair3) && ttisnil(kcdr(K->dummy_pair3)));
- return K->dummy_pair3;
-}
-
-inline TValue kget_dummy3_tail(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair3));
- return kcdr(K->dummy_pair3);
-}
-
-inline TValue kcutoff_dummy3(klisp_State *K)
-{
- klisp_assert(ttispair(K->dummy_pair3));
- TValue res = kcdr(K->dummy_pair3);
- kset_cdr(K->dummy_pair3, KNIL);
- return res;
-}
-
#endif
diff --git a/src/kstate.c b/src/kstate.c
@@ -127,10 +127,6 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) {
K->rooted_tvs_top = 0;
K->rooted_vars_top = 0;
- K->dummy_pair1 = kcons(K, KINERT, KNIL);
- K->dummy_pair2 = kcons(K, KINERT, KNIL);
- K->dummy_pair3 = kcons(K, KINERT, KNIL);
-
/* initialize strings */
/* initial size of string/symbol table */
@@ -425,12 +421,14 @@ TValue select_interceptor(TValue guard_ls)
** (interceptor-op outer_cont . denv)
*/
-/* GC: assume src_cont & dst_cont are rooted, uses dummy1 */
+/* GC: assume src_cont & dst_cont are rooted */
inline TValue create_interception_list(klisp_State *K, TValue src_cont,
TValue dst_cont)
{
mark_iancestors(dst_cont);
- TValue tail = kget_dummy1(K);
+ TValue ilist = kcons(K, KNIL, KNIL);
+ krooted_vars_push(K, &ilist);
+ TValue tail = ilist;
TValue cont = src_cont;
/* exit guards are from the inside to the outside, and
@@ -501,7 +499,8 @@ inline TValue create_interception_list(klisp_State *K, TValue src_cont,
/* all interceptions collected, append the two lists and return */
kset_cdr(tail, entry_int);
krooted_vars_pop(K);
- return kcutoff_dummy1(K);
+ krooted_vars_pop(K);
+ return kcdr(ilist);
}
/* this passes the operand tree to the continuation */
diff --git a/src/kstate.h b/src/kstate.h
@@ -170,15 +170,6 @@ struct klisp_State {
object pointed to by a variable may change */
int32_t rooted_vars_top;
TValue *rooted_vars_buf[GC_PROTECT_SIZE];
-
- /* XXX These should be replaced with calls to krooted_vars_push */
- /* These three are useful for constructing lists by means of set-car &
- set-cdr. The idea is that these dummy pairs start as the head of
- the list (protecting the entire chain from GC) and at the end of the
- construction, the list is cut off from the cdr of the dummy */
- TValue dummy_pair1;
- TValue dummy_pair2;
- TValue dummy_pair3;
};
/* some size related macros */
@@ -357,15 +348,6 @@ inline void krooted_vars_pop(klisp_State *K)
inline void krooted_vars_clear(klisp_State *K) { K->rooted_vars_top = 0; }
-/* dummy functions will be in kpair.h, because we can't include
- it from here */
-
-/* XXX: this is ugly but we can't include kpair.h here so... */
-/* MAYBE: move car & cdr to kobject.h */
-#define kstate_car(p_) (tv2pair(p_)->car)
-#define kstate_cdr(p_) (tv2pair(p_)->cdr)
-
-
/*
** Source code tracking
** MAYBE: add source code tracking to symbols
@@ -418,12 +400,6 @@ inline void klispS_apply_cc(klisp_State *K, TValue val)
/* TODO add marks assertions */
klisp_assert(K->rooted_tvs_top == 0);
klisp_assert(K->rooted_vars_top == 0);
- klisp_assert(ttispair(K->dummy_pair1) &&
- ttisnil(kstate_cdr(K->dummy_pair1)));
- klisp_assert(ttispair(K->dummy_pair2) &&
- ttisnil(kstate_cdr(K->dummy_pair2)));
- klisp_assert(ttispair(K->dummy_pair3) &&
- ttisnil(kstate_cdr(K->dummy_pair3)));
K->next_obj = K->curr_cont; /* save it from GC */
Continuation *cont = tv2cont(K->curr_cont);
@@ -460,12 +436,6 @@ inline void klispS_tail_call_si(klisp_State *K, TValue top, TValue ptree,
/* various assert to check the freeing of gc protection methods */
klisp_assert(K->rooted_tvs_top == 0);
klisp_assert(K->rooted_vars_top == 0);
- klisp_assert(ttispair(K->dummy_pair1) &&
- ttisnil(kstate_cdr(K->dummy_pair1)));
- klisp_assert(ttispair(K->dummy_pair2) &&
- ttisnil(kstate_cdr(K->dummy_pair2)));
- klisp_assert(ttispair(K->dummy_pair3) &&
- ttisnil(kstate_cdr(K->dummy_pair3)));
K->next_obj = top;
Operative *op = tv2op(top);