Implement some Ada OP_ATR_ operations
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:33 +0000 (07:28 -0700)
This implements a few Ada OP_ATR_ operations.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* ada-lang.c (ada_unop_atr_operation::evaluate): New method.
* ada-exp.h (class ada_unop_atr_operation): New.

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

index c414df1395ec3622278d5089c3a4dd5e66f4c843..ee370533123b39ae975b50a52025b93aab7bbca8 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * ada-lang.c (ada_unop_atr_operation::evaluate): New method.
+       * ada-exp.h (class ada_unop_atr_operation): New.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * ada-lang.c (ada_binop_in_bounds): No longer static.
index 4c30734171ff8ea04b714db1dfabc3bfefdabadf..e92ae469b63073584eabef2cd689765bb76f71af 100644 (file)
@@ -267,6 +267,22 @@ public:
   { return BINOP_IN_BOUNDS; }
 };
 
+/* Implement several unary Ada OP_ATR_* operations.  */
+class ada_unop_atr_operation
+  : public maybe_constant_operation<operation_up, enum exp_opcode, int>
+{
+public:
+
+  using maybe_constant_operation::maybe_constant_operation;
+
+  value *evaluate (struct type *expect_type,
+                  struct expression *exp,
+                  enum noside noside) override;
+
+  enum exp_opcode opcode () const override
+  { return std::get<1> (m_storage); }
+};
+
 } /* namespace expr */
 
 #endif /* ADA_EXP_H */
index 24241676737537bd090504f4985653a4889d4b58..9103ecedecb9f66e8ab0aca24c5bd55c080b38a2 100644 (file)
@@ -10532,6 +10532,27 @@ ada_binop_addsub_operation::evaluate (struct type *expect_type,
   return arg1;
 }
 
+value *
+ada_unop_atr_operation::evaluate (struct type *expect_type,
+                                 struct expression *exp,
+                                 enum noside noside)
+{
+  struct type *type_arg = nullptr;
+  value *val = nullptr;
+
+  if (std::get<0> (m_storage)->opcode () == OP_TYPE)
+    {
+      value *tem = std::get<0> (m_storage)->evaluate (nullptr, exp,
+                                                     EVAL_AVOID_SIDE_EFFECTS);
+      type_arg = value_type (tem);
+    }
+  else
+    val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+
+  return ada_unop_atr (exp, noside, std::get<1> (m_storage),
+                      val, type_arg, std::get<2> (m_storage));
+}
+
 }
 
 /* Implement the evaluate_exp routine in the exp_descriptor structure