don't setjmp in pic_save_point

This commit is contained in:
Yuichi Nishiwaki 2014-09-24 20:06:14 +09:00
parent d6104b8b25
commit eb1e01d000
3 changed files with 10 additions and 10 deletions

10
cont.c
View File

@ -57,7 +57,7 @@ pic_dynamic_wind(pic_state *pic, struct pic_proc *in, struct pic_proc *thunk, st
return val;
}
int
void
pic_save_point(pic_state *pic, struct pic_escape *escape)
{
escape->valid = true;
@ -71,8 +71,6 @@ pic_save_point(pic_state *pic, struct pic_escape *escape)
escape->ip = pic->ip;
escape->results = pic_undef_value();
return setjmp(escape->jmp);
}
noreturn void
@ -131,11 +129,11 @@ pic_make_econt(pic_state *pic, struct pic_escape *escape)
pic_value
pic_escape(pic_state *pic, struct pic_proc *proc)
{
struct pic_escape *escape;
struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape));
escape = pic_alloc(pic, sizeof(struct pic_escape));
pic_save_point(pic, escape);
if (pic_save_point(pic, escape)) {
if (setjmp(escape->jmp)) {
return pic_values_by_list(pic, escape->results);
}
else {

View File

@ -89,11 +89,13 @@ native_exception_handler(pic_state *pic)
bool
pic_push_try(pic_state *pic)
{
struct pic_escape *escape;
struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape));
escape = pic_alloc(pic, sizeof(struct pic_escape));
pic_save_point(pic, escape);
if (setjmp(escape->jmp)) {
puts("escaping");
if (pic_save_point(pic, escape)) {
return false;
} else {
struct pic_proc *cont, *handler;

View File

@ -26,7 +26,7 @@ struct pic_escape {
pic_value results;
};
int pic_save_point(pic_state *, struct pic_escape *);
void pic_save_point(pic_state *, struct pic_escape *);
noreturn void pic_load_point(pic_state *, struct pic_escape *);
struct pic_proc *pic_make_econt(pic_state *, struct pic_escape *);