Introduce objc_msgcall_operation

This adds class objc_msgcall_operation, which implements
OP_OBJC_MSGCALL.

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

	* eval.c (objc_msgcall_operation::evaluate): New method.
	* c-exp.h (class objc_msgcall_operation): New.
This commit is contained in:
Tom Tromey
2021-03-08 07:27:57 -07:00
parent e82a5afced
commit 085734dd95
3 changed files with 61 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (objc_msgcall_operation::evaluate): New method.
* c-exp.h (class objc_msgcall_operation): New.
2021-03-08 Tom Tromey <tom@tromey.com>
* expop.h (class var_value_operation): New.

View File

@@ -88,6 +88,23 @@ public:
{ return OP_OBJC_SELECTOR; }
};
/* An Objective C message call. */
class objc_msgcall_operation
: public tuple_holding_operation<CORE_ADDR, operation_up,
std::vector<operation_up>>
{
public:
using tuple_holding_operation::tuple_holding_operation;
value *evaluate (struct type *expect_type,
struct expression *exp,
enum noside noside) override;
enum exp_opcode opcode () const override
{ return OP_OBJC_MSGCALL; }
};
}/* namespace expr */
#endif /* C_EXP_H */

View File

@@ -2436,6 +2436,45 @@ eval_multi_subscript (struct type *expect_type, struct expression *exp,
return (arg1);
}
namespace expr
{
value *
objc_msgcall_operation::evaluate (struct type *expect_type,
struct expression *exp,
enum noside noside)
{
enum noside sub_no_side = EVAL_NORMAL;
struct type *selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
sub_no_side = EVAL_NORMAL;
else
sub_no_side = noside;
value *target
= std::get<1> (m_storage)->evaluate (selector_type, exp, sub_no_side);
if (value_as_long (target) == 0)
sub_no_side = EVAL_AVOID_SIDE_EFFECTS;
else
sub_no_side = noside;
std::vector<operation_up> &args = std::get<2> (m_storage);
value **argvec = XALLOCAVEC (struct value *, args.size () + 3);
argvec[0] = nullptr;
argvec[1] = nullptr;
for (int i = 0; i < args.size (); ++i)
argvec[i + 2] = args[i]->evaluate_with_coercion (exp, sub_no_side);
argvec[args.size () + 2] = nullptr;
return eval_op_objc_msgcall (expect_type, exp, noside, std::
get<0> (m_storage), target,
gdb::make_array_view (argvec,
args.size () + 3));
}
}
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,