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:22 -0700 |
commit | 85d23bda83101f4c278337428dc15eda0eecc95b (patch) | |
tree | 919485b3aaf4a2eaade8a265e9fea942d753b3e3 /gdb/ax-gdb.c | |
parent | 14aff815df1efbbc573df75b7fc65017e9399c84 (diff) | |
download | binutils-85d23bda83101f4c278337428dc15eda0eecc95b.zip binutils-85d23bda83101f4c278337428dc15eda0eecc95b.tar.gz binutils-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/ax-gdb.c')
-rw-r--r-- | gdb/ax-gdb.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 6471088..756f4d7 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2491,6 +2491,29 @@ comma_operation::do_generate_ax (struct expression *exp, /* It's the consumer's responsibility to trace the right operand. */ } +void +unop_sizeof_operation::do_generate_ax (struct expression *exp, + struct agent_expr *ax, + struct axs_value *value, + struct type *cast_type) +{ + /* We don't care about the value of the operand expression; we only + care about its type. However, in the current arrangement, the + only way to find an expression's type is to generate code for it. + So we generate code for the operand, and then throw it away, + replacing it with code that simply pushes its size. */ + int start = ax->len; + + std::get<0> (m_storage)->generate_ax (exp, ax, value); + + /* Throw away the code we just generated. */ + ax->len = start; + + ax_const_l (ax, TYPE_LENGTH (value->type)); + value->kind = axs_rvalue; + value->type = builtin_type (ax->gdbarch)->builtin_int; +} + } /* This handles the middle-to-right-side of code generation for binary |