aboutsummaryrefslogtreecommitdiff
path: root/gdb
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
commitab0609be836ef93f6ed4c84484ec1059cfecebf4 (patch)
treebde27a09f8f0591e25c5e56d60beede5bb95a5a2 /gdb
parent808b22cfd7e1afdcba7dea700a76401e2f68f2c6 (diff)
downloadgdb-ab0609be836ef93f6ed4c84484ec1059cfecebf4.zip
gdb-ab0609be836ef93f6ed4c84484ec1059cfecebf4.tar.gz
gdb-ab0609be836ef93f6ed4c84484ec1059cfecebf4.tar.bz2
Introduce structop_ptr_operation
This adds class structop_ptr_operation, which implements STRUCTOP_PTR. gdb/ChangeLog 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/eval.c10
-rw-r--r--gdb/expop.h39
3 files changed, 50 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 72c3df2..0a985a2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
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.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* expop.h (class structop_base_operation)
(class structop_operation): New.
* eval.c (eval_op_structop_struct): No longer static.
diff --git a/gdb/eval.c b/gdb/eval.c
index 74aa970..1962777 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1358,9 +1358,9 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp,
/* A helper function for STRUCTOP_PTR. */
-static struct value *
+struct value *
eval_op_structop_ptr (struct type *expect_type, struct expression *exp,
- enum noside noside, enum exp_opcode op,
+ enum noside noside,
struct value *arg1, const char *string)
{
if (noside == EVAL_SKIP)
@@ -1368,12 +1368,12 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp,
/* Check to see if operator '->' has been overloaded. If so replace
arg1 with the value returned by evaluating operator->(). */
- while (unop_user_defined_p (op, arg1))
+ while (unop_user_defined_p (STRUCTOP_PTR, arg1))
{
struct value *value = NULL;
try
{
- value = value_x_unop (arg1, op, noside);
+ value = value_x_unop (arg1, STRUCTOP_PTR, noside);
}
catch (const gdb_exception_error &except)
@@ -2759,7 +2759,7 @@ evaluate_subexp_standard (struct type *expect_type,
tem = longest_to_int (exp->elts[pc + 1].longconst);
(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- return eval_op_structop_ptr (expect_type, exp, noside, op, arg1,
+ return eval_op_structop_ptr (expect_type, exp, noside, arg1,
&exp->elts[pc + 2].string);
case STRUCTOP_MEMBER:
diff --git a/gdb/expop.h b/gdb/expop.h
index 9f1625c..38f3ffb 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -75,6 +75,11 @@ extern struct value *eval_op_structop_struct (struct type *expect_type,
enum noside noside,
struct value *arg1,
const char *string);
+extern struct value *eval_op_structop_ptr (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ struct value *arg1,
+ const char *string);
namespace expr
{
@@ -848,6 +853,40 @@ protected:
}
};
+class structop_ptr_operation
+ : public structop_base_operation
+{
+public:
+
+ using structop_base_operation::structop_base_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ return eval_op_structop_ptr (expect_type, exp, noside, val,
+ std::get<1> (m_storage).c_str ());
+ }
+
+ enum exp_opcode opcode () const override
+ { return STRUCTOP_PTR; }
+
+protected:
+
+ void do_generate_ax (struct expression *exp,
+ struct agent_expr *ax,
+ struct axs_value *value,
+ struct type *cast_type)
+ override
+ {
+ gen_expr_structop (exp, STRUCTOP_PTR,
+ std::get<0> (this->m_storage).get (),
+ std::get<1> (this->m_storage).c_str (),
+ ax, value);
+ }
+};
+
} /* namespace expr */
#endif /* EXPOP_H */