diff options
author | Per Bothner <per@bothner.com> | 1993-12-14 04:32:51 +0000 |
---|---|---|
committer | Per Bothner <per@bothner.com> | 1993-12-14 04:32:51 +0000 |
commit | e909f287a8340e2fe7a99f6fc1649801ec807768 (patch) | |
tree | c63edf815aaacd4fd20ca3cd370799843151bc34 /gdb/gdbtypes.c | |
parent | 1400cdc51d7a0264cea808e46f22a0a35faebac9 (diff) | |
download | gdb-e909f287a8340e2fe7a99f6fc1649801ec807768.zip gdb-e909f287a8340e2fe7a99f6fc1649801ec807768.tar.gz gdb-e909f287a8340e2fe7a99f6fc1649801ec807768.tar.bz2 |
Implement support for Chill POWERSETs.
* ch-exp.y (operand_2): Implement 'Element IN PowerSet'.
* ch-typeprint.c (chill_type_print_base): Handle POWERSETs.
* ch-valprint.c (chill_val_print): Handle TYPE_CODE_SET.
* eval.c (evaluate_subexp): Implement BINOP_IN.
* expression.h (enum exp_opcode): Added BINOP_IN.
* gdbtypes.c (create_set_type), gdbtypes.h: New function.
* stabsread.c (read_type): If 'S', create a set type.
* valarith.c (value_bit_index, value_in), value.h: New functions,
for indexing in SETs.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r-- | gdb/gdbtypes.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 4755c82..528e907 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -417,6 +417,40 @@ create_string_type (result_type, range_type) return (result_type); } +struct type * +create_set_type (result_type, domain_type) + struct type *result_type; + struct type *domain_type; +{ + if (result_type == NULL) + { + result_type = alloc_type (TYPE_OBJFILE (domain_type)); + } + TYPE_CODE (result_type) = TYPE_CODE_SET; + TYPE_NFIELDS (result_type) = 1; + TYPE_FIELDS (result_type) = (struct field *) + TYPE_ALLOC (result_type, 1 * sizeof (struct field)); + memset (TYPE_FIELDS (result_type), 0, sizeof (struct field)); + TYPE_FIELD_TYPE (result_type, 0) = domain_type; + if (TYPE_CODE (domain_type) != TYPE_CODE_RANGE) + TYPE_LENGTH (result_type) = 4; /* Error? */ + else + { + int low_bound = TYPE_FIELD_BITPOS (domain_type, 0); + int high_bound = TYPE_FIELD_BITPOS (domain_type, 1); + int bit_length = high_bound - low_bound + 1; + if (bit_length <= TARGET_CHAR_BIT) + TYPE_LENGTH (result_type) = 1; + else if (bit_length <= TARGET_SHORT_BIT) + TYPE_LENGTH (result_type) = TARGET_SHORT_BIT / TARGET_CHAR_BIT; + else + TYPE_LENGTH (result_type) + = ((bit_length + TARGET_INT_BIT - 1) / TARGET_INT_BIT) + * TARGET_CHAR_BIT; + } + return (result_type); +} + /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. A MEMBER is a wierd thing -- it amounts to a typed offset into a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't |