diff options
author | Tom Tromey <tom@tromey.com> | 2020-04-01 14:09:52 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-01 14:09:52 -0600 |
commit | 4c99290df04ba757b74a21ac5a6d16fe300e49ed (patch) | |
tree | ccb4fc81ef873b8bb729af596360c54817a3e824 /gdb/value.c | |
parent | 5b930b4538f70a9f09280e36164840e48fb1c042 (diff) | |
download | gdb-4c99290df04ba757b74a21ac5a6d16fe300e49ed.zip gdb-4c99290df04ba757b74a21ac5a6d16fe300e49ed.tar.gz gdb-4c99290df04ba757b74a21ac5a6d16fe300e49ed.tar.bz2 |
Add accessors for members of complex numbers
This introduces two new functions that make it simpler to access the
components of a complex number.
gdb/ChangeLog
2020-04-01 Tom Tromey <tom@tromey.com>
* valprint.c (generic_value_print_complex): Use accessors.
* value.h (value_real_part, value_imaginary_part): Declare.
* valops.c (value_real_part, value_imaginary_part): New
functions.
* value.c (creal_internal_fn, cimag_internal_fn): Use accessors.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/gdb/value.c b/gdb/value.c index ceaeb83..f722c27 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3962,7 +3962,7 @@ creal_internal_fn (struct gdbarch *gdbarch, type *ctype = check_typedef (value_type (cval)); if (TYPE_CODE (ctype) != TYPE_CODE_COMPLEX) error (_("expected a complex number")); - return value_from_component (cval, TYPE_TARGET_TYPE (ctype), 0); + return value_real_part (cval); } /* Implementation of the convenience function $_cimag. Extracts the @@ -3981,8 +3981,7 @@ cimag_internal_fn (struct gdbarch *gdbarch, type *ctype = check_typedef (value_type (cval)); if (TYPE_CODE (ctype) != TYPE_CODE_COMPLEX) error (_("expected a complex number")); - return value_from_component (cval, TYPE_TARGET_TYPE (ctype), - TYPE_LENGTH (TYPE_TARGET_TYPE (ctype))); + return value_imaginary_part (cval); } #if GDB_SELF_TEST |