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:01 -0700
commit0cc96de858823ae76c23430b71304e306e55f861 (patch)
tree199c2dcce009c2832bf79684a0e32cb647989eee /gdb
parent288d26bcd841072069237b03d8c1197aa68560d0 (diff)
downloadgdb-0cc96de858823ae76c23430b71304e306e55f861.zip
gdb-0cc96de858823ae76c23430b71304e306e55f861.tar.gz
gdb-0cc96de858823ae76c23430b71304e306e55f861.tar.bz2
Split out eval_op_equal
This splits BINOP_EQUAL into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_equal): New function. (evaluate_subexp_standard): Use it.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c37
2 files changed, 29 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dfbf126..d03a24e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_equal): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_subscript): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index 9ac3f39..139aeb8 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1591,6 +1591,29 @@ eval_op_subscript (struct type *expect_type, struct expression *exp,
}
}
+/* A helper function for BINOP_EQUAL. */
+
+static struct value *
+eval_op_equal (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_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,
@@ -2402,19 +2425,7 @@ evaluate_subexp_standard (struct type *expect_type,
case BINOP_EQUAL:
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_equal (arg1, arg2);
- type = language_bool_type (exp->language_defn, exp->gdbarch);
- return value_from_longest (type, (LONGEST) tem);
- }
+ return eval_op_equal (expect_type, exp, noside, op, arg1, arg2);
case BINOP_NOTEQUAL:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);