klisp

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

commit 90407b21e64662ae8d42db02f50412c79a32925b
parent a0fa1c4ae1a4297d91683334db5b4514ce517b5a
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 29 Apr 2011 19:24:44 -0300

Added all known continuation functions to the table with generic names derived from the function name. TODO: put better names, and, where possible provide better source info (like in $and? and $sequence).

Diffstat:
Msrc/keval.h | 2++
Msrc/kgcombiners.h | 7+++++++
Msrc/kgcontinuations.h | 3+++
Msrc/kgcontrol.c | 6+++---
Msrc/kgcontrol.h | 9+++++----
Msrc/kgenvironments.h | 2++
Msrc/kgkd_vars.h | 2++
Msrc/kgpairs_lists.h | 11+++++++++++
Msrc/kgports.h | 2++
Msrc/kgpromises.c | 7++++---
Msrc/kgpromises.h | 2++
Msrc/kground.c | 35+++++++++++++++++++++++++++++++++++
Msrc/kstate.h | 2++
13 files changed, 80 insertions(+), 10 deletions(-)

diff --git a/src/keval.h b/src/keval.h @@ -12,5 +12,7 @@ #include "kobject.h" void keval_ofn(klisp_State *K, TValue *xparams, TValue obj, TValue env); +void eval_ls_cfn(klisp_State *K, TValue *xparams, TValue obj); +void combine_cfn(klisp_State *K, TValue *xparams, TValue obj); #endif diff --git a/src/kgcombiners.h b/src/kgcombiners.h @@ -77,4 +77,11 @@ void map(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* Helper for combiner? */ bool kcombinerp(TValue obj); + +void do_vau(klisp_State *K, TValue *xparams, TValue obj, TValue denv); +void do_map_ret(klisp_State *K, TValue *xparams, TValue obj); +void do_map_encycle(klisp_State *K, TValue *xparams, TValue obj); +void do_map(klisp_State *K, TValue *xparams, TValue obj); +void do_map_cycle(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgcontinuations.h b/src/kgcontinuations.h @@ -61,4 +61,7 @@ void guard_dynamic_extent(klisp_State *K, TValue *xparams, TValue ptree, void kgexit(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +void do_extended_cont(klisp_State *K, TValue *xparams, TValue obj); +void do_pass_value(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgcontrol.c b/src/kgcontrol.c @@ -26,7 +26,7 @@ /* 4.5.2 $if */ /* helpers */ -void select_clause(klisp_State *K, TValue *xparams, TValue obj); +void do_select_clause(klisp_State *K, TValue *xparams, TValue obj); /* ASK JOHN: both clauses should probably be copied (copy-es-immutable) */ void Sif(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) @@ -37,7 +37,7 @@ void Sif(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) bind_3p(K, ptree, test, cons_c, alt_c); TValue new_cont = - kmake_continuation(K, kget_cc(K), select_clause, + kmake_continuation(K, kget_cc(K), do_select_clause, 3, denv, cons_c, alt_c); /* ** Mark as a bool checking cont, not necessary but avoids a continuation @@ -48,7 +48,7 @@ void Sif(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) ktail_eval(K, test, denv); } -void select_clause(klisp_State *K, TValue *xparams, TValue obj) +void do_select_clause(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: dynamic env diff --git a/src/kgcontrol.h b/src/kgcontrol.h @@ -18,9 +18,6 @@ #include "kstate.h" #include "kghelpers.h" -/* Helper (also used by $vau and $lambda) */ -void do_seq(klisp_State *K, TValue *xparams, TValue obj); - /* 4.5.1 inert? */ /* uses typep */ @@ -35,7 +32,6 @@ void Ssequence(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); TValue split_check_cond_clauses(klisp_State *K, TValue clauses, TValue *bodies); -void do_cond(klisp_State *K, TValue *xparams, TValue obj); /* 5.6.1 $cond */ void Scond(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); @@ -43,4 +39,9 @@ void Scond(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* 6.9.1 for-each */ void for_each(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +void do_seq(klisp_State *K, TValue *xparams, TValue obj); +void do_cond(klisp_State *K, TValue *xparams, TValue obj); +void do_select_clause(klisp_State *K, TValue *xparams, TValue obj); +void do_for_each(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgenvironments.h b/src/kgenvironments.h @@ -83,4 +83,6 @@ void do_b_to_env(klisp_State *K, TValue *xparams, TValue obj); void Sbindings_to_environment(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +void do_let(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgkd_vars.h b/src/kgkd_vars.h @@ -28,4 +28,6 @@ void do_access(klisp_State *K, TValue *xparams, TValue ptree, void make_keyed_dynamic_variable(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +void do_unbind(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgpairs_lists.h b/src/kgpairs_lists.h @@ -86,4 +86,15 @@ void countable_listp(klisp_State *K, TValue *xparams, TValue ptree, /* 6.3.10 reduce */ void reduce(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); + +void do_ret_cdr(klisp_State *K, TValue *xparams, TValue obj); +void do_filter_encycle(klisp_State *K, TValue *xparams, TValue obj); +void do_filter_cycle(klisp_State *K, TValue *xparams, TValue obj); +void do_filter(klisp_State *K, TValue *xparams, TValue obj); +void do_reduce_prec(klisp_State *K, TValue *xparams, TValue obj); +void do_reduce_postc(klisp_State *K, TValue *xparams, TValue obj); +void do_reduce_combine(klisp_State *K, TValue *xparams, TValue obj); +void do_reduce_cycle(klisp_State *K, TValue *xparams, TValue obj); +void do_reduce(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgports.h b/src/kgports.h @@ -83,4 +83,6 @@ void get_module(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* 15.2.? display */ void display(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +void do_close_file_ret(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kgpromises.c b/src/kgpromises.c @@ -28,7 +28,7 @@ /* uses typep */ /* Helper for force */ -void handle_result(klisp_State *K, TValue *xparams, TValue obj) +void do_handle_result(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: promise @@ -51,7 +51,7 @@ void handle_result(klisp_State *K, TValue *xparams, TValue obj) kapply_cc(K, expr); } else { TValue new_cont = kmake_continuation(K, kget_cc(K), - handle_result, 1, prom); + do_handle_result, 1, prom); kset_cc(K, new_cont); ktail_eval(K, expr, maybe_env); } @@ -78,7 +78,8 @@ 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), handle_result, 1, obj); + TValue new_cont = kmake_continuation(K, kget_cc(K), do_handle_result, + 1, obj); kset_cc(K, new_cont); ktail_eval(K, expr, env); } diff --git a/src/kgpromises.h b/src/kgpromises.h @@ -30,4 +30,6 @@ void Slazy(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* 9.1.4 memoize */ void memoize(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); +void do_handle_result(klisp_State *K, TValue *xparams, TValue obj); + #endif diff --git a/src/kground.c b/src/kground.c @@ -113,6 +113,41 @@ void kinit_cont_names(klisp_State *K) add_cont_name(K, t, error_fn, "repl-report-error"); /* GROUND ENV */ + add_cont_name(K, t, eval_ls_cfn, "eval_ls_cfn"); + add_cont_name(K, t, combine_cfn, "combine_cfn"); + add_cont_name(K, t, do_Sandp_Sorp, "do_Sandp_Sorp"); + add_cont_name(K, t, do_seq, "do_seq"); + add_cont_name(K, t, do_map, "do_map"); + add_cont_name(K, t, do_map_encycle, "do_map_encycle"); + add_cont_name(K, t, do_map_ret, "do_map_ret"); + add_cont_name(K, t, do_map_cycle, "do_map_cycle"); + add_cont_name(K, t, do_extended_cont, "do_extended_cont"); + add_cont_name(K, t, do_pass_value, "do_pass_value"); + add_cont_name(K, t, do_select_clause, "select_clause"); + add_cont_name(K, t, do_cond, "do_cond"); + add_cont_name(K, t, do_for_each, "do_for_each"); + add_cont_name(K, t, do_let, "do_let"); + add_cont_name(K, t, do_bindsp, "do_bindsp"); + add_cont_name(K, t, do_let_redirect, "do_let_redirect"); + add_cont_name(K, t, do_remote_eval, "do_remote_eval"); + add_cont_name(K, t, do_b_to_env, "do_b_to_env"); + add_cont_name(K, t, do_match, "do_match"); + add_cont_name(K, t, do_set_eval_obj, "do_set_eval_obj"); + add_cont_name(K, t, do_import, "do_import"); + add_cont_name(K, t, do_return_value, "do_return_value"); + add_cont_name(K, t, do_unbind, "do_unbind"); + add_cont_name(K, t, do_filter, "do_filter"); + add_cont_name(K, t, do_filter_encycle, "do_filter_encycle"); + add_cont_name(K, t, do_ret_cdr, "do_ret_cdr"); + add_cont_name(K, t, do_filter_cycle, "do_filter_cycle"); + add_cont_name(K, t, do_reduce_prec, "do_reduce_prec"); + add_cont_name(K, t, do_reduce_combine, "do_reduce_combine"); + add_cont_name(K, t, do_reduce_postc, "do_reduce_postc"); + add_cont_name(K, t, do_reduce, "do_reduce"); + add_cont_name(K, t, do_reduce_cycle, "do_reduce_cycle"); + add_cont_name(K, t, do_close_file_ret, "do_close_file_ret"); + add_cont_name(K, t, do_handle_result, "handle_result"); + add_cont_name(K, t, do_interception, "do_interception"); } /* diff --git a/src/kstate.h b/src/kstate.h @@ -483,5 +483,7 @@ void klispS_init_repl(klisp_State *K); void klispS_run(klisp_State *K); void klisp_close (klisp_State *K); +void do_interception(klisp_State *K, TValue *xparams, TValue obj); + #endif