wrapper/unwrapper for var-proc conversion
This commit is contained in:
parent
fadcad2d7f
commit
11ead27614
|
@ -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);
|
||||
|
|
20
src/var.c
20
src/var.c
|
@ -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 *
|
||||
|
|
Loading…
Reference in New Issue