aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:11 -0700
commitfaa1dfd751a2b9aed57cf344a78905591708bb58 (patch)
tree22ae3aff4023136020421c814073b9565b06a534 /gdb/ada-lang.c
parentd05e24e61a7dc22076568a59b3d4bbbd63ca764c (diff)
downloadgdb-faa1dfd751a2b9aed57cf344a78905591708bb58.zip
gdb-faa1dfd751a2b9aed57cf344a78905591708bb58.tar.gz
gdb-faa1dfd751a2b9aed57cf344a78905591708bb58.tar.bz2
Split out ada_mult_binop
This splits BINOP_MUL into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-lang.c (ada_mult_binop): New function. (ada_evaluate_subexp): Use it.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index cf84cf0..21c718e 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: