refactor pic_push_try. use raw continuation API

This commit is contained in:
Yuichi Nishiwaki 2014-09-24 15:35:00 +09:00
parent e38732995e
commit c7c771c861
1 changed files with 26 additions and 28 deletions

26
error.c
View File

@ -85,13 +85,20 @@ native_exception_handler(pic_state *pic)
UNREACHABLE();
}
static pic_value
native_push_try(pic_state *pic)
bool
pic_push_try(pic_state *pic)
{
struct pic_escape *escape;
escape = pic_alloc(pic, sizeof(struct pic_escape));
if (pic_save_point(pic, escape)) {
return false;
} else {
struct pic_proc *cont, *handler;
size_t xp_len, xp_offset;
pic_get_args(pic, "l", &cont);
cont = pic_make_cont(pic, escape);
handler = pic_make_proc(pic, native_exception_handler, "(native-exception-handler)");
@ -107,17 +114,8 @@ native_push_try(pic_state *pic)
*pic->xp++ = handler;
return pic_true_value();
}
bool
pic_push_try(pic_state *pic)
{
pic_value val;
val = pic_escape(pic, pic_make_proc(pic, native_push_try, "(native-push-try)"));
return pic_test(val);
return true;
}
}
void