[PATCH 080/203] Introduce var_entry_value_operation

Tom Tromey
2021-01-01T21:48:19Z

This adds class var_entry_value_operation, which implements
OP_VAR_ENTRY_VALUE.

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

* expop.h (class var_entry_value_operation): New.
* eval.c (eval_op_var_entry_value): No longer static.
---
gdb/ChangeLog | 5 +++++
gdb/eval.c | 2 +-
gdb/expop.h | 22 ++++++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 38bbb3519ba..753d505b173 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1198,7 +1198,7 @@ eval_op_scope (struct type *expect_type, struct expression *exp,

/* Helper function that implements the body of OP_VAR_ENTRY_VALUE. */

-static struct value *
+struct value *
eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
enum noside noside, symbol *sym)
{
diff --git a/gdb/expop.h b/gdb/expop.h
index caa4d329fef..d9052887739 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -50,6 +50,9 @@ extern struct value *eval_op_var_msym_value (struct type *expect_type,
enum noside noside,
minimal_symbol *msymbol,
struct objfile *objfile);
+extern struct value *eval_op_var_entry_value (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, symbol *sym);

namespace expr
{
@@ -522,6 +525,25 @@ class var_msym_value_operation
override;
};

+class var_entry_value_operation
+ : public tuple_holding_operation<symbol *>
+{
+public:
+
+ using tuple_holding_operation::tuple_holding_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ return eval_op_var_entry_value (expect_type, exp, noside,
+ std::get<0> (m_storage));
+ }
+
+ enum exp_opcode opcode () const override
+ { return OP_VAR_ENTRY_VALUE; }
+};
+
} /* namespace expr */

#endif /* EXPOP_H */
--
2.26.2