tx19 sanitize fixes.
[deliverable/binutils-gdb.git] / gdb / ch-typeprint.c
index 740af37280193f5b14c32efc668f68fa786db384..a6b1944d3870f8886ec06a3d75a22792e0ad57a0 100644 (file)
@@ -15,7 +15,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include "obstack.h"
@@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "ch-lang.h"
 #include "typeprint.h"
 
-#include <string.h>
+#include "gdb_string.h"
 #include <errno.h>
 
 static void
@@ -74,7 +74,6 @@ chill_type_print_base (type, stream, show, level)
      int show;
      int level;
 {
-  char *name;
   register int len;
   register int i;
   struct type *index_type;
@@ -100,18 +99,23 @@ chill_type_print_base (type, stream, show, level)
       return;
     }
 
-  check_stub_type (type);
+  if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
+    CHECK_TYPEDEF (type);
 
   switch (TYPE_CODE (type))
     {
+      case TYPE_CODE_TYPEDEF:
+        chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
+       break;
       case TYPE_CODE_PTR:
        if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
          {
-           fprintf_filtered (stream, "PTR");
+           fprintf_filtered (stream,
+                             TYPE_NAME (type) ? TYPE_NAME (type) : "PTR");
            break;
          }
        fprintf_filtered (stream, "REF ");
-       chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+       chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
        break;
 
       case TYPE_CODE_BOOL:
@@ -119,20 +123,26 @@ chill_type_print_base (type, stream, show, level)
           anyone ever fixes the compiler to give us the real names
           in the presence of the chill equivalent of typedef (assuming
           there is one).  */
-       fprintf_filtered (stream, "BOOL");
+       fprintf_filtered (stream,
+                         TYPE_NAME (type) ? TYPE_NAME (type) : "BOOL");
        break;
 
       case TYPE_CODE_ARRAY:
-       range_type = TYPE_FIELD_TYPE (type, 0);
-       index_type = TYPE_TARGET_TYPE (range_type);
-       low_bound = TYPE_FIELD_BITPOS (range_type, 0);
-       high_bound = TYPE_FIELD_BITPOS (range_type, 1);
         fputs_filtered ("ARRAY (", stream);
-       print_type_scalar (index_type, low_bound, stream);
-       fputs_filtered (":", stream);
-       print_type_scalar (index_type, high_bound, stream);
+       range_type = TYPE_FIELD_TYPE (type, 0);
+       if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
+         chill_print_type (range_type, "", stream, 0, level);
+       else
+         {
+           index_type = TYPE_TARGET_TYPE (range_type);
+           low_bound = TYPE_FIELD_BITPOS (range_type, 0);
+           high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+           print_type_scalar (index_type, low_bound, stream);
+           fputs_filtered (":", stream);
+           print_type_scalar (index_type, high_bound, stream);
+         }
        fputs_filtered (") ", stream);
-       chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
+       chill_print_type (TYPE_TARGET_TYPE (type), "", stream, 0, level);
        break;
 
       case TYPE_CODE_BITSTRING:
@@ -142,7 +152,7 @@ chill_type_print_base (type, stream, show, level)
 
       case TYPE_CODE_SET:
         fputs_filtered ("POWERSET ", stream);
-       chill_print_type (TYPE_FIELD_TYPE (type, 0), "", stream,
+       chill_print_type (TYPE_INDEX_TYPE (type), "", stream,
                          show - 1, level);
        break;
 
@@ -157,22 +167,46 @@ chill_type_print_base (type, stream, show, level)
 
       case TYPE_CODE_MEMBER:
        fprintf_filtered (stream, "MEMBER ");
-        chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+        chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
        break;
       case TYPE_CODE_REF:
        fprintf_filtered (stream, "/*LOC*/ ");
         chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
        break;
       case TYPE_CODE_FUNC:
-       fprintf_filtered (stream, "PROC (?)");
-        chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+       fprintf_filtered (stream, "PROC (");
+       len = TYPE_NFIELDS (type);
+       for (i = 0; i < len; i++)
+         {
+           struct type *param_type = TYPE_FIELD_TYPE (type, i);
+           if (i > 0)
+             {
+               fputs_filtered (", ", stream);
+               wrap_here ("    ");
+             }
+           if (TYPE_CODE (param_type) == TYPE_CODE_REF)
+             {
+               chill_type_print_base (TYPE_TARGET_TYPE (param_type),
+                                      stream, 0, level);
+               fputs_filtered (" LOC", stream);
+             }
+           else
+             chill_type_print_base (param_type, stream, show, level);
+         }
+       fprintf_filtered (stream, ")");
+       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+         {
+           fputs_filtered (" RETURNS (", stream);
+           chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
+           fputs_filtered (")", stream);
+         }
        break;
 
       case TYPE_CODE_STRUCT:
-       if (chill_is_varying_struct (type))
+       if (chill_varying_type (type))
          {
            chill_type_print_base (TYPE_FIELD_TYPE (type, 1),
-                                  stream, show, level);
+                                  stream, 0, level);
            fputs_filtered (" VARYING", stream);
          }
        else
@@ -226,7 +260,8 @@ chill_type_print_base (type, stream, show, level)
                                fputs_filtered ("\n", stream);
                              }
                          }
-                       fputs_filtered ("ESAC\n", stream);
+                       print_spaces_filtered (level + 4, stream);
+                       fputs_filtered ("ESAC", stream);
                      }
                    else
                      chill_print_type (field_type,
@@ -244,25 +279,20 @@ chill_type_print_base (type, stream, show, level)
        break;
 
       case TYPE_CODE_RANGE:
-       if (TYPE_DUMMY_RANGE (type))
-         chill_type_print_base (TYPE_TARGET_TYPE (type),
-                                stream, show, level);
-       else if (TYPE_TARGET_TYPE (type))
          {
-           chill_type_print_base (TYPE_TARGET_TYPE (type),
-                                  stream, show, level);
+           struct type *target = TYPE_TARGET_TYPE (type);
+           if (target && TYPE_NAME (target))
+             fputs_filtered (TYPE_NAME (target), stream);
+           else
+             fputs_filtered ("RANGE", stream);
+           if (target == NULL)
+             target = builtin_type_long;
            fputs_filtered (" (", stream);
-           print_type_scalar (TYPE_TARGET_TYPE (type),
-                              TYPE_FIELD_BITPOS (type, 0), stream);
+           print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
            fputs_filtered (":", stream);
-           print_type_scalar (TYPE_TARGET_TYPE (type),
-                              TYPE_FIELD_BITPOS (type, 1), stream);
+           print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
            fputs_filtered (")", stream);
          }
-       else
-         fprintf_filtered (stream, "RANGE? (%s : %d)",
-                           TYPE_FIELD_BITPOS (type, 0),
-                           TYPE_FIELD_BITPOS (type, 1));
        break;
 
       case TYPE_CODE_ENUM:
This page took 0.02632 seconds and 4 git commands to generate.