From faa1dfd751a2b9aed57cf344a78905591708bb58 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Split out ada_mult_binop This splits BINOP_MUL into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey * ada-lang.c (ada_mult_binop): New function. (ada_evaluate_subexp): Use it. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 33 ++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7fb5e9b30d5..b3eed7cd613 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * ada-lang.c (ada_mult_binop): New function. + (ada_evaluate_subexp): Use it. + 2021-03-08 Tom Tromey * ada-lang.c (ada_abs): New function. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index cf84cf00563..21c718e9c2d 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10065,6 +10065,26 @@ ada_abs (struct type *expect_type, return arg1; } +/* A helper function for BINOP_MUL. */ + +static value * +ada_mult_binop (struct type *expect_type, + struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1, struct value *arg2) +{ + if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); + return value_zero (value_type (arg1), not_lval); + } + else + { + binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); + return ada_value_binop (arg1, arg2, op); + } +} + /* Implement the evaluate_exp routine in the exp_descriptor structure for the Ada language. */ @@ -10223,17 +10243,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg2 = evaluate_subexp (nullptr, exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - else if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - return value_zero (value_type (arg1), not_lval); - } - else - { - type = builtin_type (exp->gdbarch)->builtin_double; - binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - return ada_value_binop (arg1, arg2, op); - } + return ada_mult_binop (expect_type, exp, noside, op, + arg1, arg2); case BINOP_EQUAL: case BINOP_NOTEQUAL: -- 2.30.2