don't use pic->rescue stack in with-exception-handler

This commit is contained in:
Yuichi Nishiwaki 2014-03-24 14:54:03 +09:00
parent f6f695fa56
commit 6448a36db5
1 changed files with 8 additions and 11 deletions

View File

@ -127,19 +127,16 @@ pic_error_with_exception_handler(pic_state *pic)
pic_get_args(pic, "ll", &handler, &thunk); pic_get_args(pic, "ll", &handler, &thunk);
if (pic->ridx >= pic->rlen) { pic_try {
v = pic_apply_argv(pic, thunk, 0);
#if DEBUG
puts("rescue realloced");
#endif
pic->rlen *= 2;
pic->rescue = (struct pic_proc **)pic_realloc(pic, pic->rescue, sizeof(struct pic_proc *) * pic->rlen);
} }
pic->rescue[pic->ridx++] = handler; pic_catch {
struct pic_error *e = pic->err;
v = pic_apply_argv(pic, thunk, 0); pic->err = NULL;
pic->ridx--; v = pic_apply_argv(pic, handler, 1, pic_obj_value(e));
pic_errorf(pic, "error handler returned ~s, by error ~s", v, pic_obj_value(e));
}
return v; return v;
} }