Introduce objc_selector_operation
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:17 +0000 (07:28 -0700)
This adds class objc_selector_operation, which implements
OP_OBJC_SELECTOR.

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

* eval.c (eval_op_objc_selector): No longer static.
* c-exp.h (class objc_selector_operation): New.

gdb/ChangeLog
gdb/c-exp.h
gdb/eval.c

index 2b7afb1dd6886c0b334a8c1ae30733ae29426871..9297e8f6e8d26f29be071177e9fc46b75feac966 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_objc_selector): No longer static.
+       * c-exp.h (class objc_selector_operation): New.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c: Include c-exp.h.
index a7b11b5a25ddbde7f4b13a91613c6e626158352c..dcb4557b2d58fd4abdf2ee7b27e9cebb400e0929 100644 (file)
 #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 @@ public:
   { 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 */
index f1553dadbdb91f02585f969a1514fccfc950c82b..3307c74aa6343c06b516a5486c7a0c29cc1f2d86 100644 (file)
@@ -1298,7 +1298,7 @@ eval_op_string (struct type *expect_type, struct expression *exp,
 
 /* Helper function that implements the body of OP_OBJC_SELECTOR.  */
 
-static struct value *
+struct value *
 eval_op_objc_selector (struct type *expect_type, struct expression *exp,
                       enum noside noside,
                       const char *sel)