From 6e8fb7b723199eed2706e5ef9ee464ed8b467f7f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Implement Ada equality operators This implements the Ada equal and not-equal operators. gdb/ChangeLog 2021-03-08 Tom Tromey * ada-lang.c (ada_equal_binop): No longer static. * ada-exp.h (class ada_binop_equal_operation): New. --- gdb/ChangeLog | 5 +++++ gdb/ada-exp.h | 27 +++++++++++++++++++++++++++ gdb/ada-lang.c | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9080b8a72a0..f34ce4b06c7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * ada-lang.c (ada_equal_binop): No longer static. + * ada-exp.h (class ada_binop_equal_operation): New. + 2021-03-08 Tom Tromey * ada-lang.c (ada_mult_binop): No longer static. diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index da52d5cb299..3091323c89e 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; using ada_binop_rem_operation = binop_operation; using ada_binop_mod_operation = binop_operation; +/* Implement the equal and not-equal operations for Ada. */ +class ada_binop_equal_operation + : public tuple_holding_operation +{ +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 */ diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 45f5592274d..7ae3343a630 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10134,7 +10134,7 @@ ada_mult_binop (struct type *expect_type, /* A helper function for BINOP_EQUAL and BINOP_NOTEQUAL. */ -static value * +value * ada_equal_binop (struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, -- 2.30.2