From f46114ca034cee7e5088cb5b36628d8f09878792 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 16 Jul 2014 10:08:58 +0900 Subject: [PATCH] [experimental] use attributes for cv implementation --- src/proc.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/proc.c b/src/proc.c index c96f0e62..d7f391b0 100644 --- a/src/proc.c +++ b/src/proc.c @@ -61,42 +61,24 @@ pic_proc_attr(pic_state *pic, struct pic_proc *proc) void pic_proc_cv_init(pic_state *pic, struct pic_proc *proc, size_t cv_size) { - struct pic_env *env; - - if (proc->env != NULL) { - pic_error(pic, "env slot already in use"); - } - env = (struct pic_env *)pic_obj_alloc(pic, sizeof(struct pic_env), PIC_TT_ENV); - env->regc = cv_size; - env->regs = (pic_value *)pic_calloc(pic, cv_size, sizeof(pic_value)); - env->up = NULL; - - proc->env = env; } int pic_proc_cv_size(pic_state *pic, struct pic_proc *proc) { - UNUSED(pic); - return proc->env ? proc->env->regc : 0; + return 0; } pic_value pic_proc_cv_ref(pic_state *pic, struct pic_proc *proc, size_t i) { - if (proc->env == NULL) { - pic_error(pic, "no closed env"); - } - return proc->env->regs[i]; + return pic_dict_ref(pic, pic_proc_attr(pic, proc), i); /* FIXME */ } void pic_proc_cv_set(pic_state *pic, struct pic_proc *proc, size_t i, pic_value v) { - if (proc->env == NULL) { - pic_error(pic, "no closed env"); - } - proc->env->regs[i] = v; + pic_dict_set(pic, pic_proc_attr(pic, proc), i, v); /* FIXME */ } static pic_value