aboutsummaryrefslogtreecommitdiff
path: root/gdb
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
commit1b1ebfab47433232078d9352d6d5ebd7baee1850 (patch)
tree9cea5003fe4d17ca0e6f884b92b0e58cae826c68 /gdb
parent039e4b76be2741e3813a691f12cc5550eb6e891d (diff)
downloadbinutils-1b1ebfab47433232078d9352d6d5ebd7baee1850.zip
binutils-1b1ebfab47433232078d9352d6d5ebd7baee1850.tar.gz
binutils-1b1ebfab47433232078d9352d6d5ebd7baee1850.tar.bz2
Introduce ada_ternop_slice
This adds class ada_ternop_slice, which implements TERNOP_SLICE for Ada. gdb/ChangeLog 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.
Diffstat (limited to 'gdb')
-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 62c71b7..57d083c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-exp.h (ada_bitwise_operation): New template class.
(ada_bitwise_and_operation, ada_bitwise_ior_operation)
(ada_bitwise_xor_operation): New typedefs.
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index d8f18b9..96e3c40 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -50,6 +50,11 @@ extern struct value *ada_equal_binop (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2);
+extern struct value *ada_ternop_slice (struct expression *exp,
+ enum noside noside,
+ struct value *array,
+ struct value *low_bound_val,
+ struct value *high_bound_val);
namespace expr
{
@@ -213,6 +218,28 @@ using ada_bitwise_and_operation = ada_bitwise_operation<BINOP_BITWISE_AND>;
using ada_bitwise_ior_operation = ada_bitwise_operation<BINOP_BITWISE_IOR>;
using ada_bitwise_xor_operation = ada_bitwise_operation<BINOP_BITWISE_XOR>;
+/* Ada array- or string-slice operation. */
+class ada_ternop_slice_operation
+ : public maybe_constant_operation<operation_up, 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 *array = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
+ return ada_ternop_slice (exp, noside, array, low, high);
+ }
+
+ enum exp_opcode opcode () const override
+ { return TERNOP_SLICE; }
+};
+
} /* namespace expr */
#endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7ae3343..3f14922 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10156,7 +10156,7 @@ ada_equal_binop (struct type *expect_type,
/* A helper function for TERNOP_SLICE. */
-static value *
+value *
ada_ternop_slice (struct expression *exp,
enum noside noside,
struct value *array, struct value *low_bound_val,