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:28 -0700
commit95d49dfbba00253382d0f7ad0ea2052b2b7bc445 (patch)
tree1df86c9bb0993124254372ded67072501e904c63
parent7c15d377deefea39bac6ce710d803cc23cbe19c9 (diff)
downloadbinutils-95d49dfbba00253382d0f7ad0ea2052b2b7bc445.zip
binutils-95d49dfbba00253382d0f7ad0ea2052b2b7bc445.tar.gz
binutils-95d49dfbba00253382d0f7ad0ea2052b2b7bc445.tar.bz2
Introduce ada_unop_range_operation
This adds class ada_unop_range_operation, which implements UNOP_IN_RANGE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-lang.c (ada_unop_in_range): No longer static. * ada-exp.h (class ada_unop_range_operation): New.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-exp.h25
-rw-r--r--gdb/ada-lang.c2
3 files changed, 31 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 08a9627..1969ec5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * ada-lang.c (ada_unop_in_range): No longer static.
+ * ada-exp.h (class ada_unop_range_operation): New.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (ada_unop_neg, ada_atr_tag, ada_atr_size, ada_abs):
No longer static.
* ada-exp.h (ada_neg_operation, ada_atr_tag_operation)
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 8f114b3..de69210 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 ed691f5..0b4ef8b 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9978,7 +9978,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,