aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-exp.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:32 -0700
commit6e8fb7b723199eed2706e5ef9ee464ed8b467f7f (patch)
tree11d3fc419f081f59781ed3fd22bdb0f9130b3d26 /gdb/ada-exp.h
parentd9e7db065eb663303dc8f0dad2c784dde9df6555 (diff)
downloadgdb-6e8fb7b723199eed2706e5ef9ee464ed8b467f7f.zip
gdb-6e8fb7b723199eed2706e5ef9ee464ed8b467f7f.tar.gz
gdb-6e8fb7b723199eed2706e5ef9ee464ed8b467f7f.tar.bz2
Implement Ada equality operators
This implements the Ada equal and not-equal operators. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-lang.c (ada_equal_binop): No longer static. * ada-exp.h (class ada_binop_equal_operation): New.
Diffstat (limited to 'gdb/ada-exp.h')
-rw-r--r--gdb/ada-exp.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index da52d5c..3091323 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -46,6 +46,10 @@ extern struct value *ada_mult_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_equal_binop (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1, struct value *arg2);
namespace expr
{
@@ -159,6 +163,29 @@ using ada_binop_div_operation = binop_operation<BINOP_DIV, ada_mult_binop>;
using ada_binop_rem_operation = binop_operation<BINOP_REM, ada_mult_binop>;
using ada_binop_mod_operation = binop_operation<BINOP_MOD, ada_mult_binop>;
+/* Implement the equal and not-equal operations for Ada. */
+class ada_binop_equal_operation
+ : public tuple_holding_operation<enum exp_opcode, operation_up, operation_up>
+{
+public:
+
+ using tuple_holding_operation::tuple_holding_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *arg2 = std::get<2> (m_storage)->evaluate (value_type (arg1),
+ exp, noside);
+ return ada_equal_binop (expect_type, exp, noside, std::get<0> (m_storage),
+ arg1, arg2);
+ }
+
+ enum exp_opcode opcode () const override
+ { return std::get<0> (m_storage); }
+};
+
} /* namespace expr */
#endif /* ADA_EXP_H */