Split out eval_op_plus
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:02 +0000 (07:28 -0700)
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.

gdb/ChangeLog
gdb/eval.c

index 1da2a5c7570bc0d13aa55f48e6a2ea9dbd23813d..3379b9f5a47fa8d6558803c44c0a784827938dfa 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 4ac323e4078017a2970e1257a97e09d9325af3f8..24c891d406b33241a1e394edc31502559de823dd 100644 (file)
@@ -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);
This page took 0.028286 seconds and 4 git commands to generate.