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:33 -0700
commit82c3886e24b3fed8d7e61b41f8cfdc17eedd88f8 (patch)
treec19afa5d25b2dcd274ece98ae70ef335954d6f50
parent1b1ebfab47433232078d9352d6d5ebd7baee1850 (diff)
downloadbinutils-82c3886e24b3fed8d7e61b41f8cfdc17eedd88f8.zip
binutils-82c3886e24b3fed8d7e61b41f8cfdc17eedd88f8.tar.gz
binutils-82c3886e24b3fed8d7e61b41f8cfdc17eedd88f8.tar.bz2
Introduce ada_binop_in_bounds
This adds class ada_binop_in_bounds, which implements BINOP_IN_BOUNDS. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-lang.c (ada_binop_in_bounds): No longer static. * ada-exp.h (class ada_binop_in_bounds_operation): New.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-exp.h27
-rw-r--r--gdb/ada-lang.c2
3 files changed, 33 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 57d083c..c414df1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * ada-lang.c (ada_binop_in_bounds): No longer static.
+ * ada-exp.h (class ada_binop_in_bounds_operation): New.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (ada_ternop_slice): No longer static.
* ada-exp.h (class ada_ternop_slice_operation): New.
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 96e3c40..4c30734 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -55,6 +55,11 @@ extern struct value *ada_ternop_slice (struct expression *exp,
struct value *array,
struct value *low_bound_val,
struct value *high_bound_val);
+extern struct value *ada_binop_in_bounds (struct expression *exp,
+ enum noside noside,
+ struct value *arg1,
+ struct value *arg2,
+ int n);
namespace expr
{
@@ -240,6 +245,28 @@ public:
{ return TERNOP_SLICE; }
};
+/* Implement BINOP_IN_BOUNDS for Ada. */
+class ada_binop_in_bounds_operation
+ : public maybe_constant_operation<operation_up, operation_up, int>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ return ada_binop_in_bounds (exp, noside, arg1, arg2,
+ std::get<2> (m_storage));
+ }
+
+ enum exp_opcode opcode () const override
+ { return BINOP_IN_BOUNDS; }
+};
+
} /* namespace expr */
#endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3f14922..2424167 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10237,7 +10237,7 @@ ada_ternop_slice (struct expression *exp,
/* A helper function for BINOP_IN_BOUNDS. */
-static value *
+value *
ada_binop_in_bounds (struct expression *exp, enum noside noside,
struct value *arg1, struct value *arg2, int n)
{