summaryrefslogtreecommitdiffstats
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-12-15 02:52:11 +0000
committerFred Fish <fnf@specifix.com>1992-12-15 02:52:11 +0000
commit85f0a8484fae7fc4f28b85298253e786645a5b6a (patch)
tree723472495b0c8155f5eb698d4bbb08cb935ebc69 /gdb/gdbtypes.c
parent7f70a2756406d76578fc4a6af98c42fd85f28b12 (diff)
downloadppe42-binutils-85f0a8484fae7fc4f28b85298253e786645a5b6a.tar.gz
ppe42-binutils-85f0a8484fae7fc4f28b85298253e786645a5b6a.zip
* gdbtypes.c (create_array_type): Complete rewrite. Now requires
a optional type to decorate as an array type, the type of the index, and the bounds of the array. Records this additional info in the array type for use with languages with nonzero array bounds. * gdbtypes.h (enum type_code): Update comment for TYPE_CODE_ARRAY to note that arrays may have bounds. * gdbtypes.h (create_array_type): Update prototype. * c-exp.y (ptype production): Adjust for new create_array_type calling conventions. * coffread.c (decode_type): Call create_array_type rather than handcrafting array types. * convex-tdep.c (value_type): Remove, now use create_array_type. * convex-tdep.c (value_of_trapped_internalvar): Convert calls to vector_type into calls to create_array_type. * dwarfread.c (decode_subscr_data): Name changed to decode_subscript_data_item throughout. * dwarfread.c (decode_subscript_data_item): Rewrite to use create_array_type. Now records index type and range as well. * dwarfread.c (dwarf_read_array_type): Rewrite as part of change to use create_array_type. * dwarfread.c (read_subroutine_type): Test existing user defined types before decorating them, to ensure they are blank, and complain about it if they are not. * dwarfread.c (decode_fund_type): For unrecognized types, always return some valid type (type integer). If the unrecognized type cannot be an implementation defined type, complain as well. * m88k-tdep.c (pushed_size): Update comment for TYPE_CODE_ARRAY. * m88k-tdep.c (store_param): Update comment for TYPE_CODE_ARRAY. * mipsread.c (upgrade_type): Add FIXME comment that code to handcraft arrays should be replaced with call to create_array_type. * stabsread.c (read_array_type): Replace code to handcraft array types with call to create_array_type. * valprint.c (type_print_varspec_prefix): Minor formatting change, join lines that don't need to be split.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index dfb98acb97..e3ec14a7bb 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -290,49 +290,54 @@ allocate_stub_method (type)
return (mtype);
}
-/* Create an array type. Elements will be of type TYPE, and there will
- be NUM of them.
+/* Create an array type using either a blank type supplied in RESULT_TYPE,
+ or creating a new type. Elements will be of type ELEMENT_TYPE, the
+ indices will be of type INDEX_TYPE, and will range from LOW_BOUND
+ to HIGH_BOUND, inclusive.
- Eventually this should be extended to take two more arguments which
- specify the bounds of the array and the type of the index.
- It should also be changed to be a "lookup" function, with the
- appropriate data structures added to the type field.
- Then read array type should call here. */
+ FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
+ sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
struct type *
-create_array_type (element_type, number)
+create_array_type (result_type, element_type, index_type, low_bound,
+ high_bound)
+ struct type *result_type;
struct type *element_type;
- int number;
+ struct type *index_type;
+ int low_bound;
+ int high_bound;
{
- struct type *result_type;
struct type *range_type;
- result_type = alloc_type (TYPE_OBJFILE (element_type));
+ /* Create a blank type if we are not given one to bash on. */
+ if (result_type == NULL)
+ {
+ result_type = alloc_type (TYPE_OBJFILE (element_type));
+ }
+ /* Create a range type. */
+ range_type = alloc_type (TYPE_OBJFILE (element_type));
+ TYPE_CODE (range_type) = TYPE_CODE_RANGE;
+ TYPE_TARGET_TYPE (range_type) = index_type;
+ TYPE_LENGTH (range_type) = sizeof (int); /* This should never be needed. */
+ TYPE_NFIELDS (range_type) = 2;
+ TYPE_FIELDS (range_type) = (struct field *)
+ TYPE_ALLOC (range_type, 2 * sizeof (struct field));
+ memset (TYPE_FIELDS (range_type), 0, 2 * sizeof (struct field));
+ TYPE_FIELD_BITPOS (range_type, 0) = low_bound;
+ TYPE_FIELD_BITPOS (range_type, 1) = high_bound;
+ TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */
+ TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */
+
+ /* Create the array type. */
TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
TYPE_TARGET_TYPE (result_type) = element_type;
- TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type);
+ TYPE_LENGTH (result_type) =
+ TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
TYPE_NFIELDS (result_type) = 1;
TYPE_FIELDS (result_type) = (struct field *)
TYPE_ALLOC (result_type, sizeof (struct field));
-
- {
- /* Create range type. */
- range_type = alloc_type (TYPE_OBJFILE (result_type));
- TYPE_CODE (range_type) = TYPE_CODE_RANGE;
- TYPE_TARGET_TYPE (range_type) = builtin_type_int; /* FIXME */
-
- /* This should never be needed. */
- TYPE_LENGTH (range_type) = sizeof (int);
-
- TYPE_NFIELDS (range_type) = 2;
- TYPE_FIELDS (range_type) = (struct field *)
- TYPE_ALLOC (range_type, 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (range_type, 0) = 0; /* FIXME */
- TYPE_FIELD_BITPOS (range_type, 1) = number-1; /* FIXME */
- TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */
- TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */
- }
+ memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
TYPE_FIELD_TYPE (result_type, 0) = range_type;
TYPE_VPTR_FIELDNO (result_type) = -1;
OpenPOWER on IntegriCloud