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:01 -0700 |
commit | 1f78d732ecde9e30c40b3cb816a8dcb262b5172c (patch) | |
tree | 666a7716ab7869cac854868909061ffd21c97672 /gdb/eval.c | |
parent | 6cad134942898cf2f6398e684a38aa5823d16889 (diff) | |
download | binutils-1f78d732ecde9e30c40b3cb816a8dcb262b5172c.zip binutils-1f78d732ecde9e30c40b3cb816a8dcb262b5172c.tar.gz binutils-1f78d732ecde9e30c40b3cb816a8dcb262b5172c.tar.bz2 |
Split out eval_op_gtr
This splits BINOP_GTR into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_gtr): New function.
(evaluate_subexp_standard): Use it.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r-- | gdb/eval.c | 37 |
1 files changed, 24 insertions, 13 deletions
@@ -1660,6 +1660,29 @@ eval_op_less (struct type *expect_type, struct expression *exp, } } +/* A helper function for BINOP_GTR. */ + +static struct value * +eval_op_gtr (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); + 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, @@ -2486,19 +2509,7 @@ evaluate_subexp_standard (struct type *expect_type, case BINOP_GTR: 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); - type = language_bool_type (exp->language_defn, exp->gdbarch); - return value_from_longest (type, (LONGEST) tem); - } + return eval_op_gtr (expect_type, exp, noside, op, arg1, arg2); case BINOP_GEQ: arg1 = evaluate_subexp (nullptr, exp, pos, noside); |