]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Split out ada_binop_exp
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:13 +0000 (07:28 -0700)
This splits BINOP_EXP into a new function for future use.

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

* ada-lang.c (ada_binop_exp): New function.
(ada_evaluate_subexp): Use it.

gdb/ChangeLog
gdb/ada-lang.c

index 924497ea9e59144f3c6b5a7f85a9ad74934c027f..2ac0fe7847d46550662639763a921c48b2ef4810 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * ada-lang.c (ada_binop_exp): New function.
+       (ada_evaluate_subexp): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * ada-lang.c (ada_val_atr): Rename from value_val_atr.  Change
index 910eec87a6a49aa79ee7a96c9549a2fad0fd25f4..be1827cedd81a157f0d916e76568dbf6431c547b 100644 (file)
@@ -10364,6 +10364,29 @@ ada_binop_minmax (struct type *expect_type,
     }
 }
 
+/* A helper function for BINOP_EXP.  */
+
+static struct value *
+ada_binop_exp (struct type *expect_type,
+              struct expression *exp,
+              enum noside noside, enum exp_opcode op,
+              struct value *arg1, struct value *arg2)
+{
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
+    return value_zero (value_type (arg1), not_lval);
+  else
+    {
+      /* For integer exponentiation operations,
+        only promote the first argument.  */
+      if (is_integral_type (value_type (arg2)))
+       unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+      else
+       binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+
+      return value_binop (arg1, arg2, op);
+    }
+}
+
 /* Implement the evaluate_exp routine in the exp_descriptor structure
    for the Ada language.  */
 
@@ -10926,19 +10949,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       arg2 = evaluate_subexp (nullptr, exp, pos, noside);
       if (noside == EVAL_SKIP)
        goto nosideret;
-      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
-       return value_zero (value_type (arg1), not_lval);
-      else
-       {
-         /* For integer exponentiation operations,
-            only promote the first argument.  */
-         if (is_integral_type (value_type (arg2)))
-           unop_promote (exp->language_defn, exp->gdbarch, &arg1);
-         else
-           binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
-
-         return value_binop (arg1, arg2, op);
-       }
+      return ada_binop_exp (expect_type, exp, noside, op, arg1, arg2);
 
     case UNOP_PLUS:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);