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:07 -0700
commit6fa9831f89a3c788f4ea1ab6d1e2543dabfc0f8e (patch)
treefa687113914d5070dd7a5b8c37a2cc3bb64c7dc6 /gdb
parentd123f9e4a3936aeff524322e052ce1fd9ff1f19f (diff)
downloadgdb-6fa9831f89a3c788f4ea1ab6d1e2543dabfc0f8e.zip
gdb-6fa9831f89a3c788f4ea1ab6d1e2543dabfc0f8e.tar.gz
gdb-6fa9831f89a3c788f4ea1ab6d1e2543dabfc0f8e.tar.bz2
Split out eval_op_rust_complement
This splits UNOP_COMPLEMENT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * rust-lang.c (eval_op_rust_complement): New function. (rust_evaluate_subexp): Use it.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/rust-lang.c28
2 files changed, 23 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 22c017f..7973492 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * rust-lang.c (eval_op_rust_complement): New function.
+ (rust_evaluate_subexp): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* rust-lang.c (eval_op_rust_ind): New function.
(rust_evaluate_subexp): Use it.
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 173b418..449f14c 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1337,6 +1337,23 @@ eval_op_rust_ind (struct type *expect_type, struct expression *exp,
return value_ind (value);
}
+/* A helper function for UNOP_COMPLEMENT. */
+
+static struct value *
+eval_op_rust_complement (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *value)
+{
+ if (noside == EVAL_SKIP)
+ {
+ /* Preserving the type is enough. */
+ return value;
+ }
+ if (value_type (value)->code () == TYPE_CODE_BOOL)
+ return value_from_longest (value_type (value), value_logical_not (value));
+ return value_complement (value);
+}
+
/* evaluate_exp implementation for Rust. */
static struct value *
@@ -1367,16 +1384,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp,
++*pos;
value = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
- {
- /* Preserving the type is enough. */
- return value;
- }
- if (value_type (value)->code () == TYPE_CODE_BOOL)
- result = value_from_longest (value_type (value),
- value_logical_not (value));
- else
- result = value_complement (value);
+ result = eval_op_rust_complement (expect_type, exp, noside, value);
}
break;