summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-04-01 19:47:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-04-01 19:47:56 -0700
commit87ed8a692c059f1e81f8deeea3b4f727044a45fa (patch)
treeb8f86e21ef965c2dbb0c3f8e8621760a62cf1943 /eval.c
parent34d0567bce45cc89fc6f476353b00b2649bcce4d (diff)
downloadtxr-87ed8a692c059f1e81f8deeea3b4f727044a45fa.tar.gz
txr-87ed8a692c059f1e81f8deeea3b4f727044a45fa.tar.bz2
txr-87ed8a692c059f1e81f8deeea3b4f727044a45fa.zip
Start of ground-work for ephemeral GC. We must add some abstraction
to places where we potentially assign a reference to a younger object inside a field located in an older object (chronological backreference) and also where we take the address of an object field, making it possible that the user of the address will do so. This patch does not take care of vectors. No, this is not an April Fool's joke. * eval.c (env_fbind, env_vbind, env_replace_vbind, lookup_var, lookup_sym_lisp1): Use set macro instead of assignment. * hash.c (hash_grow, set_hash_userdata, hash_next): Use set macro instead of assignment. * lib.c (rplaca, rplacd, string_extend, length_str, replace_str, rehome_sym, lazy_stream_func, lazy_str, lazy_str_force, lazy_str_force_upto, obj_init): Use set macro instead of assignment. (car_l, cdr_l): Use loc instead of address-of operator. * lib.h (set, loc): New macros.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index b79b88f1..ff348b8d 100644
--- a/eval.c
+++ b/eval.c
@@ -82,21 +82,21 @@ val make_env(val vbindings, val fbindings, val up_env)
val env_fbind(val env, val sym, val fun)
{
type_check(env, ENV);
- env->e.fbindings = acons_new(sym, fun, env->e.fbindings);
+ set(env->e.fbindings, acons_new(sym, fun, env->e.fbindings));
return sym;
}
val env_vbind(val env, val sym, val obj)
{
type_check(env, ENV);
- env->e.vbindings = acons_new(sym, obj, env->e.vbindings);
+ set(env->e.vbindings, acons_new(sym, obj, env->e.vbindings));
return sym;
}
static void env_replace_vbind(val env, val bindings)
{
type_check(env, ENV);
- env->e.vbindings = bindings;
+ set(env->e.vbindings, bindings);
}
noreturn static val eval_error(val form, val fmt, ...)
@@ -120,7 +120,7 @@ val lookup_var(val env, val sym)
val bind = gethash(top_vb, sym);
if (cobjp(bind)) {
struct c_var *cv = (struct c_var *) cptr_get(bind);
- cv->bind->c.cdr = *cv->loc;
+ set(cv->bind->c.cdr, *cv->loc);
return cv->bind;
}
return bind;
@@ -183,7 +183,7 @@ static val lookup_sym_lisp1(val env, val sym)
val bind = gethash(top_vb, sym);
if (cobjp(bind)) {
struct c_var *cv = (struct c_var *) cptr_get(bind);
- cv->bind->c.cdr = *cv->loc;
+ set(cv->bind->c.cdr, *cv->loc);
return cv->bind;
}
return or2(bind, gethash(top_fb, sym));