aboutsummaryrefslogtreecommitdiff
path: root/gdb
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
commit214b13ac3b8f041af4bd643808590955528a1d27 (patch)
tree110bc6c0efdb93e1c8708cf13345a92fd22c1b22 /gdb
parentfaa1dfd751a2b9aed57cf344a78905591708bb58 (diff)
downloadgdb-214b13ac3b8f041af4bd643808590955528a1d27.zip
gdb-214b13ac3b8f041af4bd643808590955528a1d27.tar.gz
gdb-214b13ac3b8f041af4bd643808590955528a1d27.tar.bz2
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 <tom@tromey.com> * ada-lang.c (ada_equal_binop): New function. (ada_evaluate_subexp): Use it.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-lang.c34
2 files changed, 28 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b3eed7c..0edd02d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * ada-lang.c (ada_equal_binop): New function.
+ (ada_evaluate_subexp): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (ada_mult_binop): New function.
(ada_evaluate_subexp): Use it.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 21c718e..39e8b85 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);