]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Split out eval_op_rust_complement
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:07 +0000 (07:28 -0700)
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.

gdb/ChangeLog
gdb/rust-lang.c

index 22c017f0ef090329e808942abd715de01c044614..797349276d0803e5d7fc6ecfe2d95ac7c554e3e0 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 173b418e2f54796bb59287df23671eb122280d6d..449f14c80f8451b11c6abb4e6b41a7912c90acbe 100644 (file)
@@ -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;