From 8cfd3e95b7624785a47e08b430d49b3d0329a0ee Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Introduce complex_operation This adds class complex_operation, which implements OP_COMPLEX. gdb/ChangeLog 2021-03-08 Tom Tromey * expop.h (class complex_operation): New. --- gdb/ChangeLog | 4 ++++ gdb/expop.h | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9297e8f6e8d..cd7ec19365f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2021-03-08 Tom Tromey + + * expop.h (class complex_operation): New. + 2021-03-08 Tom Tromey * eval.c (eval_op_objc_selector): No longer static. diff --git a/gdb/expop.h b/gdb/expop.h index 0f5b5042c10..9c63f129594 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -765,6 +765,27 @@ protected: override; }; +class complex_operation + : public maybe_constant_operation +{ +public: + + using maybe_constant_operation::maybe_constant_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + value *real = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); + value *imag = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); + return value_literal_complex (real, imag, + std::get<2> (m_storage)); + } + + enum exp_opcode opcode () const override + { return OP_COMPLEX; } +}; + } /* namespace expr */ #endif /* EXPOP_H */ -- 2.30.2