From 1e3bb6f1bbd233b848a22b96bf52fb5b4b45a946 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 2 Jun 2015 05:14:43 +0900 Subject: [PATCH] cleanup pic_push_try --- extlib/benz/error.c | 6 ++---- extlib/benz/include/picrin/error.h | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/extlib/benz/error.c b/extlib/benz/error.c index 81daee96..73370cd8 100644 --- a/extlib/benz/error.c +++ b/extlib/benz/error.c @@ -81,14 +81,12 @@ native_exception_handler(pic_state *pic) } void -pic_push_try(pic_state *pic, struct pic_escape *escape) +pic_push_try(pic_state *pic, struct pic_proc *cont) { - struct pic_proc *cont, *handler; + struct pic_proc *handler; size_t xp_len; ptrdiff_t xp_offset; - cont = pic_make_econt(pic, escape); - handler = pic_make_proc(pic, native_exception_handler, "(native-exception-handler)"); pic_attr_set(pic, pic_obj_value(handler), "@@escape", pic_obj_value(cont)); diff --git a/extlib/benz/include/picrin/error.h b/extlib/benz/include/picrin/error.h index ddf14e85..617f29f8 100644 --- a/extlib/benz/include/picrin/error.h +++ b/extlib/benz/include/picrin/error.h @@ -33,11 +33,11 @@ struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_list) struct pic_escape *escape = pic_malloc(pic, sizeof(struct pic_escape)); \ pic_save_point(pic, escape); \ if (PIC_SETJMP(pic, (void *)escape->jmp) == 0) { \ - pic_push_try(pic, escape); \ - do + do { \ + pic_push_try(pic, pic_make_econt(pic, escape)); #define pic_catch_(label) \ - while (0); \ - pic_pop_try(pic); \ + pic_pop_try(pic); \ + } while (0); \ } else { \ goto label; \ } \ @@ -45,7 +45,7 @@ struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_list) if (0) \ label: -void pic_push_try(pic_state *, struct pic_escape *); +void pic_push_try(pic_state *, struct pic_proc *); void pic_pop_try(pic_state *); pic_value pic_raise_continuable(pic_state *, pic_value);