From: Tom Tromey Date: Mon, 8 Mar 2021 14:27:57 +0000 (-0700) Subject: Introduce ada_bitwise_operation X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=039e4b76be2741e3813a691f12cc5550eb6e891d;p=deliverable%2Fbinutils-gdb.git Introduce ada_bitwise_operation This adds class ada_bitwise_operation, which is used to implement the Ada bitwise operators. gdb/ChangeLog 2021-03-08 Tom Tromey * ada-exp.h (ada_bitwise_operation): New template class. (ada_bitwise_and_operation, ada_bitwise_ior_operation) (ada_bitwise_xor_operation): New typedefs. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f34ce4b06c..62c71b7c53 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2021-03-08 Tom Tromey + + * ada-exp.h (ada_bitwise_operation): New template class. + (ada_bitwise_and_operation, ada_bitwise_ior_operation) + (ada_bitwise_xor_operation): New typedefs. + 2021-03-08 Tom Tromey * ada-lang.c (ada_equal_binop): No longer static. diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index 3091323c89..d8f18b9c61 100644 --- a/gdb/ada-exp.h +++ b/gdb/ada-exp.h @@ -186,6 +186,33 @@ public: { return std::get<0> (m_storage); } }; +/* Bitwise operators for Ada. */ +template +class ada_bitwise_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 *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); + value *rhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); + value *result = eval_op_binary (expect_type, exp, noside, OP, lhs, rhs); + return value_cast (value_type (lhs), result); + } + + enum exp_opcode opcode () const override + { return OP; } +}; + +using ada_bitwise_and_operation = ada_bitwise_operation; +using ada_bitwise_ior_operation = ada_bitwise_operation; +using ada_bitwise_xor_operation = ada_bitwise_operation; + } /* namespace expr */ #endif /* ADA_EXP_H */