klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 08427dd3e9d0748875ee124cb47414c6bcd9f960
parent 141c1a0e25050e10862828398ad57caa3ccf4fc2
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Mon, 28 Mar 2011 15:41:10 -0300

Added $let-safe to the ground environment.

Diffstat:
Msrc/kgenvironments.c | 25++++++++++++++++++++++++-
Msrc/kgenvironments.h | 2+-
Msrc/kground.c | 2+-
3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/kgenvironments.c b/src/kgenvironments.c @@ -256,7 +256,30 @@ void make_kernel_standard_environment(klisp_State *K, TValue *xparams, /* TODO */ /* 6.7.8 $let-safe */ -/* TODO */ +void Slet_safe(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) +{ + /* + ** xparams[0]: symbol name + */ + TValue sname = xparams[0]; + char *name = ksymbol_buf(sname); + bind_al1p(K, name, ptree, bindings, body); + + TValue exprs; + TValue bptree = split_check_let_bindings(K, name, bindings, &exprs, false); + int32_t dummy; + UNUSED(check_list(K, name, true, body, &dummy)); + body = copy_es_immutable_h(K, name, body, false); +/* according to the definition of the report it should be a child + of a child of the ground environment, but since this is a fresh + environment, the semantics are the same */ + TValue new_env = kmake_environment(K, K->ground_env); + TValue new_cont = + kmake_continuation(K, kget_cc(K), KNIL, KNIL, do_let, 7, sname, + bptree, KNIL, KNIL, new_env, b2tv(false), body); + kset_cc(K, new_cont); + ktail_eval(K, kcons(K, K->list_app, exprs), denv); +} /* 6.7.9 $remote-eval */ void Sremote_eval(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) diff --git a/src/kgenvironments.h b/src/kgenvironments.h @@ -62,7 +62,7 @@ void make_kernel_standard_environment(klisp_State *K, TValue *xparams, /* TODO */ /* 6.7.8 $let-safe */ -/* TODO */ +void Slet_safe(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* 6.7.9 $remote-eval */ void Sremote_eval(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); diff --git a/src/kground.c b/src/kground.c @@ -464,7 +464,7 @@ void kinit_ground_env(klisp_State *K) /* TODO */ /* 6.7.8 $let-safe */ - /* TODO */ + add_operative(K, ground_env, "$let-safe", Slet_safe, 1, symbol); /* 6.7.9 $remote-eval */ add_operative(K, ground_env, "$remote-eval", Sremote_eval, 0);