[experimental] use attributes for cv implementation

This commit is contained in:
Yuichi Nishiwaki 2014-07-16 10:08:58 +09:00
parent 98bb47dfb6
commit f46114ca03
1 changed files with 3 additions and 21 deletions

View File

@ -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