diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-04-06 13:32:17 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-04-06 13:32:17 -0700 |
commit | 61e6eee0f3af7e953fdb50b3d73e51eb32a38a1b (patch) | |
tree | 98e927f2b987060649c6d465770553daf3aa9a77 | |
parent | c5acd13409cca8f95b7a921efc12ad8833713ffe (diff) | |
download | txr-61e6eee0f3af7e953fdb50b3d73e51eb32a38a1b.tar.gz txr-61e6eee0f3af7e953fdb50b3d73e51eb32a38a1b.tar.bz2 txr-61e6eee0f3af7e953fdb50b3d73e51eb32a38a1b.zip |
unwind: rename env frames.
Unwind frames of type ENV exist for the sake of the pattern
language. Let's rename them accordingly.
* match.c (tleval, tleval_progn, h_fun, tx_subst_vars, v_bind,
v_output, v_filter, v_fun): Occurrences of the macros
uw_env_begin and uw_env_end are renamed.
* unwind.c (uw_env_stack): Renamed to uw_menv_stack.
(uw_unwind_to_exit_point, uw_abscond_to_exit_point,
uw_find_env, uw_pop_frame, revive_cont): Follow
rename of UW_ENV to UW_MENV and uw_env_stack to uw_menv_stack.
(uw_push_env): Renamed to uw_push_match_env, and updated to
follow renames.
* unwind.h (enum uw_frtype, uw_frtype_t): UW_ENV renamed
to UW_MENV.
(uw_push_env): Renamed to uw_push_match_env.
(uw_env_begin, uw_env_end): Renamed to uw_match_env_begin an
uw_match_env_end.
-rw-r--r-- | match.c | 32 | ||||
-rw-r--r-- | unwind.c | 30 | ||||
-rw-r--r-- | unwind.h | 10 |
3 files changed, 36 insertions, 36 deletions
@@ -283,7 +283,7 @@ static val tleval(val spec, val form, val bindings) { val ret; - uw_env_begin; + uw_match_env_begin; if (opt_compat && opt_compat <= 121) { uw_set_match_context(cons(spec, bindings)); @@ -297,7 +297,7 @@ static val tleval(val spec, val form, val bindings) set_dyn_env(saved_de); } - uw_env_end; + uw_match_env_end; return ret; } @@ -306,7 +306,7 @@ static val tleval_progn(val spec, val forms, val bindings) { val ret; - uw_env_begin; + uw_match_env_begin; if (opt_compat && opt_compat <= 121) { uw_set_match_context(cons(spec, bindings)); @@ -320,7 +320,7 @@ static val tleval_progn(val spec, val forms, val bindings) set_dyn_env(saved_de); } - uw_env_end; + uw_match_env_end; return ret; } @@ -1404,7 +1404,7 @@ static val h_fun(match_line_ctx *c) { args_decl_list(args, ARGS_MIN, bindings_cp); uw_block_begin(nil, result); - uw_env_begin; + uw_match_env_begin; debug_frame(sym, args, ub_p_a_pairs, c->bindings, c->dataline, c->data_lineno, c->pos); uw_simple_catch_begin; @@ -1418,7 +1418,7 @@ static val h_fun(match_line_ctx *c) uw_catch_end; debug_end; - uw_env_end; + uw_match_env_end; uw_block_end; if (!result) { @@ -1671,7 +1671,7 @@ static val tx_subst_vars(val spec, val bindings, val filter) { if (opt_compat && opt_compat <= 128) { list_collect_decl(out, iter); - uw_env_begin; + uw_match_env_begin; uw_set_match_context(cons(spec, bindings)); @@ -1737,7 +1737,7 @@ static val tx_subst_vars(val spec, val bindings, val filter) spec = cdr(spec); } - uw_env_end; + uw_match_env_end; return out; } else { val saved_de = set_dyn_env(make_env(bindings, nil, nil)); @@ -3644,12 +3644,12 @@ static val v_bind(match_files_ctx *c) testfun = curry_1234_34(func_n4(filter_equal), lfilt, rfilt); } - uw_env_begin; + uw_match_env_begin; uw_set_match_context(cons(c->spec, c->bindings)); c->bindings = dest_bind(specline, c->bindings, pattern, value, testfun); - uw_env_end; + uw_match_env_end; if (c->bindings == t) return nil; @@ -3736,7 +3736,7 @@ static val v_output(match_files_ctx *c) val stream = nil; val ret = next_spec_k; - uw_env_begin; + uw_match_env_begin; val saved_de = set_dyn_env(make_env(c->bindings, nil, nil)); @@ -3862,7 +3862,7 @@ static val v_output(match_files_ctx *c) out: set_dyn_env(saved_de); - uw_env_end; + uw_match_env_end; return ret; } @@ -4118,7 +4118,7 @@ static val v_filter(match_files_ctx *c) if (!filter) sem_error(specline, lit("~s specifies unknown filter"), filter_spec, nao); - uw_env_begin; + uw_match_env_begin; uw_set_match_context(cons(c->spec, c->bindings)); for (; vars; vars = cdr(vars)) { @@ -4127,7 +4127,7 @@ static val v_filter(match_files_ctx *c) rplacd(existing, filter_string_tree(filter, cdr(existing))); } - uw_env_end; + uw_match_env_end; return next_spec_k; } @@ -4181,7 +4181,7 @@ static val v_fun(match_files_ctx *c) { args_decl_list(args, ARGS_MIN, bindings_cp); uw_block_begin(nil, result); - uw_env_begin; + uw_match_env_begin; debug_frame(sym, args, ub_p_a_pairs, c->bindings, if2(consp(c->data), car(c->data)), c->data_lineno, nil); @@ -4196,7 +4196,7 @@ static val v_fun(match_files_ctx *c) uw_catch_end; debug_end; - uw_env_end; + uw_match_env_end; uw_block_end; if (!result) { @@ -52,7 +52,7 @@ #define UW_CONT_FRAME_AFTER (16 * sizeof (val)) static uw_frame_t *uw_stack; -static uw_frame_t *uw_env_stack; +static uw_frame_t *uw_menv_stack; static uw_frame_t *uw_exit_point; static uw_frame_t toplevel_env; static uw_frame_t unhandled_ex; @@ -99,9 +99,9 @@ static void uw_unwind_to_exit_point(void) /* 1 means unwind only. */ extended_longjmp(uw_stack->ca.jb, 1); abort(); - case UW_ENV: + case UW_MENV: /* Maintain consistency of unwind stack pointer */ - uw_env_stack = uw_env_stack->ev.up_env; + uw_menv_stack = uw_menv_stack->ev.up_env; break; case UW_GUARD: if (uw_stack->gu.uw_ok) @@ -145,7 +145,7 @@ static void uw_unwind_to_exit_point(void) case UW_BLOCK: extended_longjmp(uw_stack->bl.jb, 1); abort(); - case UW_ENV: /* env frame cannot be exit point */ + case UW_MENV: /* env frame cannot be exit point */ abort(); case UW_CATCH: /* 2 means actual catch, not just unwind */ @@ -161,8 +161,8 @@ static void uw_abscond_to_exit_point(void) for (; uw_stack && uw_stack != uw_exit_point; uw_stack = uw_stack->uw.up) { switch (uw_stack->uw.type) { - case UW_ENV: - uw_env_stack = uw_env_stack->ev.up_env; + case UW_MENV: + uw_menv_stack = uw_menv_stack->ev.up_env; break; default: break; @@ -196,20 +196,20 @@ void uw_push_block(uw_frame_t *fr, val tag) static uw_frame_t *uw_find_env(void) { - return uw_env_stack ? uw_env_stack : &toplevel_env; + return uw_menv_stack ? uw_menv_stack : &toplevel_env; } -void uw_push_env(uw_frame_t *fr) +void uw_push_match_env(uw_frame_t *fr) { uw_frame_t *prev_env = uw_find_env(); memset(fr, 0, sizeof *fr); - fr->ev.type = UW_ENV; + fr->ev.type = UW_MENV; fr->ev.up_env = prev_env; fr->ev.func_bindings = nil; fr->ev.match_context = nil; fr->ev.up = uw_stack; uw_stack = fr; - uw_env_stack = fr; + uw_menv_stack = fr; } val uw_get_func(val sym) @@ -277,9 +277,9 @@ void uw_pop_frame(uw_frame_t *fr) { assert (fr == uw_stack); uw_stack = fr->uw.up; - if (fr->uw.type == UW_ENV) { - assert (fr == uw_env_stack); - uw_env_stack = fr->ev.up_env; + if (fr->uw.type == UW_MENV) { + assert (fr == uw_menv_stack); + uw_menv_stack = fr->ev.up_env; } } @@ -926,8 +926,8 @@ static val revive_cont(val dc, val arg) uw_block_begin (cont->tag, result); for (fr = new_uw_stack; ; fr = fr->uw.up) { - if (!env_set && fr->uw.type == UW_ENV) { - uw_env_stack = fr; + if (!env_set && fr->uw.type == UW_MENV) { + uw_menv_stack = fr; env_set = 1; } if (fr->uw.up == 0) { @@ -27,7 +27,7 @@ typedef union uw_frame uw_frame_t; typedef enum uw_frtype { - UW_BLOCK, UW_CAPTURED_BLOCK, UW_ENV, UW_CATCH, UW_HANDLE, + UW_BLOCK, UW_CAPTURED_BLOCK, UW_MENV, UW_CATCH, UW_HANDLE, UW_CONT_COPY, UW_GUARD, UW_DBG } uw_frtype_t; @@ -117,7 +117,7 @@ union uw_frame { } UW_FRAME_ALIGN; void uw_push_block(uw_frame_t *, val tag); -void uw_push_env(uw_frame_t *); +void uw_push_match_env(uw_frame_t *); val uw_get_func(val sym); val uw_set_func(val sym, val value); val uw_get_match_context(void); @@ -193,12 +193,12 @@ noreturn val type_mismatch(val, ...); uw_pop_block(&uw_blk, uw_rslt); \ } while (0) -#define uw_env_begin \ +#define uw_match_env_begin \ do { \ uw_frame_t uw_env; \ - uw_push_env(&uw_env) + uw_push_match_env(&uw_env) -#define uw_env_end \ +#define uw_match_env_end \ uw_pop_frame(&uw_env); \ } while (0) |