refactor values functions

This commit is contained in:
Yuichi Nishiwaki 2014-02-02 12:27:24 +09:00
parent f2507b5cbf
commit cb3128d241
1 changed files with 2 additions and 10 deletions

View File

@ -179,38 +179,30 @@ pic_values(pic_state *pic, size_t c, ...)
{ {
va_list ap; va_list ap;
size_t i; size_t i;
pic_value head = pic_none_value();
va_start(ap, c); va_start(ap, c);
for (i = 0; i < c; ++i) { for (i = 0; i < c; ++i) {
pic->ci->fp[i] = va_arg(ap, pic_value); pic->ci->fp[i] = va_arg(ap, pic_value);
if (i == 0) {
head = pic->ci->fp[0];
}
} }
pic->ci->fp[i] = pic_undef_value(); pic->ci->fp[i] = pic_undef_value();
va_end(ap); va_end(ap);
return head; return c == 0 ? pic_none_value() : pic->ci->fp[0];
} }
pic_value pic_value
pic_values_by_array(pic_state *pic, size_t argc, pic_value *argv) pic_values_by_array(pic_state *pic, size_t argc, pic_value *argv)
{ {
size_t i; size_t i;
pic_value head = pic_none_value();
for (i = 0; i < argc; ++i) { for (i = 0; i < argc; ++i) {
pic->ci->fp[i] = argv[i]; pic->ci->fp[i] = argv[i];
if (i == 0) {
head = pic->ci->fp[0];
}
} }
pic->ci->fp[i] = pic_undef_value(); pic->ci->fp[i] = pic_undef_value();
return head; return argc == 0 ? pic_none_value() : pic->ci->fp[0];
} }
static pic_value static pic_value