[v3,128/206] Introduce ada_qual_operation

Message ID 20210220201609.838264-129-tom@tromey.com
State New
Headers show
Series
  • Refactor expressions
Related show

Commit Message

Tom Tromey Feb. 20, 2021, 8:14 p.m.
This adds class ada_qual_operation, which implements UNOP_QUAL.

gdb/ChangeLog
2021-02-20  Tom Tromey  <tom@tromey.com>

	* ada-lang.c (ada_qual_operation::evaluate): New method.
	* ada-exp.h (class ada_qual_operation): New.
---
 gdb/ChangeLog  |  5 +++++
 gdb/ada-exp.h  | 16 ++++++++++++++++
 gdb/ada-lang.c |  9 +++++++++
 3 files changed, 30 insertions(+)

-- 
2.26.2

Patch

diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 88ed0c53b46..9a8c8dffd5c 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -55,6 +55,22 @@  class ada_string_operation
 		   enum noside noside) override;
 };
 
+/* The Ada TYPE'(EXP) construct.  */
+class ada_qual_operation
+  : public tuple_holding_operation<operation_up, struct type *>
+{
+public:
+
+  using tuple_holding_operation::tuple_holding_operation;
+
+  value *evaluate (struct type *expect_type,
+		   struct expression *exp,
+		   enum noside noside) override;
+
+  enum exp_opcode opcode () const override
+  { return UNOP_QUAL; }
+};
+
 } /* namespace expr */
 
 #endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 67b2fc15eab..60eb903b2ef 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10602,6 +10602,15 @@  ada_string_operation::evaluate (struct type *expect_type,
   return result;
 }
 
+value *
+ada_qual_operation::evaluate (struct type *expect_type,
+			      struct expression *exp,
+			      enum noside noside)
+{
+  struct type *type = std::get<1> (m_storage);
+  return std::get<0> (m_storage)->evaluate (type, exp, noside);
+}
+
 }
 
 /* Implement the evaluate_exp routine in the exp_descriptor structure