aboutsummaryrefslogtreecommitdiff
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:03 -0700
commit24338fb9d964135fced728e943d0e8e80df3840b (patch)
tree64f1dd379bf3760381559da9430a20154a6194b9
parent1f09ec811eec9ea3a5ef4276f8e94ea6c5e85ef2 (diff)
downloadbinutils-24338fb9d964135fced728e943d0e8e80df3840b.zip
binutils-24338fb9d964135fced728e943d0e8e80df3840b.tar.gz
binutils-24338fb9d964135fced728e943d0e8e80df3840b.tar.bz2
Split out eval_op_lognot
This splits UNOP_LOGICAL_NOT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_lognot): New function. (evaluate_subexp_standard): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c29
2 files changed, 25 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9d39281..b9a8737 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_lognot): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_complement): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index f2dacee..6d447d5 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1805,6 +1805,25 @@ eval_op_complement (struct type *expect_type, struct expression *exp,
}
}
+/* A helper function for UNOP_LOGICAL_NOT. */
+
+static struct value *
+eval_op_lognot (struct type *expect_type, struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ if (unop_user_defined_p (op, arg1))
+ return value_x_unop (arg1, op, noside);
+ else
+ {
+ struct type *type = language_bool_type (exp->language_defn,
+ exp->gdbarch);
+ return value_from_longest (type, (LONGEST) value_logical_not (arg1));
+ }
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -2668,15 +2687,7 @@ evaluate_subexp_standard (struct type *expect_type,
case UNOP_LOGICAL_NOT:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- if (unop_user_defined_p (op, arg1))
- return value_x_unop (arg1, op, noside);
- else
- {
- type = language_bool_type (exp->language_defn, exp->gdbarch);
- return value_from_longest (type, (LONGEST) value_logical_not (arg1));
- }
+ return eval_op_lognot (expect_type, exp, noside, op, arg1);
case UNOP_IND:
if (expect_type && expect_type->code () == TYPE_CODE_PTR)