]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Resolving of defined constants in config time
authorMaria Matejka <mq@ucw.cz>
Mon, 1 Jul 2019 12:12:05 +0000 (14:12 +0200)
committerMaria Matejka <mq@ucw.cz>
Mon, 1 Jul 2019 12:12:05 +0000 (14:12 +0200)
filter/config.Y
filter/f-inst.c

index 72866bb0b6c41dd7752a9b47c6f3f9f02642f456..ff2b966e53a96b9c6601d9ee2d8db59447300605 100644 (file)
@@ -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);
index ffe07738a2dd84a7259b568e2bd68095c14a37f5..a70a4a921a42128d26f632c2fa83b335f8a48d2d 100644 (file)
@@ -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
 
     /* 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);