[PATCH 139/203] Introduce ada_unop_range_operation

Tom Tromey
2021-01-01T21:49:09Z

This adds class ada_unop_range_operation, which implements
UNOP_IN_RANGE.

gdb/ChangeLog
2021-01-01 Tom Tromey <tom@tromey.com>

* ada-lang.c (ada_unop_in_range): No longer static.
* ada-exp.h (class ada_unop_range_operation): New.
---
gdb/ChangeLog | 5 +++++
gdb/ada-exp.h | 25 +++++++++++++++++++++++++
gdb/ada-lang.c | 2 +-
3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 8f114b3a145..de69210bd2a 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -38,6 +38,10 @@ extern struct value *ada_abs (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1);
+extern struct value *ada_unop_in_range (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1, struct type *type);

namespace expr
{
@@ -109,6 +113,27 @@ using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;

+/* The in-range operation, given a type. */
+class ada_unop_range_operation
+ : public tuple_holding_operation<operation_up, struct type *>
+{
+public:
+
+ using tuple_holding_operation::tuple_holding_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 ada_unop_in_range (expect_type, exp, noside, UNOP_IN_RANGE,
+ val, std::get<1> (m_storage));
+ }
+
+ enum exp_opcode opcode () const override
+ { return UNOP_IN_RANGE; }
+};
+
} /* namespace expr */

#endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 32a64916d0e..e2c9de69b65 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10129,7 +10129,7 @@ ada_unop_neg (struct type *expect_type,

/* A helper function for UNOP_IN_RANGE. */

-static value *
+value *
ada_unop_in_range (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
--
2.26.2