diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-06-26 09:35:50 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-06-26 09:35:50 +0000 |
| commit | d1410aba223edf235b83a70be0890b48fd07e585 (patch) | |
| tree | e9b18e29bab7b84b1ec95c08e05e4e428327e4c7 /src/runtime/c/pgf/pgf.c | |
| parent | fcd2a2b12a00bb5e3427162e3f6c07b4b58a2d3d (diff) | |
we no longer maintain an explicit list of functions per category since now it is implicitly kept in the JIT compiled code
Diffstat (limited to 'src/runtime/c/pgf/pgf.c')
| -rw-r--r-- | src/runtime/c/pgf/pgf.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c index 95b2132f5..13066927c 100644 --- a/src/runtime/c/pgf/pgf.c +++ b/src/runtime/c/pgf/pgf.c @@ -151,35 +151,31 @@ pgf_iter_functions(PgfPGF* pgf, GuMapItor* fn, GuExn* err) gu_map_iter(pgf->abstract.funs, fn, err); } +typedef struct { + GuMapItor fn; + PgfCId catname; + GuMapItor* client_fn; +} PgfFunByCatIter; + +static void +pgf_filter_by_cat(GuMapItor* fn, const void* key, void* value, GuExn* err) +{ + (void) (key && err); + + PgfFunByCatIter* clo = (PgfFunByCatIter*) fn; + PgfAbsFun* absfun = *((PgfAbsFun**) value); + + if (gu_string_eq(absfun->type->cid, clo->catname)) { + clo->client_fn->fn(clo->client_fn, &absfun->name, NULL, err); + } +} + void pgf_iter_functions_by_cat(PgfPGF* pgf, PgfCId catname, GuMapItor* fn, GuExn* err) { - PgfAbsCat* abscat = - gu_map_get(pgf->abstract.cats, &catname, PgfAbsCat*); - if (abscat == NULL) { - gu_raise(err, PgfExn); - return; - } - - size_t n_functions = gu_buf_length(abscat->functions); - for (size_t i = 0; i < n_functions; i++) { - PgfAbsFun* fun = - gu_buf_get(abscat->functions, PgfAbsFun*, i); - - GuVariantInfo i = gu_variant_open(fun->ep.expr); - switch (i.tag) { - case PGF_EXPR_FUN: { - PgfExprFun* efun = i.data; - fn->fn(fn, &efun->fun, NULL, err); - if (!gu_ok(err)) - return; - break; - } - default: - gu_impossible(); - } - } + PgfFunByCatIter clo = { { pgf_filter_by_cat }, catname, fn }; + gu_map_iter(pgf->abstract.funs, &clo.fn, err); } GuString |
