0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Decrease number of warnings.

This commit is contained in:
Pavel Machek 1999-04-10 09:45:08 +00:00
parent 49ed70b48e
commit 2db3b2887e
3 changed files with 47 additions and 36 deletions

View File

@ -129,30 +129,30 @@ block:
; ;
constant: constant:
CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->arg1 = T_INT; $$->arg2 = $3; } CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_INT; $$->a2.i = $3; }
| NUM { $$ = f_new_inst(); $$->code = 'c'; $$->arg1 = T_INT; $$->arg2 = $1; } | NUM { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_INT; $$->a2.i = $1; }
| TRUE { $$ = f_new_inst(); $$->code = 'c'; $$->arg1 = T_BOOL; $$->arg2 = 1; } | TRUE { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_BOOL; $$->a2.i = 1; }
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->arg1 = T_BOOL; $$->arg2 = 0; } | FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_BOOL; $$->a2.i = 0; }
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->arg1 = T_STRING; $$->arg2 = $1; } | TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_STRING; $$->a2.p = $1; }
; ;
term: term:
term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->arg1 = $1; $$->arg2 = $3; } term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a1.p = $1; $$->a2.p = $3; }
| term '=' term { $$ = f_new_inst(); $$->code = '=='; $$->arg1 = $1; $$->arg2 = $3; } | term '=' term { $$ = f_new_inst(); $$->code = '=='; $$->a1.p = $1; $$->a2.p = $3; }
| term '!' '=' term { $$ = f_new_inst(); $$->code = '!='; $$->arg1 = $1; $$->arg2 = $4; } | term '!' '=' term { $$ = f_new_inst(); $$->code = '!='; $$->a1.p = $1; $$->a2.p = $4; }
| term '<' term { $$ = f_new_inst(); $$->code = '<'; $$->arg1 = $1; $$->arg2 = $3; } | term '<' term { $$ = f_new_inst(); $$->code = '<'; $$->a1.p = $1; $$->a2.p = $3; }
| term '<' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->arg1 = $1; $$->arg2 = $4; } | term '<' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->a1.p = $1; $$->a2.p = $4; }
| term '>' term { $$ = f_new_inst(); $$->code = '<'; $$->arg1 = $3; $$->arg2 = $1; } | term '>' term { $$ = f_new_inst(); $$->code = '<'; $$->a1.p = $3; $$->a2.p = $1; }
| term '>' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->arg1 = $4; $$->arg2 = $1; } | term '>' '=' term { $$ = f_new_inst(); $$->code = '<='; $$->a1.p = $4; $$->a2.p = $1; }
| SYM { | SYM {
$$ = f_new_inst(); $$ = f_new_inst();
switch ($1->class) { switch ($1->class) {
case SYM_VARIABLE | T_INT: case SYM_VARIABLE | T_INT:
$$->code = 'i'; $$->code = 'i';
$$->arg1 = T_INT; $$->a1.i = T_INT;
$$->arg2 = &($1->aux); $$->a2.p = &($1->aux);
break; break;
default: default:
cf_error("Can not use this class of symbol as variable" ); cf_error("Can not use this class of symbol as variable" );
@ -173,13 +173,13 @@ ifthen:
IF term THEN block { IF term THEN block {
$$ = f_new_inst(); $$ = f_new_inst();
$$->code = '?'; $$->code = '?';
$$->arg1 = $2; $$->a1.p = $2;
$$->arg2 = $4; $$->a2.p = $4;
} }
; ;
print_one: print_one:
term { $$ = f_new_inst(); $$->code = 'p'; $$->arg1 = $1; $$->arg2 = NULL; } term { $$ = f_new_inst(); $$->code = 'p'; $$->a1.p = $1; $$->a2.p = NULL; }
; ;
print_list: /* EMPTY */ { $$ = NULL; } print_list: /* EMPTY */ { $$ = NULL; }
@ -199,8 +199,8 @@ cmd:
| ifthen ELSE block { | ifthen ELSE block {
$$ = f_new_inst(); $$ = f_new_inst();
$$->code = '?'; $$->code = '?';
$$->arg1 = $1; $$->a1.p = $1;
$$->arg2 = $3; $$->a2.p = $3;
} }
| SYM '=' term ';' { | SYM '=' term ';' {
$$ = f_new_inst(); $$ = f_new_inst();
@ -208,10 +208,10 @@ cmd:
if (($1->class & ~T_MASK) != SYM_VARIABLE) if (($1->class & ~T_MASK) != SYM_VARIABLE)
cf_error( "You may only set variables, and this is %x.\n", $1->class ); cf_error( "You may only set variables, and this is %x.\n", $1->class );
$$->code = 's'; $$->code = 's';
$$->arg1 = $1; $$->a1.p = $1;
$$->arg2 = $3; $$->a2.p = $3;
} }
| break_command print_list ';' { $$ = f_new_inst(); $$->code = 'p,'; $$->arg1 = $2; $$->arg2 = $1; } | break_command print_list ';' { $$ = f_new_inst(); $$->code = 'p,'; $$->a1.p = $2; $$->a2.i = $1; }
; ;
CF_END CF_END

View File

@ -36,9 +36,9 @@ struct f_inst *startup_func = NULL;
if (x.type == T_RETURN) \ if (x.type == T_RETURN) \
return x; return x;
#define ONEARG ARG(v1, arg1) #define ONEARG ARG(v1, a1.p)
#define TWOARGS ARG(v1, arg1) \ #define TWOARGS ARG(v1, a1.p) \
ARG(v2, arg2) ARG(v2, a2.p)
#define TWOARGS_C TWOARGS \ #define TWOARGS_C TWOARGS \
if (v1.type != v2.type) \ if (v1.type != v2.type) \
runtime( "Can not operate with values of incompatible types" ); runtime( "Can not operate with values of incompatible types" );
@ -113,8 +113,8 @@ interpret(struct f_inst *what)
/* Set */ /* Set */
case 's': case 's':
ARG(v2, arg2); ARG(v2, a2.p);
sym = what->arg1; sym = what->a1.p;
switch (res.type = v2.type) { switch (res.type = v2.type) {
case T_VOID: runtime( "Can not assign void values" ); case T_VOID: runtime( "Can not assign void values" );
case T_INT: case T_INT:
@ -126,12 +126,12 @@ interpret(struct f_inst *what)
break; break;
case 'c': case 'c':
res.type = (int) what->arg1; res.type = what->a1.i;
res.val.i = (int) what->arg2; res.val.i = (int) what->a2.p;
break; break;
case 'i': case 'i':
res.type = (int) what->arg1; res.type = what->a1.i;
res.val.i = * ((int *) what->arg2); res.val.i = * ((int *) what->a2.p);
break; break;
case 'p': case 'p':
ONEARG; ONEARG;
@ -147,7 +147,7 @@ interpret(struct f_inst *what)
if (v1.type != T_BOOL) if (v1.type != T_BOOL)
runtime( "If requires bool expression" ); runtime( "If requires bool expression" );
if (v1.val.i) { if (v1.val.i) {
ARG(res,arg2); ARG(res,a2.p);
res.val.i = 0; res.val.i = 0;
} else res.val.i = 1; } else res.val.i = 1;
res.type = T_BOOL; res.type = T_BOOL;
@ -159,7 +159,7 @@ interpret(struct f_inst *what)
ONEARG; ONEARG;
printf( "\n" ); printf( "\n" );
switch ((int) what->arg2) { switch (what->a2.i) {
case F_QUITBIRD: case F_QUITBIRD:
die( "Filter asked me to die" ); die( "Filter asked me to die" );
case F_ACCEPT: case F_ACCEPT:
@ -167,7 +167,7 @@ interpret(struct f_inst *what)
case F_ERROR: case F_ERROR:
case F_REJECT: case F_REJECT:
res.type = T_RETURN; res.type = T_RETURN;
res.val.i = (int) what->arg1; res.val.i = what->a1.i;
break; break;
case F_NOP: case F_NOP:
break; break;

View File

@ -15,9 +15,19 @@
struct f_inst { /* Instruction */ struct f_inst { /* Instruction */
struct f_inst *next; /* Structure is 16 bytes, anyway */ struct f_inst *next; /* Structure is 16 bytes, anyway */
int code; int code;
void *arg1, *arg2; union {
int i;
void *p;
} a1;
union {
int i;
void *p;
} a2;
}; };
#define arg1 a1.p
#define arg2 a2.p
struct prefix { struct prefix {
ip_addr ip; ip_addr ip;
int len; int len;
@ -27,7 +37,8 @@ struct f_val {
int type; int type;
union { union {
int i; int i;
struct prefix *px; ip_addr ip;
struct prefix px;
char *s; char *s;
} val; } val;
}; };