]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Getting rid of RESULT_OK. Adding RESULT_VOID.
authorMaria Matejka <mq@ucw.cz>
Mon, 1 Jul 2019 10:07:06 +0000 (12:07 +0200)
committerMaria Matejka <mq@ucw.cz>
Mon, 1 Jul 2019 10:07:06 +0000 (12:07 +0200)
This is a preparation for filter pre-evaluation.

filter/decl.m4
filter/f-inst.c

index 50224abd12a58bf9a160545113024d5d013aae34..77af84b3dfc166eaa4d11dd3eac195d920c99948 100644 (file)
@@ -227,9 +227,9 @@ do { if (whati->fl$1) {
 } } while(0)m4_dnl
 FID_ALL()')
 
-m4_define(RESULT_OK, `FID_INTERPRET_BODY()fstk->vcnt++FID_ALL()')
 m4_define(RESULT, `RESULT_VAL([[ (struct f_val) { .type = $1, .val.$2 = $3 } ]])')
-m4_define(RESULT_VAL, `FID_INTERPRET_BODY()do { res = $1; RESULT_OK; } while (0)FID_ALL()')
+m4_define(RESULT_VAL, `FID_INTERPRET_BODY()do { res = $1; fstk->vcnt++; } while (0)FID_ALL()')
+m4_define(RESULT_VOID, `RESULT_VAL([[ (struct f_val) { .type = T_VOID } ]])')
 
 m4_define(SYMBOL, `FID_MEMBER(const struct symbol *, sym, sym,
 [[strcmp(f1->sym->name, f2->sym->name) || (f1->sym->class != f2->sym->class)]], symbol %s, item->sym->name, const struct symbol *sym = whati->sym)')
index f033bea11d2f4461efa9812f733732aa51bac6f4..d48a60866f526ef6148813bc092538106fe85d02 100644 (file)
@@ -36,7 +36,8 @@
  *     m4_dnl    ACCESS_RTE;                           this instruction needs route
  *     m4_dnl    ACCESS_EATTRS;                        this instruction needs extended attributes
  *     m4_dnl    RESULT(type, union-field, value);     putting this on value stack
- *     m4_dnl    RESULT_OK;                            legalize what already is on the value stack
+ *     m4_dnl    RESULT_VAL(value-struct);             pass the struct f_val directly
+ *     m4_dnl    RESULT_VOID;                          return undef
  *     m4_dnl  }
  *
  *     Other code is just copied into the interpreter part.
   INST(FI_ADD, 2, 1) {
     ARG(1,T_INT);
     ARG(2,T_INT);
-    res.val.i = v1.val.i + v2.val.i;
-    RESULT_OK;
+    RESULT(T_INT, i, v1.val.i + v2.val.i);
   }
   INST(FI_SUBTRACT, 2, 1) {
     ARG(1,T_INT);
     ARG(2,T_INT);
-    res.val.i = v1.val.i - v2.val.i;
-    RESULT_OK;
+    RESULT(T_INT, i, v1.val.i - v2.val.i);
   }
   INST(FI_MULTIPLY, 2, 1) {
     ARG(1,T_INT);
     ARG(2,T_INT);
-    res.val.i = v1.val.i * v2.val.i;
-    RESULT_OK;
+    RESULT(T_INT, i, v1.val.i * v2.val.i);
   }
   INST(FI_DIVIDE, 2, 1) {
     ARG(1,T_INT);
     ARG(2,T_INT);
     if (v2.val.i == 0) runtime( "Mother told me not to divide by 0" );
-    res.val.i = v1.val.i / v2.val.i;
-    RESULT_OK;
+    RESULT(T_INT, i, v1.val.i / v2.val.i);
   }
   INST(FI_AND, 1, 1) {
     ARG(1,T_BOOL);
-    if (res.val.i)
+    if (v1.val.i)
       LINE(2,0);
     else
-      RESULT_OK;
+      RESULT_VAL(v1);
   }
   INST(FI_OR, 1, 1) {
     ARG(1,T_BOOL);
-    if (!res.val.i)
+    if (!v1.val.i)
       LINE(2,0);
     else
-      RESULT_OK;
+      RESULT_VAL(v1);
   }
   INST(FI_PAIR_CONSTRUCT, 2, 1) {
     ARG(1,T_INT);
 
   INST(FI_VAR_GET, 0, 1) {
     SYMBOL(1);
-    res = fstk->vstk[curline.vbase + sym->offset];
-    RESULT_OK;
+    RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
   }
 
     /* some constants have value in a[1], some in *a[0].p, strange. */
       debug("%sconstant %s with value %s\n", INDENT, item->sym->name, val_dump(item->valp));
     FID_ALL
 
-    res = *whati->valp;
-    RESULT_OK;
+    RESULT_VAL(*whati->valp);
   }
   INST(FI_PRINT, 1, 0) {
     ARG_ANY(1);
        }
 
        /* Undefined value */
-       res.type = T_VOID;
-       RESULT_OK;
+       RESULT_VOID;
        break;
       }
 
        RESULT(T_LCLIST, ad, e->u.ptr);
        break;
       case EAF_TYPE_UNDEF:
-       res.type = T_VOID;
-       RESULT_OK;
+       RESULT_VOID;
        break;
       default:
        bug("Unknown dynamic attribute type");