From 60cdd4871ac9c9e0118cd47c7fce36cd5163404a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Split out eval_op_leq This splits BINOP_LEQ into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey * eval.c (eval_op_leq): New function. (evaluate_subexp_standard): Use it. --- gdb/ChangeLog | 5 +++++ gdb/eval.c | 37 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c66440fc138..6cc372978af 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * eval.c (eval_op_leq): New function. + (evaluate_subexp_standard): Use it. + 2021-03-08 Tom Tromey * eval.c (eval_op_geq): New function. diff --git a/gdb/eval.c b/gdb/eval.c index 15a2ee27cb0..4e02bc0c88b 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1706,6 +1706,29 @@ eval_op_geq (struct type *expect_type, struct expression *exp, } } +/* A helper function for BINOP_LEQ. */ + +static struct value * +eval_op_leq (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 (arg1, arg2) || 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, @@ -2542,19 +2565,7 @@ evaluate_subexp_standard (struct type *expect_type, case BINOP_LEQ: 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 (arg1, arg2) || value_equal (arg1, arg2); - type = language_bool_type (exp->language_defn, exp->gdbarch); - return value_from_longest (type, (LONGEST) tem); - } + return eval_op_leq (expect_type, exp, noside, op, arg1, arg2); case BINOP_REPEAT: arg1 = evaluate_subexp (nullptr, exp, pos, noside); -- 2.30.2