diff options
author | Maria Matejka <mq@ucw.cz> | 2019-07-01 14:12:05 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-07-01 14:12:05 +0200 |
commit | 30667d50417f926fc948905aaab3e679b416b2e1 (patch) | |
tree | 51f67626e10ec7964d1ff1997084503174501632 /filter | |
parent | 26bfe59f450c2497dabc536c3e2a604e8aa5839a (diff) |
Filter: Resolving of defined constants in config time
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 2 | ||||
-rw-r--r-- | filter/f-inst.c | 45 |
2 files changed, 10 insertions, 37 deletions
diff --git a/filter/config.Y b/filter/config.Y index 72866bb0..ff2b966e 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -856,7 +856,7 @@ symbol_value: CF_SYM_KNOWN { switch ($1->class) { case SYM_CONSTANT_RANGE: - $$ = f_new_inst(FI_CONSTANT_DEFINED, $1); + $$ = f_new_inst(FI_CONSTANT, *($1->val)); break; case SYM_VARIABLE_RANGE: $$ = f_new_inst(FI_VAR_GET, $1); diff --git a/filter/f-inst.c b/filter/f-inst.c index ffe07738..a70a4a92 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -39,7 +39,7 @@ * m4_dnl C type, for storage in structs * m4_dnl name in f_inst, how the member is named before linearization * m4_dnl name in f_line_item, how the member is named afterwards - * m4_dnl comparator for same(), how the member is compared + * m4_dnl comparator for same(), if different, this should be TRUE (CAVEAT) * m4_dnl dump format string debug -> format string for bvsnprintf * m4_dnl dump format args appropriate args * m4_dnl interpreter body how to deal with this on execution @@ -294,44 +294,17 @@ /* some constants have value in a[1], some in *a[0].p, strange. */ INST(FI_CONSTANT, 0, 1) { /* integer (or simple type) constant, string, set, or prefix_set */ - FID_LINE_IN - struct f_val val; - FID_STRUCT_IN - struct f_val val; - FID_NEW_ARGS - , const struct f_val val - FID_NEW_BODY - whati->val = val; - FID_LINEARIZE_BODY - item->val = whati->val; - FID_SAME_BODY - if (!val_same(&(f1->val), &(f2->val))) return 0; - FID_DUMP_BODY - debug("%svalue %s\n", INDENT, val_dump(&item->val)); - FID_ALL + FID_MEMBER( + struct f_val, + val, + val, + [[ !val_same(&(f1->val), &(f2->val)) ]], + value %s, + val_dump(&(item->val)) + ); RESULT_VAL(whati->val); } - INST(FI_CONSTANT_DEFINED, 0, 1) { - FID_STRUCT_IN - const struct symbol *sym; - FID_LINE_IN - const struct symbol *sym; - const struct f_val *valp; - FID_NEW_ARGS - , const struct symbol *sym - FID_NEW_BODY - whati->sym = sym; - FID_LINEARIZE_BODY - item->valp = (item->sym = whati->sym)->val; - FID_SAME_BODY - if (strcmp(f1->sym->name, f2->sym->name) || !val_same(f1->sym->val, f2->sym->val)) return 0; - FID_DUMP_BODY - debug("%sconstant %s with value %s\n", INDENT, item->sym->name, val_dump(item->valp)); - FID_ALL - - RESULT_VAL(*whati->valp); - } INST(FI_PRINT, 1, 0) { ARG_ANY(1); val_format(&(v1), &fs->buf); |