publish pic_callcc

This commit is contained in:
Yuichi Nishiwaki 2014-01-18 16:08:07 +09:00
parent 3ff7d5b208
commit acb513aa16
2 changed files with 15 additions and 6 deletions

View File

@ -50,6 +50,8 @@ struct pic_cont {
} \
} while (0)
pic_value pic_callcc(pic_state *, struct pic_proc *);
#if defined(__cplusplus)
}
#endif

View File

@ -150,13 +150,10 @@ cont_call(pic_state *pic)
return pic_undef_value();
}
static pic_value
pic_cont_callcc(pic_state *pic)
pic_value
pic_callcc(pic_state *pic, struct pic_proc *proc)
{
struct pic_cont *cont;
struct pic_proc *cb;
pic_get_args(pic, "l", &cb);
save_cont(pic, &cont);
if (setjmp(cont->jmp)) {
@ -171,10 +168,20 @@ pic_cont_callcc(pic_state *pic)
pic_proc_cv_init(pic, c, 1);
pic_proc_cv_set(pic, c, 0, pic_obj_value(cont));
return pic_apply_argv(pic, cb, 1, pic_obj_value(c));
return pic_apply_argv(pic, proc, 1, pic_obj_value(c));
}
}
static pic_value
pic_cont_callcc(pic_state *pic)
{
struct pic_proc *cb;
pic_get_args(pic, "l", &cb);
return pic_callcc(pic, cb);
}
static pic_value
pic_cont_dynamic_wind(pic_state *pic)
{