gdb/
[binutils-gdb.git] / gdb / ada-typeprint.c
index ffbe49eb9b96e9a91ebdf1bbba686e7e85d2d742..7e8a649fa2027a916edf5684083a2d70f6f68532 100644 (file)
@@ -55,7 +55,7 @@ static void
 print_dynamic_range_bound (struct type *, const char *, int,
                           const char *, struct ui_file *);
 
-static void print_range_type_named (char *, struct type *, struct ui_file *);
+static void print_range_type (struct type *, struct ui_file *);
 \f
 
 
@@ -151,6 +151,7 @@ print_range_bound (struct type *type, char *bounds, int *n,
                   struct ui_file *stream)
 {
   LONGEST B;
+
   if (ada_scan_number (bounds, *n, &B, n))
     {
       /* STABS decodes all range types which bounds are 0 .. -1 as
@@ -212,19 +213,19 @@ print_dynamic_range_bound (struct type *type, const char *name, int name_len,
     fprintf_filtered (stream, "?");
 }
 
-/* Print the range type named NAME.  If symbol lookup fails, fall back
-   to ORIG_TYPE as base type.  */
+/* Print RAW_TYPE as a range type, using any bound information
+   following the GNAT encoding (if available).  */
 
 static void
-print_range_type_named (char *name, struct type *orig_type,
-                       struct ui_file *stream)
+print_range_type (struct type *raw_type, struct ui_file *stream)
 {
-  struct type *raw_type = ada_find_any_type (name);
+  char *name;
   struct type *base_type;
   char *subtype_info;
 
-  if (raw_type == NULL)
-    raw_type = orig_type;
+  gdb_assert (raw_type != NULL);
+  name = TYPE_NAME (raw_type);
+  gdb_assert (name != NULL);
 
   if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
     base_type = TYPE_TARGET_TYPE (raw_type);
@@ -310,15 +311,6 @@ print_fixed_point_type (struct type *type, struct ui_file *stream)
     }
 }
 
-/* Print representation of special VAX floating-point type TYPE on STREAM.  */
-
-static void
-print_vax_floating_point_type (struct type *type, struct ui_file *stream)
-{
-  fprintf_filtered (stream, "<float format %c>",
-                   ada_vax_float_type_suffix (type));
-}
-
 /* Print simple (constrained) array 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
@@ -350,10 +342,12 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
     {
       if (ada_is_simple_array_type (type))
        {
-         struct type *range_desc_type =
-           ada_find_parallel_type (type, "___XA");
+         struct type *range_desc_type;
          struct type *arr_type;
 
+         range_desc_type = ada_find_parallel_type (type, "___XA");
+         ada_fixup_array_indexes_type (range_desc_type);
+
          bitsize = 0;
          if (range_desc_type == NULL)
            {
@@ -370,6 +364,7 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
          else
            {
              int k;
+
              n_indices = TYPE_NFIELDS (range_desc_type);
              for (k = 0, arr_type = type;
                   k < n_indices;
@@ -377,9 +372,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
                {
                  if (k > 0)
                    fprintf_filtered (stream, ", ");
-                 print_range_type_named (TYPE_FIELD_NAME
-                                         (range_desc_type, k),
-                                         TYPE_INDEX_TYPE (arr_type), stream);
+                 print_range_type (TYPE_FIELD_TYPE (range_desc_type, k),
+                                   stream);
                  if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
                    bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
                }
@@ -388,6 +382,7 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
       else
        {
          int i, i0;
+
          for (i = i0 = ada_array_arity (type); i > 0; i -= 1)
            fprintf_filtered (stream, "%s<>", i == i0 ? "" : ", ");
        }
@@ -443,6 +438,7 @@ print_choices (struct type *type, int field_num, struct ui_file *stream,
        case 'S':
          {
            LONGEST W;
+
            if (!ada_scan_number (name, p + 1, &W, &p))
              goto Huh;
            ada_print_scalar (val_type, W, stream);
@@ -451,6 +447,7 @@ print_choices (struct type *type, int field_num, struct ui_file *stream,
        case 'R':
          {
            LONGEST L, U;
+
            if (!ada_scan_number (name, p + 1, &L, &p)
                || name[p] != 'T' || !ada_scan_number (name, p + 1, &U, &p))
              goto Huh;
@@ -786,26 +783,23 @@ ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
       case TYPE_CODE_INT:
        if (ada_is_fixed_point_type (type))
          print_fixed_point_type (type, stream);
-       else if (ada_is_vax_floating_type (type))
-         print_vax_floating_point_type (type, stream);
        else
          {
            char *name = ada_type_name (type);
+
            if (!ada_is_range_type_name (name))
              fprintf_filtered (stream, _("<%d-byte integer>"),
                                TYPE_LENGTH (type));
            else
              {
                fprintf_filtered (stream, "range ");
-               print_range_type_named (name, type, stream);
+               print_range_type (type, stream);
              }
          }
        break;
       case TYPE_CODE_RANGE:
        if (ada_is_fixed_point_type (type))
          print_fixed_point_type (type, stream);
-       else if (ada_is_vax_floating_type (type))
-         print_vax_floating_point_type (type, stream);
        else if (ada_is_modular_type (type))
          fprintf_filtered (stream, "mod %s", 
                            int_string (ada_modulus (type), 10, 0, 0, 1));
@@ -841,3 +835,14 @@ ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
        break;
       }
 }
+
+/* Implement the la_print_typedef language method for Ada.  */
+
+void
+ada_print_typedef (struct type *type, struct symbol *new_symbol,
+                   struct ui_file *stream)
+{
+  type = ada_check_typedef (type);
+  ada_print_type (type, "", stream, 0, 0);
+  fprintf_filtered (stream, "\n");
+}