From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Split out ada_equal_binop X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=214b13ac3b8f041af4bd643808590955528a1d27;p=binutils-gdb.git Split out ada_equal_binop This splits BINOP_EQUAL and BINOP_NOTEQUAL into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey * ada-lang.c (ada_equal_binop): New function. (ada_evaluate_subexp): Use it. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b3eed7cd613..0edd02dfd2b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * ada-lang.c (ada_equal_binop): New function. + (ada_evaluate_subexp): Use it. + 2021-03-08 Tom Tromey * ada-lang.c (ada_mult_binop): New function. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 21c718e9c2d..39e8b8535bd 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10085,6 +10085,28 @@ ada_mult_binop (struct type *expect_type, } } +/* A helper function for BINOP_EQUAL and BINOP_NOTEQUAL. */ + +static value * +ada_equal_binop (struct type *expect_type, + struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1, struct value *arg2) +{ + int tem; + if (noside == EVAL_AVOID_SIDE_EFFECTS) + tem = 0; + else + { + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); + tem = ada_value_equal (arg1, arg2); + } + if (op == BINOP_NOTEQUAL) + tem = !tem; + struct type *type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); +} + /* Implement the evaluate_exp routine in the exp_descriptor structure for the Ada language. */ @@ -10252,17 +10274,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - tem = 0; - else - { - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - tem = ada_value_equal (arg1, arg2); - } - if (op == BINOP_NOTEQUAL) - tem = !tem; - type = language_bool_type (exp->language_defn, exp->gdbarch); - return value_from_longest (type, (LONGEST) tem); + return ada_equal_binop (expect_type, exp, noside, op, arg1, arg2); case UNOP_NEG: arg1 = evaluate_subexp (nullptr, exp, pos, noside);