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:24 -0700
commit165a813a3abaa1f5993d754765bff2cfa9755995 (patch)
tree894fdd041f92d7cf2f04a0fe27229d50834322a3
parente5946e1604068a154a8541f88d74ad75a9e52fac (diff)
downloadgdb-165a813a3abaa1f5993d754765bff2cfa9755995.zip
gdb-165a813a3abaa1f5993d754765bff2cfa9755995.tar.gz
gdb-165a813a3abaa1f5993d754765bff2cfa9755995.tar.bz2
Introduce unop_cast_operation
This adds class unop_cast_operation, which implements UNOP_CAST. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_cast_operation): New. * ax-gdb.c (unop_cast_operation::do_generate_ax): New method.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ax-gdb.c10
-rw-r--r--gdb/expop.h28
3 files changed, 43 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c260f04..8d1bbf0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * expop.h (class unop_cast_operation): New.
+ * ax-gdb.c (unop_cast_operation::do_generate_ax): New method.
+
+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.
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index f81e5b9..84887da 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2515,6 +2515,16 @@ unop_sizeof_operation::do_generate_ax (struct expression *exp,
}
void
+unop_cast_operation::do_generate_ax (struct expression *exp,
+ struct agent_expr *ax,
+ struct axs_value *value,
+ struct type *cast_type)
+{
+ std::get<0> (m_storage)->generate_ax (exp, ax, value,
+ std::get<1> (m_storage));
+}
+
+void
unop_memval_operation::do_generate_ax (struct expression *exp,
struct agent_expr *ax,
struct axs_value *value,
diff --git a/gdb/expop.h b/gdb/expop.h
index 93af40d..abd5f64 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1836,6 +1836,34 @@ protected:
override;
};
+/* A type cast. */
+class unop_cast_operation
+ : public maybe_constant_operation<operation_up, struct type *>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ return std::get<0> (m_storage)->evaluate_for_cast (std::get<1> (m_storage),
+ exp, noside);
+ }
+
+ enum exp_opcode opcode () const override
+ { return UNOP_CAST; }
+
+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 */