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

View file

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

View file

@ -15,9 +15,19 @@
struct f_inst { /* Instruction */
struct f_inst *next; /* Structure is 16 bytes, anyway */
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 {
ip_addr ip;
int len;
@ -27,7 +37,8 @@ struct f_val {
int type;
union {
int i;
struct prefix *px;
ip_addr ip;
struct prefix px;
char *s;
} val;
};