From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Introduce type_instance_operation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44b675c89b9d4e22ab60f51416b47634df2a3774;p=binutils-gdb.git Introduce type_instance_operation This adds class type_instance_operation, which implements TYPE_INSTANCE. gdb/ChangeLog 2021-03-08 Tom Tromey * expop.h (class type_instance_operation): New. * eval.c (type_instance_operation::evaluate): New method. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e9ba10d0899..58ada4e3282 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * expop.h (class type_instance_operation): New. + * eval.c (type_instance_operation::evaluate): New method. + 2021-03-08 Tom Tromey * expop.h (class op_this_operation): New. diff --git a/gdb/eval.c b/gdb/eval.c index 2781e1d993e..f0bad85e951 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -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 &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 * diff --git a/gdb/expop.h b/gdb/expop.h index 7c0768ca6c1..b196de52d0b 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1740,6 +1740,23 @@ protected: override; }; +/* Implement the "type instance" operation. */ +class type_instance_operation + : public tuple_holding_operation, + 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 */