From e3e1ba4c11397117cdf6f7468cd342e6e34053e6 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 8 Jan 2014 22:44:53 +0900 Subject: [PATCH] rename procedure creation functions --- include/picrin/proc.h | 4 ++-- src/codegen.c | 4 ++-- src/cont.c | 3 ++- src/proc.c | 26 +++++++++++++------------- src/vm.c | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/picrin/proc.h b/include/picrin/proc.h index 03046abb..21a24b21 100644 --- a/include/picrin/proc.h +++ b/include/picrin/proc.h @@ -26,7 +26,7 @@ struct pic_proc { #define pic_proc_cfunc_p(o) (pic_proc_ptr(o)->cfunc_p) -struct pic_proc *pic_proc_new(pic_state *, struct pic_irep *, struct pic_env *); -struct pic_proc *pic_proc_new_cfunc(pic_state *, pic_func_t); +struct pic_proc *pic_proc_new(pic_state *, pic_func_t); +struct pic_proc *pic_proc_new_irep(pic_state *, struct pic_irep *, struct pic_env *); #endif diff --git a/src/codegen.c b/src/codegen.c index 2f7ac1f3..05ab6246 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -913,7 +913,7 @@ pic_codegen(pic_state *pic, pic_value obj) state->irep->cv_num = 0; state->irep->cv_tbl = NULL; - proc = pic_proc_new(pic, state->irep, NULL); + proc = pic_proc_new_irep(pic, state->irep, NULL); destroy_codegen_state(pic, state); @@ -936,7 +936,7 @@ pic_defun(pic_state *pic, const char *name, pic_func_t cfunc) struct pic_proc *proc; int idx; - proc = pic_proc_new_cfunc(pic, cfunc); + proc = pic_proc_new(pic, cfunc); idx = scope_global_define(pic, name); pic->globals[idx] = pic_obj_value(proc); diff --git a/src/cont.c b/src/cont.c index 44e0af26..63e856ff 100644 --- a/src/cont.c +++ b/src/cont.c @@ -161,7 +161,8 @@ pic_cont_callcc(pic_state *pic) else { struct pic_proc *c; - c = pic_proc_new_cfunc(pic, cont_call); + c = pic_proc_new(pic, cont_call); + /* save the continuation object in proc */ c->env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV); c->env->up = NULL; diff --git a/src/proc.c b/src/proc.c index c66ef8d6..759b0446 100644 --- a/src/proc.c +++ b/src/proc.c @@ -4,19 +4,7 @@ #include "picrin/irep.h" struct pic_proc * -pic_proc_new(pic_state *pic, struct pic_irep *irep, struct pic_env *env) -{ - struct pic_proc *proc; - - proc = (struct pic_proc *)pic_obj_alloc(pic, sizeof(struct pic_proc), PIC_TT_PROC); - proc->cfunc_p = false; - proc->u.irep = irep; - proc->env = env; - return proc; -} - -struct pic_proc * -pic_proc_new_cfunc(pic_state *pic, pic_func_t cfunc) +pic_proc_new(pic_state *pic, pic_func_t cfunc) { struct pic_proc *proc; @@ -27,6 +15,18 @@ pic_proc_new_cfunc(pic_state *pic, pic_func_t cfunc) return proc; } +struct pic_proc * +pic_proc_new_irep(pic_state *pic, struct pic_irep *irep, struct pic_env *env) +{ + struct pic_proc *proc; + + proc = (struct pic_proc *)pic_obj_alloc(pic, sizeof(struct pic_proc), PIC_TT_PROC); + proc->cfunc_p = false; + proc->u.irep = irep; + proc->env = env; + return proc; +} + static pic_value pic_proc_proc_p(pic_state *pic) { diff --git a/src/vm.c b/src/vm.c index d2953dfb..5323c674 100644 --- a/src/vm.c +++ b/src/vm.c @@ -613,7 +613,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) CASE(OP_LAMBDA) { struct pic_proc *proc; - proc = pic_proc_new(pic, pic->irep[c.u.i], pic->ci->env); + proc = pic_proc_new_irep(pic, pic->irep[c.u.i], pic->ci->env); PUSH(pic_obj_value(proc)); pic_gc_arena_restore(pic, ai); NEXT;