[008/203] Split out eval_op_concat

Message ID 20210101214723.1784144-9-tom@tromey.com
State Superseded
Headers show
Series
  • Refactor expressions
Related show

Commit Message

Tom Tromey Jan. 1, 2021, 9:44 p.m.
This splits BINOP_CONCAT into a new function for future use.

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

	* eval.c (eval_op_concat): New function.
	(evaluate_subexp_standard): Use it.
---
 gdb/ChangeLog |  5 +++++
 gdb/eval.c    | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

-- 
2.26.2

Patch

diff --git a/gdb/eval.c b/gdb/eval.c
index ebab2c8fdbb..b00139ca36f 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1296,6 +1296,19 @@  eval_op_objc_selector (struct type *expect_type, struct expression *exp,
 			     lookup_child_selector (exp->gdbarch, sel));
 }
 
+static struct value *
+eval_op_concat (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
+    return value_concat (arg1, arg2);
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
 			  struct expression *exp, int *pos,
@@ -2013,12 +2026,7 @@  evaluate_subexp_standard (struct type *expect_type,
     case BINOP_CONCAT:
       arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
       arg2 = evaluate_subexp_with_coercion (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
-	return value_concat (arg1, arg2);
+      return eval_op_concat (expect_type, exp, noside, op, arg1, arg2);
 
     case BINOP_ASSIGN:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);