diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:02 -0700 |
commit | 39f288bea9fbae9e63c123411c150f8f34ea0059 (patch) | |
tree | 907500f1fec98b5a07831c8efe943c0304e92b5e | |
parent | eed70b1c374ac4155f5d18b87a5a6a74581f2076 (diff) | |
download | binutils-39f288bea9fbae9e63c123411c150f8f34ea0059.zip binutils-39f288bea9fbae9e63c123411c150f8f34ea0059.tar.gz binutils-39f288bea9fbae9e63c123411c150f8f34ea0059.tar.bz2 |
Split out eval_op_plus
This splits UNOP_PLUS into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_plus): New function.
(evaluate_subexp_standard): Use it.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/eval.c | 28 |
2 files changed, 24 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1da2a5c..3379b9f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_plus): New function. + (evaluate_subexp_standard): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_repeat): New function. (evaluate_subexp_standard): Use it. @@ -1751,6 +1751,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, @@ -2600,15 +2618,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); |