+2021-03-08 Tom Tromey <tom@tromey.com>
+
+ * rust-lang.c (eval_op_rust_ind): No longer static. Add "opcode"
+ parameter.
+ (rust_evaluate_subexp): Update.
+ * rust-exp.h (class rust_unop_ind_operation): New.
+
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-lang.c (eval_op_rust_complement, eval_op_rust_array): No
enum exp_opcode opcode,
struct value *ncopies,
struct value *elt);
+extern struct value *eval_op_rust_ind (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ enum exp_opcode opcode,
+ struct value *value);
namespace expr
{
using rust_array_operation = binop_operation<OP_RUST_ARRAY,
eval_op_rust_array>;
+/* The Rust indirection operation. */
+class rust_unop_ind_operation
+ : public unop_ind_operation
+{
+public:
+
+ using unop_ind_operation::unop_ind_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ if (noside != EVAL_NORMAL)
+ return unop_ind_operation::evaluate (expect_type, exp, noside);
+
+ value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ return eval_op_rust_ind (expect_type, exp, noside, UNOP_IND, arg1);
+ }
+};
+
} /* namespace expr */
#endif /* RUST_EXP_H */
/* A helper function for UNOP_IND. */
-static struct value *
+struct value *
eval_op_rust_ind (struct type *expect_type, struct expression *exp,
enum noside noside,
+ enum exp_opcode opcode,
struct value *value)
{
gdb_assert (noside == EVAL_NORMAL);
++*pos;
struct value *value = evaluate_subexp (expect_type, exp, pos,
noside);
- result = eval_op_rust_ind (expect_type, exp, noside, value);
+ result = eval_op_rust_ind (expect_type, exp, noside, op, value);
}
}
break;