1
1
/* Support for printing Ada types for GDB, the GNU debugger.
2
2
Copyright (C) 1986, 1988, 1989, 1991, 1997, 1998, 1999, 2000, 2001, 2002,
3
2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
3
2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
5
This file is part of GDB.
117
/* Print range type TYPE on STREAM. */
117
/* Print TYPE on STREAM, preferably as a range. */
120
120
print_range (struct type *type, struct ui_file *stream)
122
struct type *target_type;
123
target_type = TYPE_TARGET_TYPE (type);
124
if (target_type == NULL)
127
switch (TYPE_CODE (target_type))
122
switch (TYPE_CODE (type))
129
124
case TYPE_CODE_RANGE:
133
125
case TYPE_CODE_ENUM:
127
struct type *target_type;
128
target_type = TYPE_TARGET_TYPE (type);
129
if (target_type == NULL)
131
ada_print_scalar (target_type, ada_discrete_type_low_bound (type),
133
fprintf_filtered (stream, " .. ");
134
ada_print_scalar (target_type, ada_discrete_type_high_bound (type),
140
if (TYPE_NFIELDS (type) < 2)
142
/* A range needs at least 2 bounds to be printed. If there are less
143
than 2, just print the type name instead of the range itself.
144
This check handles cases such as characters, for example.
146
If the name is not defined, then we don't print anything.
148
139
fprintf_filtered (stream, "%.*s",
149
140
ada_name_prefix_len (TYPE_NAME (type)),
150
141
TYPE_NAME (type));
154
/* We extract the range type bounds respectively from the first element
155
and the last element of the type->fields array */
156
const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type);
157
const LONGEST upper_bound = (TYPE_CODE (type) == TYPE_CODE_RANGE
158
? (LONGEST) TYPE_HIGH_BOUND (type)
159
: (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1));
161
ada_print_scalar (target_type, lower_bound, stream);
162
fprintf_filtered (stream, " .. ");
163
ada_print_scalar (target_type, upper_bound, stream);
334
/* Print representation of special VAX floating-point type TYPE on STREAM. */
337
print_vax_floating_point_type (struct type *type, struct ui_file *stream)
339
fprintf_filtered (stream, "<float format %c>",
340
ada_vax_float_type_suffix (type));
343
313
/* Print simple (constrained) array type TYPE on STREAM. LEVEL is the
344
314
recursion (indentation) level, in case the element type itself has
345
315
nested structure, and SHOW is the number of levels of internal
771
741
if (ada_is_aligner_type (type))
772
742
ada_print_type (ada_aligned_type (type), "", stream, show, level);
773
else if (ada_is_packed_array_type (type))
743
else if (ada_is_constrained_packed_array_type (type))
775
745
if (TYPE_CODE (type) == TYPE_CODE_PTR)
807
777
case TYPE_CODE_INT:
808
778
if (ada_is_fixed_point_type (type))
809
779
print_fixed_point_type (type, stream);
810
else if (ada_is_vax_floating_type (type))
811
print_vax_floating_point_type (type, stream);
814
782
char *name = ada_type_name (type);
825
793
case TYPE_CODE_RANGE:
826
794
if (ada_is_fixed_point_type (type))
827
795
print_fixed_point_type (type, stream);
828
else if (ada_is_vax_floating_type (type))
829
print_vax_floating_point_type (type, stream);
830
796
else if (ada_is_modular_type (type))
831
797
fprintf_filtered (stream, "mod %s",
832
798
int_string (ada_modulus (type), 10, 0, 0, 1));