Implement Ada equality operators
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:32 +0000 (07:28 -0700)
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.

gdb/ChangeLog
gdb/ada-exp.h
gdb/ada-lang.c

index 9080b8a72a05f2c7bb212e611f1bfe16795de78e..f34ce4b06c76a1e5687149e32911cf863a1ebba2 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * ada-lang.c (ada_mult_binop): No longer static.
index da52d5cb2998c0b756f90736a211a2d4aab3b539..3091323c89e3d3acd57dda45f0252e56802c2f4e 100644 (file)
@@ -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 */
index 45f5592274d3597df50d9be0c4070e89ed67abe6..7ae3343a63078421c8f5fc2eddead7e438642610 100644 (file)
@@ -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,