[v3,129/206] Introduce ada_ternop_range_operation

Message ID 20210220201609.838264-130-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_ternop_range_operation, which implements
TERNOP_IN_RANGE.

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

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

-- 
2.26.2

Patch

diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 9a8c8dffd5c..17a04ea15c6 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -71,6 +71,22 @@  class ada_qual_operation
   { return UNOP_QUAL; }
 };
 
+/* Ternary in-range operator.  */
+class ada_ternop_range_operation
+  : public tuple_holding_operation<operation_up, 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;
+
+  enum exp_opcode opcode () const override
+  { return TERNOP_IN_RANGE; }
+};
+
 } /* namespace expr */
 
 #endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 60eb903b2ef..7554480a1ff 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10611,6 +10611,17 @@  ada_qual_operation::evaluate (struct type *expect_type,
   return std::get<0> (m_storage)->evaluate (type, exp, noside);
 }
 
+value *
+ada_ternop_range_operation::evaluate (struct type *expect_type,
+				      struct expression *exp,
+				      enum noside noside)
+{
+  value *arg0 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+  value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+  value *arg2 = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
+  return eval_ternop_in_range (expect_type, exp, noside, arg0, arg1, arg2);
+}
+
 }
 
 /* Implement the evaluate_exp routine in the exp_descriptor structure