[v3,083/206] Introduce last_operation

Message ID 20210220201609.838264-84-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 last_operation, which implements OP_LAST.

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

	* expop.h (class last_operation): New.
---
 gdb/ChangeLog |  4 ++++
 gdb/expop.h   | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

-- 
2.26.2

Patch

diff --git a/gdb/expop.h b/gdb/expop.h
index 8329babd09b..73b66bf154b 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -579,6 +579,24 @@  class func_static_var_operation
   { return OP_FUNC_STATIC_VAR; }
 };
 
+class last_operation
+  : public tuple_holding_operation<int>
+{
+public:
+
+  using tuple_holding_operation::tuple_holding_operation;
+
+  value *evaluate (struct type *expect_type,
+		   struct expression *exp,
+		   enum noside noside) override
+  {
+    return access_value_history (std::get<0> (m_storage));
+  }
+
+  enum exp_opcode opcode () const override
+  { return OP_LAST; }
+};
+
 } /* namespace expr */
 
 #endif /* EXPOP_H */