aboutsummaryrefslogtreecommitdiff
path: root/gdb/expop.h
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:24 -0700
commite5946e1604068a154a8541f88d74ad75a9e52fac (patch)
tree4d2d484d5f5b3a60ae9cef1ddc63952142ee62fb /gdb/expop.h
parent40786782896deaf8f97f8dc62b85d9facb30fc8a (diff)
downloadgdb-e5946e1604068a154a8541f88d74ad75a9e52fac.zip
gdb-e5946e1604068a154a8541f88d74ad75a9e52fac.tar.gz
gdb-e5946e1604068a154a8541f88d74ad75a9e52fac.tar.bz2
Introduce assign_modify_operation
This adds class assign_modify_operation, which implements BINOP_ASSIGN_MODIFY. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class assign_modify_operation): New. * eval.c (eval_binop_assign_modify): No longer static. * ax-gdb.c (assign_modify_operation::do_generate_ax): New method.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r--gdb/expop.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 0f22365..93af40d 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -197,6 +197,12 @@ extern struct value *eval_op_memval (struct type *expect_type,
struct expression *exp,
enum noside noside,
struct value *arg1, struct type *type);
+extern struct value *eval_binop_assign_modify (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ enum exp_opcode op,
+ struct value *arg1,
+ struct value *arg2);
namespace expr
{
@@ -1800,6 +1806,36 @@ protected:
override;
};
+/* Assignment with modification, like "+=". */
+class assign_modify_operation
+ : public tuple_holding_operation<exp_opcode, 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<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *rhs = std::get<2> (m_storage)->evaluate (expect_type, exp, noside);
+ return eval_binop_assign_modify (expect_type, exp, noside,
+ std::get<0> (m_storage), lhs, rhs);
+ }
+
+ enum exp_opcode opcode () const override
+ { return BINOP_ASSIGN_MODIFY; }
+
+protected:
+
+ void do_generate_ax (struct expression *exp,
+ struct agent_expr *ax,
+ struct axs_value *value,
+ struct type *cast_type)
+ override;
+};
+
} /* namespace expr */
#endif /* EXPOP_H */