GRIB-394:grib_filter further fixes required because of mixed types in IF statement

This commit is contained in:
Shahram Najm 2013-08-14 16:06:12 +01:00
parent cabc6994b0
commit 40fa5272df
3 changed files with 214 additions and 191 deletions

View File

@ -92,7 +92,6 @@
c = c->super ? *(c->super) : NULL;
}
Assert(1==0);
}
void grib_expression_compile(grib_expression* g,grib_compiler* f)
@ -224,7 +223,6 @@ void grib_arguments_print(grib_context* c,grib_arguments* g,grib_handle* f)
return e ? grib_expression_get_name(e) : NULL;
}
const char* grib_arguments_get_string(grib_handle* h,grib_arguments* args,int n)
{
grib_expression *e = NULL;
@ -249,7 +247,6 @@ void grib_arguments_print(grib_context* c,grib_arguments* g,grib_handle* f)
e = args->expression;
ret = grib_expression_evaluate_long(h,e,&lres);
return lres;
}
double grib_arguments_get_double(grib_handle* h,grib_arguments* args,int n)
@ -276,7 +273,3 @@ void grib_arguments_print(grib_context* c,grib_arguments* g,grib_handle* f)
return args->expression;
}

View File

@ -103,6 +103,21 @@ static int evaluate_long(grib_expression *g,grib_handle* h,long* lres)
int ret;
grib_expression_binop* e = (grib_expression_binop*)g;
#if 0 /* DEBUGGING */
{
int typeLeft, typeRight;
const char* nameLeft;
const char* nameRight;
typeLeft = grib_expression_native_type(h, e->left);
typeRight = grib_expression_native_type(h, e->right);
nameLeft = grib_expression_get_name(e->left);
nameRight= grib_expression_get_name(e->right);
printf("eval_long nameLeft=%s (type=%d), nameRight=%s (type=%d)\n",nameLeft,typeLeft, nameRight,typeRight);
grib_expression_print(h->context, g, h);
printf("\n");
}
#endif
ret = grib_expression_evaluate_long(h,e->left,&v1);
if (ret != GRIB_SUCCESS) return ret;
@ -121,6 +136,21 @@ static int evaluate_double(grib_expression *g,grib_handle* h,double* dres)
grib_expression_binop* e = (grib_expression_binop*)g;
#if 0 /* DEBUGGING */
{
int typeLeft, typeRight;
const char* nameLeft;
const char* nameRight;
typeLeft = grib_expression_native_type(h, e->left);
typeRight = grib_expression_native_type(h, e->right);
nameLeft = grib_expression_get_name(e->left);
nameRight= grib_expression_get_name(e->right);
printf("eval_dbl nameLeft=%s (type=%d), nameRight=%s (type=%d)\n",nameLeft,typeLeft, nameRight,typeRight);
grib_expression_print(h->context, g, h);
printf("\n");
}
#endif
ret = grib_expression_evaluate_double(h,e->left,&v1);
if (ret != GRIB_SUCCESS) return ret;
@ -191,5 +221,5 @@ static int native_type(grib_expression* g,grib_handle *h)
{
return GRIB_TYPE_DOUBLE;
}
return e->double_func ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE;
return e->long_func ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE;
}

View File

@ -161,5 +161,5 @@ static void compile(grib_expression* g,grib_compiler* c)
static int native_type(grib_expression* g,grib_handle *h)
{
grib_expression_unop* e = (grib_expression_unop*)g;
return e->double_func ? GRIB_TYPE_DOUBLE : GRIB_TYPE_LONG;
return e->long_func ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE;
}