add pic_receive

This commit is contained in:
Yuichi Nishiwaki 2014-02-02 12:38:46 +09:00
parent 19db4bb6b2
commit 116a65cdee
2 changed files with 16 additions and 0 deletions

View File

@ -54,6 +54,7 @@ pic_value pic_callcc(pic_state *, struct pic_proc *);
pic_value pic_values(pic_state *, size_t, ...); pic_value pic_values(pic_state *, size_t, ...);
pic_value pic_values_by_array(pic_state *, size_t, pic_value *); pic_value pic_values_by_array(pic_state *, size_t, pic_value *);
pic_value pic_values_by_list(pic_state *, pic_value); pic_value pic_values_by_list(pic_state *, pic_value);
size_t pic_receive(pic_state *, size_t, pic_value *);
#if defined(__cplusplus) #if defined(__cplusplus)
} }

View File

@ -218,6 +218,21 @@ pic_values_by_list(pic_state *pic, pic_value list)
return pic_nil_p(list) ? pic_none_value() : pic->ci->fp[0]; return pic_nil_p(list) ? pic_none_value() : pic->ci->fp[0];
} }
size_t
pic_receive(pic_state *pic, size_t n, pic_value *argv)
{
size_t i;
for (i = 0; ; ++i) {
if (pic_undef_p(pic->ci->fp[i]))
break;
if (i < n) {
argv[i] = pic->ci->fp[i];
}
}
return i;
}
static pic_value static pic_value
pic_cont_callcc(pic_state *pic) pic_cont_callcc(pic_state *pic)
{ {