#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);
extern struct value *opencl_value_cast (struct type *type, struct value *arg);
extern struct value *eval_opencl_assign (struct type *expect_type,
struct expression *exp,
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- const std::string &str = std::get<0> (m_storage);
- return value_nsstring (exp->gdbarch, str.c_str (), str.size () + 1);
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return OP_OBJC_NSSTRING; }
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- return eval_op_objc_selector (expect_type, exp, noside,
- std::get<0> (m_storage).c_str ());
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return OP_OBJC_SELECTOR; }
return value_slice (array, lowbound, upperbound - lowbound + 1);
}
-} /* namespace expr */
-
-/* Helper function that implements the body of OP_OBJC_SELECTOR. */
-
struct value *
-eval_op_objc_selector (struct type *expect_type, struct expression *exp,
- enum noside noside,
- const char *sel)
+objc_selector_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ const char *sel = std::get<0> (m_storage).c_str ();
struct type *selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
return value_from_longest (selector_type,
lookup_child_selector (exp->gdbarch, sel));
}
+} /* namespace expr */
+
/* A helper function for STRUCTOP_STRUCT. */
struct value *
return value_as_long (call_function_by_hand (function, NULL, selstring));
}
+namespace expr
+{
+
struct value *
-value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
+objc_nsstring_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ const std::string &str = std::get<0> (m_storage);
+ struct gdbarch *gdbarch = exp->gdbarch;
+
struct type *char_type = builtin_type (gdbarch)->builtin_char;
struct value *stringValue[3];
struct value *function, *nsstringValue;
if (!target_has_execution ())
return 0; /* Can't call into inferior to create NSString. */
- stringValue[2] = value_string(ptr, len, char_type);
- stringValue[2] = value_coerce_array(stringValue[2]);
+ stringValue[2] = value_string (str.c_str (), str.size () + 1, char_type);
+ stringValue[2] = value_coerce_array (stringValue[2]);
/* _NSNewStringFromCString replaces "istr" after Lantern2A. */
if (lookup_minimal_symbol (current_program_space,
"_NSNewStringFromCString").minsym != nullptr)
return nsstringValue;
}
+} /* namespace expr */
+
/* Class representing the Objective-C language. */
class objc_language : public language_defn
extern const char *find_imps (const char *method,
std::vector<const char *> *symbol_names);
-extern struct value *value_nsstring (struct gdbarch *gdbarch,
- const char *ptr, int len);
-
/* for parsing Objective C */
extern void start_msglist (void);
extern void add_msglist (struct stoken *str, int addcolon);