rename procedure creation functions
This commit is contained in:
parent
e7f765d218
commit
e3e1ba4c11
|
@ -26,7 +26,7 @@ struct pic_proc {
|
||||||
|
|
||||||
#define pic_proc_cfunc_p(o) (pic_proc_ptr(o)->cfunc_p)
|
#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(pic_state *, pic_func_t);
|
||||||
struct pic_proc *pic_proc_new_cfunc(pic_state *, pic_func_t);
|
struct pic_proc *pic_proc_new_irep(pic_state *, struct pic_irep *, struct pic_env *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -913,7 +913,7 @@ pic_codegen(pic_state *pic, pic_value obj)
|
||||||
state->irep->cv_num = 0;
|
state->irep->cv_num = 0;
|
||||||
state->irep->cv_tbl = NULL;
|
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);
|
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;
|
struct pic_proc *proc;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
proc = pic_proc_new_cfunc(pic, cfunc);
|
proc = pic_proc_new(pic, cfunc);
|
||||||
idx = scope_global_define(pic, name);
|
idx = scope_global_define(pic, name);
|
||||||
pic->globals[idx] = pic_obj_value(proc);
|
pic->globals[idx] = pic_obj_value(proc);
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,8 @@ pic_cont_callcc(pic_state *pic)
|
||||||
else {
|
else {
|
||||||
struct pic_proc *c;
|
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 */
|
/* save the continuation object in proc */
|
||||||
c->env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV);
|
c->env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV);
|
||||||
c->env->up = NULL;
|
c->env->up = NULL;
|
||||||
|
|
26
src/proc.c
26
src/proc.c
|
@ -4,19 +4,7 @@
|
||||||
#include "picrin/irep.h"
|
#include "picrin/irep.h"
|
||||||
|
|
||||||
struct pic_proc *
|
struct pic_proc *
|
||||||
pic_proc_new(pic_state *pic, struct pic_irep *irep, struct pic_env *env)
|
pic_proc_new(pic_state *pic, pic_func_t cfunc)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
struct pic_proc *proc;
|
struct pic_proc *proc;
|
||||||
|
|
||||||
|
@ -27,6 +15,18 @@ pic_proc_new_cfunc(pic_state *pic, pic_func_t cfunc)
|
||||||
return proc;
|
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
|
static pic_value
|
||||||
pic_proc_proc_p(pic_state *pic)
|
pic_proc_proc_p(pic_state *pic)
|
||||||
{
|
{
|
||||||
|
|
2
src/vm.c
2
src/vm.c
|
@ -613,7 +613,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
||||||
CASE(OP_LAMBDA) {
|
CASE(OP_LAMBDA) {
|
||||||
struct pic_proc *proc;
|
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));
|
PUSH(pic_obj_value(proc));
|
||||||
pic_gc_arena_restore(pic, ai);
|
pic_gc_arena_restore(pic, ai);
|
||||||
NEXT;
|
NEXT;
|
||||||
|
|
Loading…
Reference in New Issue