From 5b5f5140e1c37f899bf426ea7031548f4bd7e4ca Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Introduce type_operation This adds class type_operation, which implements OP_TYPE. gdb/ChangeLog 2021-03-08 Tom Tromey * expop.h (class type_operation): New. * eval.c (eval_op_type): No longer static. --- gdb/ChangeLog | 5 +++++ gdb/eval.c | 2 +- gdb/expop.h | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index da7cd6916f..6496f982e5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * expop.h (class type_operation): New. + * eval.c (eval_op_type): No longer static. + 2021-03-08 Tom Tromey * expop.h (class unop_ind_base_operation) diff --git a/gdb/eval.c b/gdb/eval.c index 1995d39e18..f5a5a20508 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2042,7 +2042,7 @@ eval_op_postdec (struct type *expect_type, struct expression *exp, /* A helper function for OP_TYPE. */ -static struct value * +struct value * eval_op_type (struct type *expect_type, struct expression *exp, enum noside noside, struct type *type) { diff --git a/gdb/expop.h b/gdb/expop.h index 4b1d65a1be..8b7bfbe3af 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -186,6 +186,9 @@ extern struct value *eval_op_ind (struct type *expect_type, struct expression *exp, enum noside noside, struct value *arg1); +extern struct value *eval_op_type (struct type *expect_type, + struct expression *exp, + enum noside noside, struct type *type); namespace expr { @@ -1420,6 +1423,28 @@ protected: } }; +/* Implement OP_TYPE. */ +class type_operation + : public tuple_holding_operation +{ +public: + + using tuple_holding_operation::tuple_holding_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + return eval_op_type (expect_type, exp, noside, std::get<0> (m_storage)); + } + + enum exp_opcode opcode () const override + { return OP_TYPE; } + + bool constant_p () const override + { return true; } +}; + } /* namespace expr */ #endif /* EXPOP_H */ -- 2.34.1