From c601dbf27e50514a5ec51ef95e1cfb3781e08575 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 17 Jul 2014 16:31:26 +0900 Subject: [PATCH] rename pic_proc_cv_ref to pic_attr_ref --- include/picrin/proc.h | 6 ++---- src/cont.c | 6 +++--- src/proc.c | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/picrin/proc.h b/include/picrin/proc.h index 40dfc46c..b91960de 100644 --- a/include/picrin/proc.h +++ b/include/picrin/proc.h @@ -52,10 +52,8 @@ struct pic_proc *pic_proc_new_irep(pic_state *, struct pic_irep *, struct pic_en pic_sym pic_proc_name(struct pic_proc *); struct pic_dict *pic_attr(pic_state *, struct pic_proc *); - -/* closed variables accessor */ -pic_value pic_proc_cv_ref(pic_state *, struct pic_proc *, size_t); -void pic_proc_cv_set(pic_state *, struct pic_proc *, size_t, pic_value); +pic_value pic_attr_ref(pic_state *, struct pic_proc *, const char *); +void pic_attr_set(pic_state *, struct pic_proc *, const char *, pic_value); #if defined(__cplusplus) } diff --git a/src/cont.c b/src/cont.c index f76a6695..de076874 100644 --- a/src/cont.c +++ b/src/cont.c @@ -221,7 +221,7 @@ cont_call(pic_state *pic) proc = pic_get_proc(pic); pic_get_args(pic, "*", &argc, &argv); - cont = (struct pic_cont *)pic_ptr(pic_proc_cv_ref(pic, proc, 0)); + cont = (struct pic_cont *)pic_ptr(pic_attr_ref(pic, proc, "@@cont")); cont->results = pic_list_by_array(pic, argc, argv); /* execute guard handlers */ @@ -245,7 +245,7 @@ pic_callcc(pic_state *pic, struct pic_proc *proc) c = pic_proc_new(pic, cont_call, ""); /* save the continuation object in proc */ - pic_proc_cv_set(pic, c, 0, pic_obj_value(cont)); + pic_attr_set(pic, c, "@@cont", pic_obj_value(cont)); return pic_apply1(pic, proc, pic_obj_value(c)); } @@ -266,7 +266,7 @@ pic_callcc_trampoline(pic_state *pic, struct pic_proc *proc) c = pic_proc_new(pic, cont_call, ""); /* save the continuation object in proc */ - pic_proc_cv_set(pic, c, 0, pic_obj_value(cont)); + pic_attr_set(pic, c, "@@cont", pic_obj_value(cont)); return pic_apply_trampoline(pic, proc, pic_list1(pic, pic_obj_value(c))); } diff --git a/src/proc.c b/src/proc.c index e3694a25..84967224 100644 --- a/src/proc.c +++ b/src/proc.c @@ -59,15 +59,15 @@ pic_attr(pic_state *pic, struct pic_proc *proc) } pic_value -pic_proc_cv_ref(pic_state *pic, struct pic_proc *proc, size_t i) +pic_attr_ref(pic_state *pic, struct pic_proc *proc, const char *key) { - return pic_dict_ref(pic, pic_attr(pic, proc), i); /* FIXME */ + return pic_dict_ref(pic, pic_attr(pic, proc), pic_intern_cstr(pic, key)); } void -pic_proc_cv_set(pic_state *pic, struct pic_proc *proc, size_t i, pic_value v) +pic_attr_set(pic_state *pic, struct pic_proc *proc, const char *key, pic_value v) { - pic_dict_set(pic, pic_attr(pic, proc), i, v); /* FIXME */ + pic_dict_set(pic, pic_attr(pic, proc), pic_intern_cstr(pic, key), v); } static pic_value