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:21 -0700 |
commit | 4efc574cb9e721c1e29425146d6f51424a730729 (patch) | |
tree | 398e9538f8c0bb7f9f53f5f92f7fcf7830eb8127 /gdb/expop.h | |
parent | 5b5f5140e1c37f899bf426ea7031548f4bd7e4ca (diff) | |
download | fsf-binutils-gdb-4efc574cb9e721c1e29425146d6f51424a730729.zip fsf-binutils-gdb-4efc574cb9e721c1e29425146d6f51424a730729.tar.gz fsf-binutils-gdb-4efc574cb9e721c1e29425146d6f51424a730729.tar.bz2 |
Introduce typeof_operation
This adds class typeof_operation, which implements OP_TYPEOF.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* expop.h (class typeof_operation): New.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r-- | gdb/expop.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h index 8b7bfbe..da74359 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1445,6 +1445,31 @@ public: { return true; } }; +/* Implement the "typeof" operation. */ +class typeof_operation + : public maybe_constant_operation<operation_up> +{ +public: + + using maybe_constant_operation::maybe_constant_operation; + + value *evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) override + { + if (noside == EVAL_SKIP) + return eval_skip_value (exp); + else if (noside == EVAL_AVOID_SIDE_EFFECTS) + return std::get<0> (m_storage)->evaluate (nullptr, exp, + EVAL_AVOID_SIDE_EFFECTS); + else + error (_("Attempt to use a type as an expression")); + } + + enum exp_opcode opcode () const override + { return OP_TYPEOF; } +}; + } /* namespace expr */ #endif /* EXPOP_H */ |