From e6985c5e45ef0693005e21a25d847baf0f93c965 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: Introduce bool_operation This adds class bool_operation, which implements OP_BOOL. gdb/ChangeLog 2021-03-08 Tom Tromey * expop.h (class bool_operation): New. --- gdb/ChangeLog | 4 ++++ gdb/expop.h | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0633260..9acaee4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2021-03-08 Tom Tromey + * expop.h (class bool_operation): New. + +2021-03-08 Tom Tromey + * expop.h (class register_operation): New. * eval.c (eval_op_register): No longer static. * ax-gdb.c (register_operation::do_generate_ax): New method. diff --git a/gdb/expop.h b/gdb/expop.h index a0e0030..44098b8 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -627,6 +627,28 @@ protected: override; }; +class bool_operation + : public tuple_holding_operation +{ +public: + + using tuple_holding_operation::tuple_holding_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + struct type *type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, std::get<0> (m_storage)); + } + + enum exp_opcode opcode () const override + { return OP_BOOL; } + + bool constant_p () const override + { return true; } +}; + } /* namespace expr */ #endif /* EXPOP_H */ -- cgit v1.1