summaryrefslogtreecommitdiff
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
commit292382f47ef08c5ec3292c612f737fe4b312c9f1 (patch)
treef2d9e9490ac38fb8609578b84036bfc7955574fa /gdb/expop.h
parent165a813a3abaa1f5993d754765bff2cfa9755995 (diff)
Introduce unop_cast_type_operation
This adds class unop_cast_type_operation, which implements UNOP_CAST_TYPE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_cast_type_operation): New. * ax-gdb.c (unop_cast_type_operation::do_generate_ax): New method.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r--gdb/expop.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index abd5f64fda..1d1ce0b664 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1864,6 +1864,37 @@ protected:
override;
};
+/* A cast, but the type comes from an expression, not a "struct
+ type". */
+class unop_cast_type_operation
+ : public maybe_constant_operation<operation_up, operation_up>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *val = std::get<0> (m_storage)->evaluate (nullptr, exp,
+ EVAL_AVOID_SIDE_EFFECTS);
+ return std::get<1> (m_storage)->evaluate_for_cast (value_type (val),
+ exp, noside);
+ }
+
+ enum exp_opcode opcode () const override
+ { return UNOP_CAST_TYPE; }
+
+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 */