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:03 -0700 |
commit | 1f09ec811eec9ea3a5ef4276f8e94ea6c5e85ef2 (patch) | |
tree | d0c6c8fdd38d8831122a445975ea10a8d2cf8755 /gdb | |
parent | 606d105ff12c443e5466581a095ad151ce14bc62 (diff) | |
download | gdb-1f09ec811eec9ea3a5ef4276f8e94ea6c5e85ef2.zip gdb-1f09ec811eec9ea3a5ef4276f8e94ea6c5e85ef2.tar.gz gdb-1f09ec811eec9ea3a5ef4276f8e94ea6c5e85ef2.tar.bz2 |
Split out eval_op_complement
This splits UNOP_COMPLEMENT into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_complement): New function.
(evaluate_subexp_standard): Use it.
Diffstat (limited to 'gdb')
-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 b27ed9c..9d39281 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_complement): New function. + (evaluate_subexp_standard): Use it. + +2021-03-08 Tom Tromey <tom@tromey.com> + * eval.c (eval_op_neg): New function. (evaluate_subexp_standard): Use it. @@ -1787,6 +1787,24 @@ eval_op_neg (struct type *expect_type, struct expression *exp, } } +/* A helper function for UNOP_COMPLEMENT. */ + +static struct value * +eval_op_complement (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 (UNOP_COMPLEMENT, arg1)) + return value_x_unop (arg1, UNOP_COMPLEMENT, noside); + else + { + unop_promote (exp->language_defn, exp->gdbarch, &arg1); + return value_complement (arg1); + } +} + struct value * evaluate_subexp_standard (struct type *expect_type, struct expression *exp, int *pos, @@ -2646,15 +2664,7 @@ evaluate_subexp_standard (struct type *expect_type, /* C++: check for and handle destructor names. */ arg1 = evaluate_subexp (nullptr, exp, pos, noside); - if (noside == EVAL_SKIP) - return eval_skip_value (exp); - if (unop_user_defined_p (UNOP_COMPLEMENT, arg1)) - return value_x_unop (arg1, UNOP_COMPLEMENT, noside); - else - { - unop_promote (exp->language_defn, exp->gdbarch, &arg1); - return value_complement (arg1); - } + return eval_op_complement (expect_type, exp, noside, op, arg1); case UNOP_LOGICAL_NOT: arg1 = evaluate_subexp (nullptr, exp, pos, noside); |