mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-05 08:31:53 +00:00
Filter: Make the IF instruction three-args
Dropping another old quirk.
This commit is contained in:
parent
8e86ffce82
commit
76cc61fa51
@ -989,12 +989,10 @@ cmd:
|
|||||||
$$->a2.p = $4;
|
$$->a2.p = $4;
|
||||||
}
|
}
|
||||||
| IF term THEN block ELSE block {
|
| IF term THEN block ELSE block {
|
||||||
struct f_inst *i = f_new_inst(FI_CONDITION);
|
|
||||||
i->a1.p = $2;
|
|
||||||
i->a2.p = $4;
|
|
||||||
$$ = f_new_inst(FI_CONDITION);
|
$$ = f_new_inst(FI_CONDITION);
|
||||||
$$->a1.p = i;
|
$$->a1.p = $2;
|
||||||
$$->a2.p = $6;
|
$$->a2.p = $4;
|
||||||
|
$$->a3.p = $6;
|
||||||
}
|
}
|
||||||
| SYM '=' term ';' {
|
| SYM '=' term ';' {
|
||||||
DBG( "Ook, we'll set value\n" );
|
DBG( "Ook, we'll set value\n" );
|
||||||
|
@ -897,14 +897,13 @@ interpret(struct f_inst *what)
|
|||||||
ARG_ANY(1);
|
ARG_ANY(1);
|
||||||
val_format(v1, &f_buf);
|
val_format(v1, &f_buf);
|
||||||
break;
|
break;
|
||||||
case FI_CONDITION: /* ? has really strange error value, so we can implement if ... else nicely :-) */
|
case FI_CONDITION:
|
||||||
ARG(1, T_BOOL);
|
ARG(1, T_BOOL);
|
||||||
if (v1.val.i) {
|
if (v1.val.i) {
|
||||||
ARG_ANY(2);
|
ARG_ANY(2);
|
||||||
res.val.i = 0;
|
} else {
|
||||||
} else
|
ARG_ANY(3);
|
||||||
res.val.i = 1;
|
}
|
||||||
res.type = T_BOOL;
|
|
||||||
break;
|
break;
|
||||||
case FI_NOP:
|
case FI_NOP:
|
||||||
debug( "No operation\n" );
|
debug( "No operation\n" );
|
||||||
@ -1669,7 +1668,7 @@ i_same(struct f_inst *f1, struct f_inst *f2)
|
|||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case FI_PRINT: case FI_LENGTH: ONEARG; break;
|
case FI_PRINT: case FI_LENGTH: ONEARG; break;
|
||||||
case FI_CONDITION: TWOARGS; break;
|
case FI_CONDITION: THREEARGS; break;
|
||||||
case FI_NOP: case FI_EMPTY: break;
|
case FI_NOP: case FI_EMPTY: break;
|
||||||
case FI_PRINT_AND_DIE: ONEARG; A2_SAME; break;
|
case FI_PRINT_AND_DIE: ONEARG; A2_SAME; break;
|
||||||
case FI_PREF_GET:
|
case FI_PREF_GET:
|
||||||
|
Loading…
Reference in New Issue
Block a user