diff options
author | Tom Tromey <tom@tromey.com> | 2018-02-09 13:31:42 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-02-26 09:21:08 -0700 |
commit | 7c22600aabfd10e190e98fff0b7c2d69cd191325 (patch) | |
tree | fe62912bb7071c2d73027cd20f5c0b3c7fb8bf04 /gdb/value.h | |
parent | 15ce8941e7d2807a3396a6874c528b24c387660a (diff) | |
download | binutils-7c22600aabfd10e190e98fff0b7c2d69cd191325.zip binutils-7c22600aabfd10e190e98fff0b7c2d69cd191325.tar.gz binutils-7c22600aabfd10e190e98fff0b7c2d69cd191325.tar.bz2 |
Initial support for variant parts
This adds some initial support for variant parts to gdbtypes.h. A
variant part is represented as a union. The union has a flag
indicating that it has a discriminant, and information about the
discriminant is attached using the dynamic property system.
2018-02-26 Tom Tromey <tom@tromey.com>
* value.h (value_union_variant): Declare.
* valops.c (value_union_variant): New function.
* gdbtypes.h (TYPE_FLAG_DISCRIMINATED_UNION): New macro.
(struct discriminant_info): New.
(enum dynamic_prop_node_kind) <DYN_PROP_DISCRIMINATED>: New
enumerator.
(struct main_type) <flag_discriminated_union>: New field.
Diffstat (limited to 'gdb/value.h')
-rw-r--r-- | gdb/value.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/value.h b/gdb/value.h index 5676d24..0bc5130 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1169,4 +1169,12 @@ extern struct type *result_type_of_xmethod (struct value *method, extern struct value *call_xmethod (struct value *method, int argc, struct value **argv); +/* Given a discriminated union type and some corresponding value + contents, this will return the field index of the currently active + variant. This will throw an exception if no active variant can be + found. */ + +extern int value_union_variant (struct type *union_type, + const gdb_byte *contents); + #endif /* !defined (VALUE_H) */ |