Split out eval_op_lognot
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:03 +0000 (07:28 -0700)
This splits UNOP_LOGICAL_NOT into a new function for future use.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* eval.c (eval_op_lognot): New function.
(evaluate_subexp_standard): Use it.

gdb/ChangeLog
gdb/eval.c

index 9d39281d52a6588ac62fd60cc0026afc61bcfaf3..b9a873727f71a1f42f1c41660763498abc1c3359 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_lognot): New function.
+       (evaluate_subexp_standard): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c (eval_op_complement): New function.
index f2dacee9f4dfbb462dba3e0fc7f6889dc4969d83..6d447d5f706059e4af85e5840aa8211d820e23b1 100644 (file)
@@ -1805,6 +1805,25 @@ eval_op_complement (struct type *expect_type, struct expression *exp,
     }
 }
 
+/* A helper function for UNOP_LOGICAL_NOT.  */
+
+static struct value *
+eval_op_lognot (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
+    {
+      struct type *type = language_bool_type (exp->language_defn,
+                                             exp->gdbarch);
+      return value_from_longest (type, (LONGEST) value_logical_not (arg1));
+    }
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
                          struct expression *exp, int *pos,
@@ -2668,15 +2687,7 @@ evaluate_subexp_standard (struct type *expect_type,
 
     case UNOP_LOGICAL_NOT:
       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
-       {
-         type = language_bool_type (exp->language_defn, exp->gdbarch);
-         return value_from_longest (type, (LONGEST) value_logical_not (arg1));
-       }
+      return eval_op_lognot (expect_type, exp, noside, op, arg1);
 
     case UNOP_IND:
       if (expect_type && expect_type->code () == TYPE_CODE_PTR)
This page took 0.029651 seconds and 4 git commands to generate.