[PATCH 081/203] Introduce func_static_var_operation

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

This adds class func_static_var_operation, which implements
OP_FUNC_STATIC_VAR.

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

* expop.h (class func_static_var_operation): New.
* eval.c (eval_op_func_static_var): No longer static.
---
gdb/ChangeLog | 5 +++++
gdb/eval.c | 2 +-
gdb/expop.h | 24 ++++++++++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 753d505b173..f28c7ace8be 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1230,7 +1230,7 @@ eval_op_var_msym_value (struct type *expect_type, struct expression *exp,
return val;
}

-static struct value *
+struct value *
eval_op_func_static_var (struct type *expect_type, struct expression *exp,
enum noside noside,
value *func, const char *var)
diff --git a/gdb/expop.h b/gdb/expop.h
index d9052887739..49f1f561019 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -53,6 +53,10 @@ extern struct value *eval_op_var_msym_value (struct type *expect_type,
extern struct value *eval_op_var_entry_value (struct type *expect_type,
struct expression *exp,
enum noside noside, symbol *sym);
+extern struct value *eval_op_func_static_var (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ value *func, const char *var);

namespace expr
{
@@ -544,6 +548,26 @@ class var_entry_value_operation
{ return OP_VAR_ENTRY_VALUE; }
};

+class func_static_var_operation
+ : public maybe_constant_operation<operation_up, std::string>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *func = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ return eval_op_func_static_var (expect_type, exp, noside, func,
+ std::get<1> (m_storage).c_str ());
+ }
+
+ enum exp_opcode opcode () const override
+ { return OP_FUNC_STATIC_VAR; }
+};
+
} /* namespace expr */

#endif /* EXPOP_H */
--
2.26.2