Introduce type_instance_operation

This adds class type_instance_operation, which implements
TYPE_INSTANCE.

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

	* expop.h (class type_instance_operation): New.
	* eval.c (type_instance_operation::evaluate): New method.
This commit is contained in:
Tom Tromey 2021-03-08 07:27:57 -07:00
parent f6b4232691
commit 44b675c89b
3 changed files with 40 additions and 0 deletions

View File

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

View File

@ -636,6 +636,24 @@ fake_method::~fake_method ()
xfree (m_type.fields ());
}
namespace expr
{
value *
type_instance_operation::evaluate (struct type *expect_type,
struct expression *exp,
enum noside noside)
{
type_instance_flags flags = std::get<0> (m_storage);
std::vector<type *> &types = std::get<1> (m_storage);
fake_method fake_expect_type (flags, types.size (), types.data ());
return std::get<2> (m_storage)->evaluate (fake_expect_type.type (),
exp, noside);
}
}
/* Helper for evaluating an OP_VAR_VALUE. */
value *

View File

@ -1740,6 +1740,23 @@ protected:
override;
};
/* Implement the "type instance" operation. */
class type_instance_operation
: public tuple_holding_operation<type_instance_flags, std::vector<type *>,
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 TYPE_INSTANCE; }
};
} /* namespace expr */
#endif /* EXPOP_H */