[091/203] Introduce objc_selector_operation

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

Commit Message

Tom Tromey Jan. 1, 2021, 9:45 p.m.
This adds class objc_selector_operation, which implements
OP_OBJC_SELECTOR.

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

	* eval.c (eval_op_objc_selector): No longer static.
	* c-exp.h (class objc_selector_operation): New.
---
 gdb/ChangeLog |  5 +++++
 gdb/c-exp.h   | 25 +++++++++++++++++++++++++
 gdb/eval.c    |  2 +-
 3 files changed, 31 insertions(+), 1 deletion(-)

-- 
2.26.2

Patch

diff --git a/gdb/c-exp.h b/gdb/c-exp.h
index a7b11b5a25d..dcb4557b2d5 100644
--- a/gdb/c-exp.h
+++ b/gdb/c-exp.h
@@ -23,6 +23,10 @@ 
 #include "expop.h"
 #include "objc-lang.h"
 
+extern struct value *eval_op_objc_selector (struct type *expect_type,
+					    struct expression *exp,
+					    enum noside noside,
+					    const char *sel);
 namespace expr
 {
 
@@ -63,6 +67,27 @@  class objc_nsstring_operation
   { return OP_OBJC_NSSTRING; }
 };
 
+class objc_selector_operation
+  : public tuple_holding_operation<std::string>
+{
+public:
+
+  using tuple_holding_operation::tuple_holding_operation;
+
+  value *evaluate (struct type *expect_type,
+		   struct expression *exp,
+		   enum noside noside) override
+  {
+    if (noside == EVAL_SKIP)
+      return eval_skip_value (exp);
+    return eval_op_objc_selector (expect_type, exp, noside,
+				  std::get<0> (m_storage).c_str ());
+  }
+
+  enum exp_opcode opcode () const override
+  { return OP_OBJC_SELECTOR; }
+};
+
 }/* namespace expr */
 
 #endif /* C_EXP_H */
diff --git a/gdb/eval.c b/gdb/eval.c
index 0b709ce17a2..217e37b8530 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1285,7 +1285,7 @@  eval_op_string (struct type *expect_type, struct expression *exp,
   return value_string (string, len, type);
 }
 
-static struct value *
+struct value *
 eval_op_objc_selector (struct type *expect_type, struct expression *exp,
 		       enum noside noside,
 		       const char *sel)