klisp

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

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

Changed some names for continuation functions (now they all start with do_, should probably be something with k...) and types names for all continuations.

Diffstat:
Msrc/keval.c | 12++++++------
Msrc/keval.h | 4++--
Msrc/kground.c | 80++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/krepl.c | 25+++++++++++++------------
Msrc/krepl.h | 10+++++-----
5 files changed, 66 insertions(+), 65 deletions(-)

diff --git a/src/keval.c b/src/keval.c @@ -15,7 +15,7 @@ /* ** Eval helpers */ -void eval_ls_cfn(klisp_State *K, TValue *xparams, TValue obj) +void do_eval_ls(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: this argument list pair @@ -39,7 +39,7 @@ 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), eval_ls_cfn, 4, + TValue new_cont = kmake_continuation(K, kget_cc(K), do_eval_ls, 4, rest, env, tail, combiner); kset_cc(K, new_cont); ktail_eval(K, kcar(rest), env); @@ -89,7 +89,7 @@ inline TValue make_arg_ls(klisp_State *K, TValue operands, TValue *tail) return arg_ls; } -void combine_cfn(klisp_State *K, TValue *xparams, TValue obj) +void do_combine(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: operand list @@ -113,13 +113,13 @@ void combine_cfn(klisp_State *K, TValue *xparams, TValue obj) TValue tail; TValue arg_ls = make_arg_ls(K, operands, &tail); krooted_tvs_push(K, arg_ls); - TValue comb_cont = kmake_continuation(K, kget_cc(K), combine_cfn, + TValue comb_cont = kmake_continuation(K, kget_cc(K), do_combine, 3, arg_ls, env, si); krooted_tvs_pop(K); /* already in cont */ krooted_tvs_push(K, comb_cont); TValue els_cont = - kmake_continuation(K, comb_cont, eval_ls_cfn, 4, arg_ls, env, + kmake_continuation(K, comb_cont, do_eval_ls, 4, arg_ls, env, tail, tv2app(obj)->underlying); kset_cc(K, els_cont); krooted_tvs_pop(K); @@ -145,7 +145,7 @@ 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), combine_cfn, 3, kcdr(obj), + kmake_continuation(K, kget_cc(K), do_combine, 3, kcdr(obj), env, ktry_get_si(K, obj)); kset_cc(K, new_cont); ktail_eval(K, kcar(obj), env); diff --git a/src/keval.h b/src/keval.h @@ -12,7 +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); +void do_eval_ls(klisp_State *K, TValue *xparams, TValue obj); +void do_combine(klisp_State *K, TValue *xparams, TValue obj); #endif diff --git a/src/kground.c b/src/kground.c @@ -106,48 +106,48 @@ void kinit_cont_names(klisp_State *K) Table *t = tv2table(K->cont_name_table); /* REPL, root-continuation & error-continuation */ - add_cont_name(K, t, exit_fn, "exit"); - add_cont_name(K, t, read_fn, "repl-read"); - add_cont_name(K, t, eval_cfn, "repl-eval"); - add_cont_name(K, t, loop_fn, "repl-loop"); - add_cont_name(K, t, error_fn, "repl-report-error"); + add_cont_name(K, t, do_repl_exit, "exit"); + add_cont_name(K, t, do_repl_read, "repl-read"); + add_cont_name(K, t, do_repl_eval, "repl-eval"); + add_cont_name(K, t, do_repl_loop, "repl-loop"); + add_cont_name(K, t, do_repl_error, "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"); + add_cont_name(K, t, do_eval_ls, "eval-list"); + add_cont_name(K, t, do_combine, "eval-combine"); + add_cont_name(K, t, do_Sandp_Sorp, "eval-booleans"); + add_cont_name(K, t, do_seq, "eval-sequence"); + add_cont_name(K, t, do_map, "map-acyclic-part"); + add_cont_name(K, t, do_map_encycle, "map-encycle!"); + add_cont_name(K, t, do_map_ret, "map-ret"); + add_cont_name(K, t, do_map_cycle, "map-cyclic-part"); + add_cont_name(K, t, do_extended_cont, "extended-cont"); + add_cont_name(K, t, do_pass_value, "pass-value"); + add_cont_name(K, t, do_select_clause, "select-clause"); + add_cont_name(K, t, do_cond, "eval-cond-list"); + add_cont_name(K, t, do_for_each, "for-each"); + add_cont_name(K, t, do_let, "eval-let"); + add_cont_name(K, t, do_bindsp, "eval-$binds?-env"); + add_cont_name(K, t, do_let_redirect, "eval-let-redirect"); + add_cont_name(K, t, do_remote_eval, "eval-remote-eval-env"); + add_cont_name(K, t, do_b_to_env, "bindings-to-env"); + add_cont_name(K, t, do_match, "match-ptree"); + add_cont_name(K, t, do_set_eval_obj, "set-eval-obj"); + add_cont_name(K, t, do_import, "import"); + add_cont_name(K, t, do_return_value, "return-value"); + add_cont_name(K, t, do_unbind, "unbind-dynamic-var"); + add_cont_name(K, t, do_filter, "filter-acyclic-part"); + add_cont_name(K, t, do_filter_encycle, "filter-encycle!"); + add_cont_name(K, t, do_ret_cdr, "return-cdr"); + add_cont_name(K, t, do_filter_cycle, "filter-cyclic-part"); + add_cont_name(K, t, do_reduce_prec, "reduce-precycle"); + add_cont_name(K, t, do_reduce_combine, "reduce-combine"); + add_cont_name(K, t, do_reduce_postc, "reduce-postcycle"); + add_cont_name(K, t, do_reduce, "reduce-acyclic-part"); + add_cont_name(K, t, do_reduce_cycle, "reduce-cyclic-part"); + add_cont_name(K, t, do_close_file_ret, "close-file-and-ret"); + add_cont_name(K, t, do_handle_result, "handle-result"); + add_cont_name(K, t, do_interception, "do-interception"); } /* diff --git a/src/krepl.c b/src/krepl.c @@ -25,7 +25,7 @@ /* TODO add names & source info to the repl continuations */ /* the exit continuation, it exits the loop */ -void exit_fn(klisp_State *K, TValue *xparams, TValue obj) +void do_repl_exit(klisp_State *K, TValue *xparams, TValue obj) { UNUSED(xparams); UNUSED(obj); @@ -36,7 +36,7 @@ void exit_fn(klisp_State *K, TValue *xparams, TValue obj) } /* the underlying function of the read cont */ -void read_fn(klisp_State *K, TValue *xparams, TValue obj) +void do_repl_read(klisp_State *K, TValue *xparams, TValue obj) { UNUSED(xparams); UNUSED(obj); @@ -58,7 +58,7 @@ void read_fn(klisp_State *K, TValue *xparams, TValue obj) } /* the underlying function of the eval cont */ -void eval_cfn(klisp_State *K, TValue *xparams, TValue obj) +void do_repl_eval(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: dynamic environment @@ -75,20 +75,20 @@ void eval_cfn(klisp_State *K, TValue *xparams, TValue obj) } } -void loop_fn(klisp_State *K, TValue *xparams, TValue obj); +void do_repl_loop(klisp_State *K, TValue *xparams, TValue obj); -/* this is called from both loop_fn and error_fn */ +/* this is called from both do_repl_loop and do_repl_error */ /* GC: assumes denv is NOT rooted */ inline void create_loop(klisp_State *K, TValue denv) { krooted_tvs_push(K, denv); TValue loop_cont = - kmake_continuation(K, K->root_cont, loop_fn, 1, denv); + kmake_continuation(K, K->root_cont, do_repl_loop, 1, denv); krooted_tvs_push(K, loop_cont); - TValue eval_cont = kmake_continuation(K, loop_cont, eval_cfn, 1, denv); + TValue eval_cont = kmake_continuation(K, loop_cont, do_repl_eval, 1, denv); krooted_tvs_pop(K); /* in eval cont */ krooted_tvs_push(K, eval_cont); - TValue read_cont = kmake_continuation(K, eval_cont, read_fn, 0); + TValue read_cont = kmake_continuation(K, eval_cont, do_repl_read, 0); kset_cc(K, read_cont); krooted_tvs_pop(K); krooted_tvs_pop(K); @@ -96,7 +96,7 @@ inline void create_loop(klisp_State *K, TValue denv) } /* the underlying function of the write & loop cont */ -void loop_fn(klisp_State *K, TValue *xparams, TValue obj) +void do_repl_loop(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: dynamic environment @@ -114,7 +114,7 @@ void loop_fn(klisp_State *K, TValue *xparams, TValue obj) } /* the underlying function of the error cont */ -void error_fn(klisp_State *K, TValue *xparams, TValue obj) +void do_repl_error(klisp_State *K, TValue *xparams, TValue obj) { /* ** xparams[0]: dynamic environment @@ -201,10 +201,11 @@ void kinit_repl(klisp_State *K) krooted_tvs_push(K, std_env); /* set up the continuations */ - TValue root_cont = kmake_continuation(K, KNIL, exit_fn, 0); + TValue root_cont = kmake_continuation(K, KNIL, do_repl_exit, 0); krooted_tvs_push(K, root_cont); - TValue error_cont = kmake_continuation(K, root_cont, error_fn, 1, std_env); + TValue error_cont = kmake_continuation(K, root_cont, do_repl_error, + 1, std_env); krooted_tvs_push(K, error_cont); /* update the ground environment with these two conts */ diff --git a/src/krepl.h b/src/krepl.h @@ -14,10 +14,10 @@ void kinit_repl(klisp_State *K); /* continuation functions */ -void exit_fn(klisp_State *K, TValue *xparams, TValue obj); -void read_fn(klisp_State *K, TValue *xparams, TValue obj); -void eval_cfn(klisp_State *K, TValue *xparams, TValue obj); -void loop_fn(klisp_State *K, TValue *xparams, TValue obj); -void error_fn(klisp_State *K, TValue *xparams, TValue obj); +void do_repl_exit(klisp_State *K, TValue *xparams, TValue obj); +void do_repl_read(klisp_State *K, TValue *xparams, TValue obj); +void do_repl_eval(klisp_State *K, TValue *xparams, TValue obj); +void do_repl_loop(klisp_State *K, TValue *xparams, TValue obj); +void do_repl_error(klisp_State *K, TValue *xparams, TValue obj); #endif