summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-11-10 15:54:11 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-11-10 15:54:11 -0800
commitb41bdc04f6ce6a595fb17e6de39c82770384cb55 (patch)
tree22e4d59eaaf4a88e72924af30adeb2310c9d2f6f
parentf9d713f3fc2fbd1c3ead07121b3bc39f5088a7d7 (diff)
downloadtxr-b41bdc04f6ce6a595fb17e6de39c82770384cb55.tar.gz
txr-b41bdc04f6ce6a595fb17e6de39c82770384cb55.tar.bz2
txr-b41bdc04f6ce6a595fb17e6de39c82770384cb55.zip
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.
-rw-r--r--ChangeLog11
-rw-r--r--match.c23
2 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ac7464d7..2ed62e33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-11-10 Kaz Kylheku <kaz@kylheku.com>
+ 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.
+
+2011-11-10 Kaz Kylheku <kaz@kylheku.com>
+
* parser.l: Fixed wrong error message.
2011-11-10 Kaz Kylheku <kaz@kylheku.com>
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));