aboutsummaryrefslogtreecommitdiff
path: root/gdb/expop.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:22 -0700
commit929f3aa7425dde2626bdf5b23277aee62ec75129 (patch)
treef6c00a8852886827bfa4f493dcfc1179dc0c9558 /gdb/expop.h
parent0af8829eb1aea4fa72f1a0a2c7c749c411c8ed41 (diff)
downloadgdb-929f3aa7425dde2626bdf5b23277aee62ec75129.zip
gdb-929f3aa7425dde2626bdf5b23277aee62ec75129.tar.gz
gdb-929f3aa7425dde2626bdf5b23277aee62ec75129.tar.bz2
Introduce typeid_operation
This adds class typeid_operation, which implements OP_TYPEID. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class typeid_operation): New.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r--gdb/expop.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 1831378..804f516 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1517,6 +1517,35 @@ public:
{ return OP_DECLTYPE; }
};
+/* Implement 'typeid'. */
+class typeid_operation
+ : public tuple_holding_operation<operation_up>
+{
+public:
+
+ using tuple_holding_operation::tuple_holding_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ enum exp_opcode sub_op = std::get<0> (m_storage)->opcode ();
+ enum noside sub_noside
+ = ((sub_op == OP_TYPE || sub_op == OP_DECLTYPE || sub_op == OP_TYPEOF)
+ ? EVAL_AVOID_SIDE_EFFECTS
+ : noside);
+
+ value *result = std::get<0> (m_storage)->evaluate (nullptr, exp,
+ sub_noside);
+ if (noside != EVAL_NORMAL)
+ return allocate_value (cplus_typeid_type (exp->gdbarch));
+ return cplus_typeid (result);
+ }
+
+ enum exp_opcode opcode () const override
+ { return OP_TYPEID; }
+};
+
} /* namespace expr */
#endif /* EXPOP_H */