From 13a861377a55a77d2ad2072fd700b720aa71d4d0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 31 Mar 2012 16:00:52 -0700 Subject: If one of the blocks which are subordinate to a @(trailer) happen to request a successful termination by invoking @(accept) the position must not advance into the trailer material. * match.c (v_trailer): Added an unwind protect which detects that an accept is taking place and adjusts the return value to restrict the input position at the point given to trailer. (accept_fail): Use uw_block_return_proto instead of uw_block_return and pass the symbol as the protocol identifier. * unwind.c (uw_current_exit_point): New function. (uw_block_return): Function renamed to uw_block_return_proto; takes new parameter which is stored in the block structure. * unwind.h (struct uw_block): New member, protocol. (uw_block_return): Becomes an inline wrapper for uw_block_return_proto. (uw_block_return_proto, uw_current_exit_point): Declared. * txr.1: Interaction between @(trailer) and @(accept) documented. --- unwind.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'unwind.h') diff --git a/unwind.h b/unwind.h index c963b1ff..db8a53fa 100644 --- a/unwind.h +++ b/unwind.h @@ -43,6 +43,7 @@ struct uw_block { uw_frtype_t type; val tag; val result; + val protocol; jmp_buf jb; }; @@ -91,7 +92,11 @@ val uw_get_func(val sym); val uw_set_func(val sym, val value); val uw_get_match_context(void); val uw_set_match_context(val context); -val uw_block_return(val tag, val result); +val uw_block_return_proto(val tag, val result, val protocol); +INLINE val uw_block_return(val tag, val result) +{ + return uw_block_return_proto(tag, result, nil); +} void uw_push_catch(uw_frame_t *, val matches); noreturn val uw_throw(val sym, val exception); noreturn val uw_throwf(val sym, val fmt, ...); @@ -106,6 +111,7 @@ void uw_push_debug(uw_frame_t *, val func, val args, val line, val chr); void uw_pop_frame(uw_frame_t *); uw_frame_t *uw_current_frame(void); +uw_frame_t *uw_current_exit_point(void); void uw_init(void); noreturn val type_mismatch(val, ...); -- cgit v1.2.3