mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
Filter: Getting rid of RESULT_OK. Adding RESULT_VOID.
This is a preparation for filter pre-evaluation.
This commit is contained in:
parent
236828d06f
commit
f74d19765e
@ -227,9 +227,9 @@ do { if (whati->fl$1) {
|
|||||||
} } while(0)m4_dnl
|
} } while(0)m4_dnl
|
||||||
FID_ALL()')
|
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, `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,
|
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)')
|
[[strcmp(f1->sym->name, f2->sym->name) || (f1->sym->class != f2->sym->class)]], symbol %s, item->sym->name, const struct symbol *sym = whati->sym)')
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
* m4_dnl ACCESS_RTE; this instruction needs route
|
* m4_dnl ACCESS_RTE; this instruction needs route
|
||||||
* m4_dnl ACCESS_EATTRS; this instruction needs extended attributes
|
* m4_dnl ACCESS_EATTRS; this instruction needs extended attributes
|
||||||
* m4_dnl RESULT(type, union-field, value); putting this on value stack
|
* 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 }
|
* m4_dnl }
|
||||||
*
|
*
|
||||||
* Other code is just copied into the interpreter part.
|
* Other code is just copied into the interpreter part.
|
||||||
@ -50,41 +51,37 @@
|
|||||||
INST(FI_ADD, 2, 1) {
|
INST(FI_ADD, 2, 1) {
|
||||||
ARG(1,T_INT);
|
ARG(1,T_INT);
|
||||||
ARG(2,T_INT);
|
ARG(2,T_INT);
|
||||||
res.val.i = v1.val.i + v2.val.i;
|
RESULT(T_INT, i, v1.val.i + v2.val.i);
|
||||||
RESULT_OK;
|
|
||||||
}
|
}
|
||||||
INST(FI_SUBTRACT, 2, 1) {
|
INST(FI_SUBTRACT, 2, 1) {
|
||||||
ARG(1,T_INT);
|
ARG(1,T_INT);
|
||||||
ARG(2,T_INT);
|
ARG(2,T_INT);
|
||||||
res.val.i = v1.val.i - v2.val.i;
|
RESULT(T_INT, i, v1.val.i - v2.val.i);
|
||||||
RESULT_OK;
|
|
||||||
}
|
}
|
||||||
INST(FI_MULTIPLY, 2, 1) {
|
INST(FI_MULTIPLY, 2, 1) {
|
||||||
ARG(1,T_INT);
|
ARG(1,T_INT);
|
||||||
ARG(2,T_INT);
|
ARG(2,T_INT);
|
||||||
res.val.i = v1.val.i * v2.val.i;
|
RESULT(T_INT, i, v1.val.i * v2.val.i);
|
||||||
RESULT_OK;
|
|
||||||
}
|
}
|
||||||
INST(FI_DIVIDE, 2, 1) {
|
INST(FI_DIVIDE, 2, 1) {
|
||||||
ARG(1,T_INT);
|
ARG(1,T_INT);
|
||||||
ARG(2,T_INT);
|
ARG(2,T_INT);
|
||||||
if (v2.val.i == 0) runtime( "Mother told me not to divide by 0" );
|
if (v2.val.i == 0) runtime( "Mother told me not to divide by 0" );
|
||||||
res.val.i = v1.val.i / v2.val.i;
|
RESULT(T_INT, i, v1.val.i / v2.val.i);
|
||||||
RESULT_OK;
|
|
||||||
}
|
}
|
||||||
INST(FI_AND, 1, 1) {
|
INST(FI_AND, 1, 1) {
|
||||||
ARG(1,T_BOOL);
|
ARG(1,T_BOOL);
|
||||||
if (res.val.i)
|
if (v1.val.i)
|
||||||
LINE(2,0);
|
LINE(2,0);
|
||||||
else
|
else
|
||||||
RESULT_OK;
|
RESULT_VAL(v1);
|
||||||
}
|
}
|
||||||
INST(FI_OR, 1, 1) {
|
INST(FI_OR, 1, 1) {
|
||||||
ARG(1,T_BOOL);
|
ARG(1,T_BOOL);
|
||||||
if (!res.val.i)
|
if (!v1.val.i)
|
||||||
LINE(2,0);
|
LINE(2,0);
|
||||||
else
|
else
|
||||||
RESULT_OK;
|
RESULT_VAL(v1);
|
||||||
}
|
}
|
||||||
INST(FI_PAIR_CONSTRUCT, 2, 1) {
|
INST(FI_PAIR_CONSTRUCT, 2, 1) {
|
||||||
ARG(1,T_INT);
|
ARG(1,T_INT);
|
||||||
@ -281,8 +278,7 @@
|
|||||||
|
|
||||||
INST(FI_VAR_GET, 0, 1) {
|
INST(FI_VAR_GET, 0, 1) {
|
||||||
SYMBOL(1);
|
SYMBOL(1);
|
||||||
res = fstk->vstk[curline.vbase + sym->offset];
|
RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
|
||||||
RESULT_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* some constants have value in a[1], some in *a[0].p, strange. */
|
/* some constants have value in a[1], some in *a[0].p, strange. */
|
||||||
@ -323,8 +319,7 @@
|
|||||||
debug("%sconstant %s with value %s\n", INDENT, item->sym->name, val_dump(item->valp));
|
debug("%sconstant %s with value %s\n", INDENT, item->sym->name, val_dump(item->valp));
|
||||||
FID_ALL
|
FID_ALL
|
||||||
|
|
||||||
res = *whati->valp;
|
RESULT_VAL(*whati->valp);
|
||||||
RESULT_OK;
|
|
||||||
}
|
}
|
||||||
INST(FI_PRINT, 1, 0) {
|
INST(FI_PRINT, 1, 0) {
|
||||||
ARG_ANY(1);
|
ARG_ANY(1);
|
||||||
@ -500,8 +495,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Undefined value */
|
/* Undefined value */
|
||||||
res.type = T_VOID;
|
RESULT_VOID;
|
||||||
RESULT_OK;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,8 +528,7 @@
|
|||||||
RESULT(T_LCLIST, ad, e->u.ptr);
|
RESULT(T_LCLIST, ad, e->u.ptr);
|
||||||
break;
|
break;
|
||||||
case EAF_TYPE_UNDEF:
|
case EAF_TYPE_UNDEF:
|
||||||
res.type = T_VOID;
|
RESULT_VOID;
|
||||||
RESULT_OK;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bug("Unknown dynamic attribute type");
|
bug("Unknown dynamic attribute type");
|
||||||
|
Loading…
Reference in New Issue
Block a user