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
commit85d23bda83101f4c278337428dc15eda0eecc95b (patch)
tree919485b3aaf4a2eaade8a265e9fea942d753b3e3 /gdb/expop.h
parent14aff815df1efbbc573df75b7fc65017e9399c84 (diff)
downloadgdb-85d23bda83101f4c278337428dc15eda0eecc95b.zip
gdb-85d23bda83101f4c278337428dc15eda0eecc95b.tar.gz
gdb-85d23bda83101f4c278337428dc15eda0eecc95b.tar.bz2
Introduce unop_sizeof_operation
This adds class unop_sizeof_operation, which implements UNOP_SIZEOF. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class unop_sizeof_operation): New. * ax-gdb.c (unop_sizeof_operation::do_generate_ax): New method.
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 a09be96..8cb7281 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1582,6 +1582,35 @@ protected:
}
};
+/* Implement 'sizeof'. */
+class unop_sizeof_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);
+ return std::get<0> (m_storage)->evaluate_for_sizeof (exp, noside);
+ }
+
+ enum exp_opcode opcode () const override
+ { return UNOP_SIZEOF; }
+
+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 */