From b41bdc04f6ce6a595fb17e6de39c82770384cb55 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 10 Nov 2011 15:54:11 -0800 Subject: Task #11583 More generic approach. * match.c (h_bind): Function removed. (hv_trampoline): New function. (dir_tables_init): hv_trampoline installed in h_directive_table instead of h_bind. --- match.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'match.c') diff --git a/match.c b/match.c index 0d9c16c5..6dd3eda0 100644 --- a/match.c +++ b/match.c @@ -2423,16 +2423,25 @@ static val v_bind(match_files_ctx *c) return next_spec_k; } -static val h_bind(match_line_ctx c, match_line_ctx *cout) +static val hv_trampoline(match_line_ctx c, match_line_ctx *cout) { val ret; match_files_ctx mf = mf_from_ml(c); - ret = v_bind(&mf); - if (ret == next_spec_k) { - c.bindings = mf.bindings; - *cout = c; + val sym = first(first(c.specline)); + val entry = gethash(v_directive_table, sym); + + if (!entry) + internal_error("hv_trampoline: missing dispatch table entry"); + + { + v_match_func vmf = (v_match_func) cptr_get(entry); + ret = vmf(&mf); + if (ret == next_spec_k) { + c.bindings = mf.bindings; + *cout = c; + } + return ret; } - return ret; } static val v_set(match_files_ctx *c) @@ -3163,7 +3172,7 @@ static void dir_tables_init(void) sethash(h_directive_table, var_s, cptr((mem_t *) h_var)); sethash(h_directive_table, skip_s, cptr((mem_t *) h_skip)); sethash(h_directive_table, coll_s, cptr((mem_t *) h_coll)); - sethash(h_directive_table, bind_s, cptr((mem_t *) h_bind)); + sethash(h_directive_table, bind_s, cptr((mem_t *) hv_trampoline)); sethash(h_directive_table, some_s, cptr((mem_t *) h_parallel)); sethash(h_directive_table, all_s, cptr((mem_t *) h_parallel)); sethash(h_directive_table, none_s, cptr((mem_t *) h_parallel)); -- cgit v1.2.3