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

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

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

gdb/ChangeLog
gdb/eval.c

index da07cefca5cfe201ef4b07b50aa4aaa910f7c895..d250cf539ededed719ec622e9731968c85fa5e6d 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_less): New function.
+       (evaluate_subexp_standard): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c (eval_op_notequal): New function.
index aee3741c8b9e6b693b3bacd6e831869b3368a377..8e8846d2337caad4a61329d46f5de74436154022 100644 (file)
@@ -1637,6 +1637,29 @@ eval_op_notequal (struct type *expect_type, struct expression *exp,
     }
 }
 
+/* A helper function for BINOP_LESS.  */
+
+static struct value *
+eval_op_less (struct type *expect_type, struct expression *exp,
+             enum noside noside, enum exp_opcode op,
+             struct value *arg1, struct value *arg2)
+{
+  if (noside == EVAL_SKIP)
+    return eval_skip_value (exp);
+  if (binop_user_defined_p (op, arg1, arg2))
+    {
+      return value_x_binop (arg1, arg2, op, OP_NULL, noside);
+    }
+  else
+    {
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+      int tem = value_less (arg1, arg2);
+      struct type *type = language_bool_type (exp->language_defn,
+                                             exp->gdbarch);
+      return value_from_longest (type, (LONGEST) tem);
+    }
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
                          struct expression *exp, int *pos,
@@ -2458,19 +2481,7 @@ evaluate_subexp_standard (struct type *expect_type,
     case BINOP_LESS:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);
       arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
-      if (noside == EVAL_SKIP)
-       return eval_skip_value (exp);
-      if (binop_user_defined_p (op, arg1, arg2))
-       {
-         return value_x_binop (arg1, arg2, op, OP_NULL, noside);
-       }
-      else
-       {
-         binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
-         tem = value_less (arg1, arg2);
-         type = language_bool_type (exp->language_defn, exp->gdbarch);
-         return value_from_longest (type, (LONGEST) tem);
-       }
+      return eval_op_less (expect_type, exp, noside, op, arg1, arg2);
 
     case BINOP_GTR:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);
This page took 0.029269 seconds and 4 git commands to generate.