diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:33 -0700 |
commit | 039e4b76be2741e3813a691f12cc5550eb6e891d (patch) | |
tree | 6652439c5e8813adf251915cfbefcea387948ef2 /gdb/ada-exp.h | |
parent | 6e8fb7b723199eed2706e5ef9ee464ed8b467f7f (diff) | |
download | fsf-binutils-gdb-039e4b76be2741e3813a691f12cc5550eb6e891d.zip fsf-binutils-gdb-039e4b76be2741e3813a691f12cc5550eb6e891d.tar.gz fsf-binutils-gdb-039e4b76be2741e3813a691f12cc5550eb6e891d.tar.bz2 |
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 <tom@tromey.com>
* ada-exp.h (ada_bitwise_operation): New template class.
(ada_bitwise_and_operation, ada_bitwise_ior_operation)
(ada_bitwise_xor_operation): New typedefs.
Diffstat (limited to 'gdb/ada-exp.h')
-rw-r--r-- | gdb/ada-exp.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index 3091323..d8f18b9 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<enum exp_opcode OP> +class ada_bitwise_operation + : public maybe_constant_operation<operation_up, operation_up> +{ +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<BINOP_BITWISE_AND>; +using ada_bitwise_ior_operation = ada_bitwise_operation<BINOP_BITWISE_IOR>; +using ada_bitwise_xor_operation = ada_bitwise_operation<BINOP_BITWISE_XOR>; + } /* namespace expr */ #endif /* ADA_EXP_H */ |