aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:18 -0700
commit07f724a8c604cdfa1639f757e577dd6eb9caed25 (patch)
treef4838548b2cdc00fbc2c4353c3f92620958539e1
parentab0609be836ef93f6ed4c84484ec1059cfecebf4 (diff)
downloadgdb-07f724a8c604cdfa1639f757e577dd6eb9caed25.zip
gdb-07f724a8c604cdfa1639f757e577dd6eb9caed25.tar.gz
gdb-07f724a8c604cdfa1639f757e577dd6eb9caed25.tar.bz2
Introduce structop_member_operation and structop_mptr_operation
This adds class structop_member_operation and structop_mptr_operation, which implement STRUCTOP_MEMBER and STRUCTOP_MPTR. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class structop_member_operation) (class structop_mptr_operation): New. * eval.c (eval_op_member): No longer static.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/eval.c2
-rw-r--r--gdb/expop.h48
3 files changed, 55 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0a985a2..42a8e1c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * expop.h (class structop_member_operation)
+ (class structop_mptr_operation): New.
+ * eval.c (eval_op_member): No longer static.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* expop.h (class structop_ptr_operation): New.
* eval.c (eval_op_structop_ptr): No longer static. Remove "op"
parameter.
diff --git a/gdb/eval.c b/gdb/eval.c
index 1962777..de78631 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1417,7 +1417,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp,
/* A helper function for STRUCTOP_MEMBER. */
-static struct value *
+struct value *
eval_op_member (struct type *expect_type, struct expression *exp,
enum noside noside,
struct value *arg1, struct value *arg2)
diff --git a/gdb/expop.h b/gdb/expop.h
index 38f3ffb..cbd4d62 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -80,6 +80,10 @@ extern struct value *eval_op_structop_ptr (struct type *expect_type,
enum noside noside,
struct value *arg1,
const char *string);
+extern struct value *eval_op_member (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ struct value *arg1, struct value *arg2);
namespace expr
{
@@ -887,6 +891,50 @@ protected:
}
};
+class structop_member_operation
+ : public tuple_holding_operation<operation_up, operation_up>
+{
+public:
+
+ using tuple_holding_operation::tuple_holding_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *lhs
+ = std::get<0> (m_storage)->evaluate_for_address (exp, noside);
+ value *rhs
+ = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ return eval_op_member (expect_type, exp, noside, lhs, rhs);
+ }
+
+ enum exp_opcode opcode () const override
+ { return STRUCTOP_MEMBER; }
+};
+
+class structop_mptr_operation
+ : public tuple_holding_operation<operation_up, operation_up>
+{
+public:
+
+ using tuple_holding_operation::tuple_holding_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *lhs
+ = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *rhs
+ = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ return eval_op_member (expect_type, exp, noside, lhs, rhs);
+ }
+
+ enum exp_opcode opcode () const override
+ { return STRUCTOP_MPTR; }
+};
+
} /* namespace expr */
#endif /* EXPOP_H */