unsigned int i;
unsigned int len;
- len = TYPE_NFIELDS (type);
+ len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
/* generic_val_print helper for TYPE_CODE_FLT and TYPE_CODE_DECFLOAT. */
static void
-generic_val_print_float (struct type *type,
- int embedded_offset, struct ui_file *stream,
+generic_val_print_float (struct type *type, struct ui_file *stream,
struct value *original_value,
const struct value_print_options *options)
{
- struct gdbarch *gdbarch = get_type_arch (type);
- int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-
gdb_assert (!options->format);
const gdb_byte *valaddr = value_contents_for_printing (original_value);
- print_floating (valaddr + embedded_offset * unit_size, type, stream);
+ print_floating (valaddr, type, stream);
}
/* generic_value_print helper for TYPE_CODE_COMPLEX. */
if (options->format)
value_print_scalar_formatted (val, options, 0, stream);
else
- generic_val_print_float (type, 0, stream,
- val, options);
+ generic_val_print_float (type, stream, val, options);
break;
case TYPE_CODE_VOID:
const gdb_byte *valaddr = (value_contents_for_printing (original_value)
+ embedded_offset);
ULONGEST val = unpack_long (type, valaddr);
- int field, nfields = TYPE_NFIELDS (type);
+ int field, nfields = type->num_fields ();
struct gdbarch *gdbarch = get_type_arch (type);
struct type *bool_type = builtin_type (gdbarch)->builtin_bool;
{
if (TYPE_FIELD_NAME (type, field)[0] != '\0')
{
- struct type *field_type = TYPE_FIELD_TYPE (type, field);
+ struct type *field_type = type->field (field).type ();
if (field_type == bool_type
/* We require boolean types here to be one bit wide. This is a
struct ui_file *stream,
const struct value_print_options *options)
{
- struct value *index_value;
-
if (!options->print_array_indexes)
return;
- index_value = value_from_longest (index_type, index);
-
- LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+ LA_PRINT_ARRAY_INDEX (index_type, index, stream, options);
}
/* See valprint.h. */
{
unsigned int things_printed = 0;
unsigned len;
- struct type *elttype, *index_type, *base_index_type;
+ struct type *elttype, *index_type;
unsigned eltlen;
/* Position of the array element we are examining to see
whether it is repeated. */
/* Number of repetitions we have detected so far. */
unsigned int reps;
LONGEST low_bound, high_bound;
- LONGEST low_pos, high_pos;
struct type *type = check_typedef (value_type (val));
elttype = TYPE_TARGET_TYPE (type);
eltlen = type_length_units (check_typedef (elttype));
- index_type = TYPE_INDEX_TYPE (type);
+ index_type = type->index_type ();
+ if (index_type->code () == TYPE_CODE_RANGE)
+ index_type = TYPE_TARGET_TYPE (index_type);
if (get_array_bounds (type, &low_bound, &high_bound))
{
- if (index_type->code () == TYPE_CODE_RANGE)
- base_index_type = TYPE_TARGET_TYPE (index_type);
- else
- base_index_type = index_type;
-
- /* Non-contiguous enumerations types can by used as index types
- in some languages (e.g. Ada). In this case, the array length
- shall be computed from the positions of the first and last
- literal in the enumeration type, and not from the values
- of these literals. */
- if (!discrete_position (base_index_type, low_bound, &low_pos)
- || !discrete_position (base_index_type, high_bound, &high_pos))
- {
- warning (_("unable to get positions in array, use bounds instead"));
- low_pos = low_bound;
- high_pos = high_bound;
- }
-
- /* The array length should normally be HIGH_POS - LOW_POS + 1.
- But we have to be a little extra careful, because some languages
- such as Ada allow LOW_POS to be greater than HIGH_POS for
- empty arrays. In that situation, the array length is just zero,
- not negative! */
- if (low_pos > high_pos)
+ /* The array length should normally be HIGH_BOUND - LOW_BOUND +
+ 1. But we have to be a little extra careful, because some
+ languages such as Ada allow LOW_BOUND to be greater than
+ HIGH_BOUND for empty arrays. In that situation, the array
+ length is just zero, not negative! */
+ if (low_bound > high_bound)
len = 0;
else
- len = high_pos - low_pos + 1;
+ len = high_bound - low_bound + 1;
}
else
{