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:17 -0700 |
commit | 9186293fd6bd4c3a4855c7aa62ad2ab1734077e6 (patch) | |
tree | 96b8629642559901874a0b406eb729307c82a379 /gdb/expop.h | |
parent | 1594e0bb3d35b05aa53519f08021fb15bf26f1dc (diff) | |
download | gdb-9186293fd6bd4c3a4855c7aa62ad2ab1734077e6.zip gdb-9186293fd6bd4c3a4855c7aa62ad2ab1734077e6.tar.gz gdb-9186293fd6bd4c3a4855c7aa62ad2ab1734077e6.tar.bz2 |
Introduce ternop_cond_operation
This adds class ternop_cond_operation, which implements TERNOP_COND.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* expop.h (class ternop_cond_operation): New.
* ax-gdb.c (ternop_cond_operation::do_generate_ax): New method.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r-- | gdb/expop.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h index 436a011..0f5b504 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -734,6 +734,37 @@ public: { return TERNOP_SLICE; } }; +class ternop_cond_operation + : public maybe_constant_operation<operation_up, 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 + { + struct value *val + = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); + + if (value_logical_not (val)) + return std::get<2> (m_storage)->evaluate (nullptr, exp, noside); + return std::get<1> (m_storage)->evaluate (nullptr, exp, noside); + } + + enum exp_opcode opcode () const override + { return TERNOP_COND; } + +protected: + + void do_generate_ax (struct expression *exp, + struct agent_expr *ax, + struct axs_value *value, + struct type *cast_type) + override; +}; + } /* namespace expr */ #endif /* EXPOP_H */ |