Introduce func_static_var_operation
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:15 +0000 (07:28 -0700)
This adds class func_static_var_operation, which implements
OP_FUNC_STATIC_VAR.

gdb/ChangeLog
2021-03-08  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
gdb/eval.c
gdb/expop.h

index f35cb4babab372a1487865bf4e09aa9ef1ec86fb..6e9779e935e3da1db2487ad648204526c29479eb 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * expop.h (class func_static_var_operation): New.
+       * eval.c (eval_op_func_static_var): No longer static.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * expop.h (class var_entry_value_operation): New.
index 7645291a8017dc72811d81b7074482cc2e98e962..56010ee22e931325f6f4d5aa02fabd5d91edc22c 100644 (file)
@@ -1237,7 +1237,7 @@ eval_op_var_msym_value (struct type *expect_type, struct expression *exp,
 
 /* Helper function that implements the body of OP_FUNC_STATIC_VAR.  */
 
-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)
index 033ea0b1f0c89b11ddb606656d78426b5051fb2e..8329babd09bd1db4b6502dd91a53c3d78f82b07d 100644 (file)
@@ -54,6 +54,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
 {
@@ -555,6 +559,26 @@ public:
   { 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 */