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:27 -0700 |
commit | 9db6b6ddbd3a384d3a80bfee3e3a5c5a40fd43d0 (patch) | |
tree | 7982ddac368014b043cca1c4d62a8827ab1063ee /gdb/rust-exp.h | |
parent | 6ce1ad679a7aa1f82e483451669d5d77bfc1b8fb (diff) | |
download | gdb-9db6b6ddbd3a384d3a80bfee3e3a5c5a40fd43d0.zip gdb-9db6b6ddbd3a384d3a80bfee3e3a5c5a40fd43d0.tar.gz gdb-9db6b6ddbd3a384d3a80bfee3e3a5c5a40fd43d0.tar.bz2 |
Introduce rust_range_operation
This adds class rust_range_operation, which implements OP_RANGE.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_range): No longer static.
* rust-exp.h (class rust_range_operation): New.
Diffstat (limited to 'gdb/rust-exp.h')
-rw-r--r-- | gdb/rust-exp.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gdb/rust-exp.h b/gdb/rust-exp.h index 7571009..263d41a 100644 --- a/gdb/rust-exp.h +++ b/gdb/rust-exp.h @@ -42,6 +42,10 @@ extern struct value *rust_subscript (struct type *expect_type, struct expression *exp, enum noside noside, bool for_addr, struct value *lhs, struct value *rhs); +extern struct value *rust_range (struct type *expect_type, + struct expression *exp, + enum noside noside, enum range_flag kind, + struct value *low, struct value *high); namespace expr { @@ -124,6 +128,32 @@ public: { return UNOP_ADDR; } }; +/* The Rust range operators. */ +class rust_range_operation + : public tuple_holding_operation<enum range_flag, operation_up, operation_up> +{ +public: + + using tuple_holding_operation::tuple_holding_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + auto kind = std::get<0> (m_storage); + value *low = nullptr; + if (std::get<1> (m_storage) != nullptr) + low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); + value *high = nullptr; + if (std::get<2> (m_storage) != nullptr) + high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside); + return rust_range (expect_type, exp, noside, kind, low, high); + } + + enum exp_opcode opcode () const override + { return OP_RANGE; } +}; + } /* namespace expr */ #endif /* RUST_EXP_H */ |