diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:02 -0700 |
commit | 96e3efd9b2458355440fbaaea391003fb8f5cdef (patch) | |
tree | ca368aae9b2994cc38a38762c3716889c53e3aaa | |
parent | 1f78d732ecde9e30c40b3cb816a8dcb262b5172c (diff) | |
download | binutils-96e3efd9b2458355440fbaaea391003fb8f5cdef.zip binutils-96e3efd9b2458355440fbaaea391003fb8f5cdef.tar.gz binutils-96e3efd9b2458355440fbaaea391003fb8f5cdef.tar.bz2 |
Split out eval_op_geq
This splits BINOP_GEQ into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_geq): New function.
(evaluate_subexp_standard): Use it.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/eval.c | 37 |
2 files changed, 29 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 580c0f7..c66440f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_geq): New function. + (evaluate_subexp_standard): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_gtr): New function. (evaluate_subexp_standard): Use it. @@ -1683,6 +1683,29 @@ eval_op_gtr (struct type *expect_type, struct expression *exp, } } +/* A helper function for BINOP_GEQ. */ + +static struct value * +eval_op_geq (struct type *expect_type, struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1, struct value *arg2) +{ + if (noside == EVAL_SKIP) + return eval_skip_value (exp); + if (binop_user_defined_p (op, arg1, arg2)) + { + return value_x_binop (arg1, arg2, op, OP_NULL, noside); + } + else + { + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); + int tem = value_less (arg2, arg1) || value_equal (arg1, arg2); + struct type *type = language_bool_type (exp->language_defn, + exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); + } +} + struct value * evaluate_subexp_standard (struct type *expect_type, struct expression *exp, int *pos, @@ -2514,19 +2537,7 @@ evaluate_subexp_standard (struct type *expect_type, case BINOP_GEQ: arg1 = evaluate_subexp (nullptr, exp, pos, noside); arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - return eval_skip_value (exp); - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL, noside); - } - else - { - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - tem = value_less (arg2, arg1) || value_equal (arg1, arg2); - type = language_bool_type (exp->language_defn, exp->gdbarch); - return value_from_longest (type, (LONGEST) tem); - } + return eval_op_geq (expect_type, exp, noside, op, arg1, arg2); case BINOP_LEQ: arg1 = evaluate_subexp (nullptr, exp, pos, noside); |