wrapper/unwrapper for var-proc conversion

This commit is contained in:
Yuichi Nishiwaki 2014-01-12 16:08:27 +09:00
parent fadcad2d7f
commit 11ead27614
2 changed files with 16 additions and 7 deletions

View File

@ -15,6 +15,9 @@ struct pic_var {
struct pic_var *pic_var_new(pic_state *, pic_value, struct pic_proc *);
struct pic_proc *pic_wrap_var(pic_state *, struct pic_var *);
struct pic_var *pic_unwrap_var(pic_state *, struct pic_proc *);
pic_value pic_var_ref(pic_state *, struct pic_var *);
void pic_var_set(pic_state *, struct pic_var *, pic_value);
void pic_var_set_force(pic_state *, struct pic_var *, pic_value);

View File

@ -66,22 +66,28 @@ var_call(pic_state *pic)
UNREACHABLE;
}
struct pic_proc *
pic_wrap_var(pic_state *pic, struct pic_var *var)
{
struct pic_proc *proc;
proc = pic_proc_new(pic, var_call);
pic_proc_cv_init(pic, proc, 1);
pic_proc_cv_set(pic, proc, 0, pic_obj_value(var));
return proc;
}
static pic_value
pic_var_make_parameter(pic_state *pic)
{
struct pic_proc *proc, *conv = NULL;
struct pic_proc *conv = NULL;
struct pic_var *var;
pic_value init;
pic_get_args(pic, "o|l", &init, &conv);
var = pic_var_new(pic, init, conv);
proc = pic_proc_new(pic, var_call);
pic_proc_cv_init(pic, proc, 1);
pic_proc_cv_set(pic, proc, 0, pic_obj_value(var));
return pic_obj_value(proc);
return pic_obj_value(pic_wrap_var(pic, var));
}
static struct pic_var *