Introduce opencl_structop_operation

This adds class opencl_structop_operation, which implements
STRUCTOP_STRUCT for OpenCL.

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

	* opencl-lang.c (opencl_structop_operation::evaluate): New
	method.
	* c-exp.h (class opencl_structop_operation): New.
This commit is contained in:
Tom Tromey 2021-03-08 07:27:57 -07:00
parent 2492ba36f6
commit 33b7921462
3 changed files with 50 additions and 0 deletions

View file

@ -958,6 +958,34 @@ Cannot perform conditional operation on vectors with different sizes"));
return evaluate_subexp_c (expect_type, exp, pos, noside);
}
namespace expr
{
value *
opencl_structop_operation::evaluate (struct type *expect_type,
struct expression *exp,
enum noside noside)
{
value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
struct type *type1 = check_typedef (value_type (arg1));
if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ())
return opencl_component_ref (exp, arg1, std::get<1> (m_storage).c_str (),
noside);
else
{
struct value *v = value_struct_elt (&arg1, NULL,
std::get<1> (m_storage).c_str (),
NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
v = value_zero (value_type (v), VALUE_LVAL (v));
return v;
}
}
} /* namespace expr */
const struct exp_descriptor exp_descriptor_opencl =
{
print_subexp_standard,