Split out eval_op_f_ceil
This splits UNOP_FORTRAN_CEILING into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * f-lang.c (eval_op_f_ceil): New function. (evaluate_subexp_f): Use it.
This commit is contained in:
parent
e08109f24b
commit
3dc41f3cdf
2 changed files with 26 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* f-lang.c (eval_op_f_ceil): New function.
|
||||||
|
(evaluate_subexp_f): Use it.
|
||||||
|
|
||||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* f-lang.c (eval_op_f_mod): New function.
|
* f-lang.c (eval_op_f_mod): New function.
|
||||||
|
|
32
gdb/f-lang.c
32
gdb/f-lang.c
|
@ -1041,6 +1041,25 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp,
|
||||||
error (_("MOD of type %s not supported"), TYPE_SAFE_NAME (type));
|
error (_("MOD of type %s not supported"), TYPE_SAFE_NAME (type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A helper function for UNOP_FORTRAN_CEILING. */
|
||||||
|
|
||||||
|
static struct value *
|
||||||
|
eval_op_f_ceil (struct type *expect_type, struct expression *exp,
|
||||||
|
enum noside noside,
|
||||||
|
struct value *arg1)
|
||||||
|
{
|
||||||
|
if (noside == EVAL_SKIP)
|
||||||
|
return eval_skip_value (exp);
|
||||||
|
struct type *type = value_type (arg1);
|
||||||
|
if (type->code () != TYPE_CODE_FLT)
|
||||||
|
error (_("argument to CEILING must be of type float"));
|
||||||
|
double val
|
||||||
|
= target_float_to_host_double (value_contents (arg1),
|
||||||
|
value_type (arg1));
|
||||||
|
val = ceil (val);
|
||||||
|
return value_from_host_double (type, val);
|
||||||
|
}
|
||||||
|
|
||||||
/* Special expression evaluation cases for Fortran. */
|
/* Special expression evaluation cases for Fortran. */
|
||||||
|
|
||||||
static struct value *
|
static struct value *
|
||||||
|
@ -1072,19 +1091,8 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
|
||||||
return eval_op_f_mod (expect_type, exp, noside, arg1, arg2);
|
return eval_op_f_mod (expect_type, exp, noside, arg1, arg2);
|
||||||
|
|
||||||
case UNOP_FORTRAN_CEILING:
|
case UNOP_FORTRAN_CEILING:
|
||||||
{
|
|
||||||
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
|
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
|
||||||
if (noside == EVAL_SKIP)
|
return eval_op_f_ceil (expect_type, exp, noside, arg1);
|
||||||
return eval_skip_value (exp);
|
|
||||||
type = value_type (arg1);
|
|
||||||
if (type->code () != TYPE_CODE_FLT)
|
|
||||||
error (_("argument to CEILING must be of type float"));
|
|
||||||
double val
|
|
||||||
= target_float_to_host_double (value_contents (arg1),
|
|
||||||
value_type (arg1));
|
|
||||||
val = ceil (val);
|
|
||||||
return value_from_host_double (type, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
case UNOP_FORTRAN_FLOOR:
|
case UNOP_FORTRAN_FLOOR:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue