[PATCH v2 024/206] Split out eval_op_plus
Tom Tromey
tom@tromey.com
Sat Feb 13 19:59:54 GMT 2021
This splits UNOP_PLUS into a new function for future use.
2021-02-13 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_plus): New function.
(evaluate_subexp_standard): Use it.
---
gdb/ChangeLog | 5 +++++
gdb/eval.c | 28 +++++++++++++++++++---------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 865d40e2a49..132b45cee4e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1748,6 +1748,24 @@ eval_op_repeat (struct type *expect_type, struct expression *exp,
return value_repeat (arg1, longest_to_int (value_as_long (arg2)));
}
+/* A helper function for UNOP_PLUS. */
+
+static struct value *
+eval_op_plus (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
+ {
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ return value_pos (arg1);
+ }
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -2597,15 +2615,7 @@ evaluate_subexp_standard (struct type *expect_type,
case UNOP_PLUS:
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
- {
- unop_promote (exp->language_defn, exp->gdbarch, &arg1);
- return value_pos (arg1);
- }
+ return eval_op_plus (expect_type, exp, noside, op, arg1);
case UNOP_NEG:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
--
2.26.2
More information about the Gdb-patches
mailing list