From 30667d50417f926fc948905aaab3e679b416b2e1 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 1 Jul 2019 14:12:05 +0200 Subject: [PATCH] Filter: Resolving of defined constants in config time --- filter/config.Y | 2 +- filter/f-inst.c | 45 +++++++++------------------------------------ 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/filter/config.Y b/filter/config.Y index 72866bb0b..ff2b966e5 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 ffe07738a..a70a4a921 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); -- 2.39.2