#include "gdb_string.h"
#include <errno.h>
+static int print_selected_record_field_types (struct type *, struct type *,
+ int, int,
+ struct ui_file *, int, int);
+
static int print_record_field_types (struct type *, struct type *,
struct ui_file *, int, int);
static void print_array_type (struct type *, struct ui_file *, int, int);
-static void print_choices (struct type *, int, struct ui_file *,
- struct type *);
+static int print_choices (struct type *, int, struct ui_file *,
+ struct type *);
static void print_range (struct type *, struct ui_file *);
}
/* Print the choices encoded by field FIELD_NUM of variant-part TYPE on
- STREAM, assuming that VAL_TYPE (if non-NULL) is the type of the values. */
+ STREAM, assuming that VAL_TYPE (if non-NULL) is the type of the
+ values. Returns non-zero if the field is an encoding of
+ discriminant values, as in a standard variant record, and 0 if the
+ field is not so encoded (as happens with single-component variants
+ in types annotated with pragma Unchecked_Variant.)
+ */
-static void
+static int
print_choices (struct type *type, int field_num, struct ui_file *stream,
struct type *val_type)
{
switch (name[p])
{
default:
- return;
+ goto Huh;
+ case '_':
+ case '\0':
+ fprintf_filtered (stream, " =>");
+ return 1;
case 'S':
case 'R':
case 'O':
}
Huh:
- fprintf_filtered (stream, "??");
-
+ fprintf_filtered (stream, "?? =>");
+ return 0;
}
-/* Assuming that field FIELD_NUM of TYPE is a VARIANTS field whose
- discriminant is contained in OUTER_TYPE, print its variants on STREAM.
- LEVEL is the recursion
- (indentation) level, in case any of the fields themselves have
- nested structure, and SHOW is the number of levels of internal structure
- to show (see ada_print_type). For this purpose, fields nested in a
- variant part are taken to be at the same level as the fields
- immediately outside the variant part. */
+/* Assuming that field FIELD_NUM of TYPE represents variants whose
+ discriminant is contained in OUTER_TYPE, print its components on STREAM.
+ LEVEL is the recursion (indentation) level, in case any of the fields
+ themselves have nested structure, and SHOW is the number of levels of
+ internal structure to show (see ada_print_type). For this purpose,
+ fields nested in a variant part are taken to be at the same level as
+ the fields immediately outside the variant part. */
static void
print_variant_clauses (struct type *type, int field_num,
for (i = 0; i < TYPE_NFIELDS (var_type); i += 1)
{
fprintf_filtered (stream, "\n%*swhen ", level + 4, "");
- print_choices (var_type, i, stream, discr_type);
- fprintf_filtered (stream, " =>");
- if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
- outer_type, stream, show, level + 4) <= 0)
- fprintf_filtered (stream, " null;");
+ if (print_choices (var_type, i, stream, discr_type))
+ {
+ if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
+ outer_type, stream, show, level + 4)
+ <= 0)
+ fprintf_filtered (stream, " null;");
+ }
+ else
+ print_selected_record_field_types (var_type, outer_type, i, i,
+ stream, show, level + 4);
}
}
fprintf_filtered (stream, "\n%*send case;", level + 4, "");
}
-/* Print a description on STREAM of the fields in record type TYPE, whose
- discriminants are in OUTER_TYPE. LEVEL is the recursion (indentation)
- level, in case any of the fields themselves have nested structure,
- and SHOW is the number of levels of internal structure to show
- (see ada_print_type). Does not print parent type information of TYPE.
- Returns 0 if no fields printed, -1 for an incomplete type, else > 0.
- Prints each field beginning on a new line, but does not put a new line at
- end. */
+/* Print a description on STREAM of the fields FLD0 through FLD1 in
+ record or union type TYPE, whose discriminants are in OUTER_TYPE.
+ LEVEL is the recursion (indentation) level, in case any of the
+ fields themselves have nested structure, and SHOW is the number of
+ levels of internal structure to show (see ada_print_type). Does
+ not print parent type information of TYPE. Returns 0 if no fields
+ printed, -1 for an incomplete type, else > 0. Prints each field
+ beginning on a new line, but does not put a new line at end. */
static int
-print_record_field_types (struct type *type, struct type *outer_type,
- struct ui_file *stream, int show, int level)
+print_selected_record_field_types (struct type *type, struct type *outer_type,
+ int fld0, int fld1,
+ struct ui_file *stream, int show, int level)
{
- int len, i, flds;
+ int i, flds;
flds = 0;
- len = TYPE_NFIELDS (type);
- if (len == 0 && TYPE_STUB (type))
+ if (fld0 > fld1 && TYPE_STUB (type))
return -1;
- for (i = 0; i < len; i += 1)
+ for (i = fld0; i <= fld1; i += 1)
{
QUIT;
return flds;
}
+/* Print a description on STREAM of all fields of record or union type
+ TYPE, as for print_selected_record_field_types, above. */
+
+static int
+print_record_field_types (struct type *type, struct type *outer_type,
+ struct ui_file *stream, int show, int level)
+{
+ return print_selected_record_field_types (type, outer_type,
+ 0, TYPE_NFIELDS (type) - 1,
+ stream, show, level);
+}
+
+
/* Print record type TYPE on STREAM. LEVEL is the recursion (indentation)
level, in case the element type itself has nested structure, and SHOW is
the number of levels of internal structure to show (see ada_print_type). */