2010-05-06 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / p-typeprint.c
index 697a2b9ec4ec76f530d546c232f794a536f15700..8924a28cc3ee5e7070d69bf6c0b74a90b1ea7b41 100644 (file)
@@ -1,12 +1,12 @@
 /* Support for printing Pascal types for GDB, the GNU debugger.
-   Copyright (C) 2000, 2001, 2002
+   Copyright (C) 2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,9 +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., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This file is derived from p-typeprint.c */
 
@@ -59,23 +57,23 @@ pascal_print_type (struct type *type, char *varstring, struct ui_file *stream,
   if (show > 0)
     CHECK_TYPEDEF (type);
 
-  if ((code == TYPE_CODE_FUNC ||
-       code == TYPE_CODE_METHOD))
+  if ((code == TYPE_CODE_FUNC
+       || code == TYPE_CODE_METHOD))
     {
       pascal_type_print_varspec_prefix (type, stream, show, 0);
     }
   /* first the name */
   fputs_filtered (varstring, stream);
 
-  if ((varstring != NULL && *varstring != '\0') &&
-      !(code == TYPE_CODE_FUNC ||
-       code == TYPE_CODE_METHOD))
+  if ((varstring != NULL && *varstring != '\0')
+      && !(code == TYPE_CODE_FUNC
+          || code == TYPE_CODE_METHOD))
     {
       fputs_filtered (" : ", stream);
     }
 
-  if (!(code == TYPE_CODE_FUNC ||
-       code == TYPE_CODE_METHOD))
+  if (!(code == TYPE_CODE_FUNC
+       || code == TYPE_CODE_METHOD))
     {
       pascal_type_print_varspec_prefix (type, stream, show, 0);
     }
@@ -89,6 +87,21 @@ pascal_print_type (struct type *type, char *varstring, struct ui_file *stream,
 
 }
 
+/* Print a typedef using Pascal syntax.  TYPE is the underlying type.
+   NEW_SYMBOL is the symbol naming the type.  STREAM is the stream on
+   which to print.  */
+
+void
+pascal_print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream)
+{
+  CHECK_TYPEDEF (type);
+  fprintf_filtered (stream, "type ");
+  fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new_symbol));
+  type_print (type, "", stream, 0);
+  fprintf_filtered (stream, ";\n");
+}
+
 /* If TYPE is a derived type, then print out derivation information.
    Print only the actual base classes of this type, not the base classes
    of the base classes.  I.E.  for the derivation hierarchy:
@@ -140,8 +153,8 @@ void
 pascal_type_print_method_args (char *physname, char *methodname,
                               struct ui_file *stream)
 {
-  int is_constructor = DEPRECATED_STREQN (physname, "__ct__", 6);
-  int is_destructor = DEPRECATED_STREQN (physname, "__dt__", 6);
+  int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
+  int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
 
   if (is_constructor || is_destructor)
     {
@@ -192,7 +205,6 @@ void
 pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
                                  int show, int passed_a_ptr)
 {
-  char *name;
   if (type == 0)
     return;
 
@@ -208,19 +220,6 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
       pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
       break;                   /* pointer should be handled normally in pascal */
 
-    case TYPE_CODE_MEMBER:
-      if (passed_a_ptr)
-       fprintf_filtered (stream, "(");
-      pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
-      fprintf_filtered (stream, " ");
-      name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
-      if (name)
-       fputs_filtered (name, stream);
-      else
-       pascal_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
-      fprintf_filtered (stream, "::");
-      break;
-
     case TYPE_CODE_METHOD:
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
@@ -265,12 +264,11 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
       fprintf_filtered (stream, "array ");
-      if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
-       && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
-       fprintf_filtered (stream, "[%d..%d] ",
-                         TYPE_ARRAY_LOWER_BOUND_VALUE (type),
-                         TYPE_ARRAY_UPPER_BOUND_VALUE (type)
-         );
+      if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
+       && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
+       fprintf_filtered (stream, "[%s..%s] ",
+                         plongest (TYPE_ARRAY_LOWER_BOUND_VALUE (type)),
+                         plongest (TYPE_ARRAY_UPPER_BOUND_VALUE (type)));
       fprintf_filtered (stream, "of ");
       break;
 
@@ -290,7 +288,6 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_BITSTRING:
     case TYPE_CODE_COMPLEX:
     case TYPE_CODE_TYPEDEF:
-    case TYPE_CODE_TEMPLATE:
       /* These types need no prefix.  They are listed here so that
          gcc -Wall will reveal any types that haven't been handled.  */
       break;
@@ -353,12 +350,6 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
        fprintf_filtered (stream, ")");
       break;
 
-    case TYPE_CODE_MEMBER:
-      if (passed_a_ptr)
-       fprintf_filtered (stream, ")");
-      pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
-      break;
-
     case TYPE_CODE_METHOD:
       if (passed_a_ptr)
        fprintf_filtered (stream, ")");
@@ -411,7 +402,6 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_BITSTRING:
     case TYPE_CODE_COMPLEX:
     case TYPE_CODE_TYPEDEF:
-    case TYPE_CODE_TEMPLATE:
       /* These types do not need a suffix.  They are listed so that
          gcc -Wall will report types that may not have been considered.  */
       break;
@@ -481,7 +471,6 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
     {
     case TYPE_CODE_TYPEDEF:
     case TYPE_CODE_PTR:
-    case TYPE_CODE_MEMBER:
     case TYPE_CODE_REF:
       /* case TYPE_CODE_FUNC:
          case TYPE_CODE_METHOD: */
@@ -560,7 +549,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
            {
              QUIT;
              /* Don't print out virtual function table.  */
-             if (DEPRECATED_STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
+             if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0)
                  && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
                continue;
 
@@ -597,14 +586,12 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
                }
 
              print_spaces_filtered (level + 4, stream);
-             if (TYPE_FIELD_STATIC (type, i))
-               {
-                 fprintf_filtered (stream, "static ");
-               }
+             if (field_is_static (&TYPE_FIELD (type, i)))
+               fprintf_filtered (stream, "static ");
              pascal_print_type (TYPE_FIELD_TYPE (type, i),
                                 TYPE_FIELD_NAME (type, i),
                                 stream, show - 1, level + 4);
-             if (!TYPE_FIELD_STATIC (type, i)
+             if (!field_is_static (&TYPE_FIELD (type, i))
                  && TYPE_FIELD_PACKED (type, i))
                {
                  /* It is a bitfield.  This code does not attempt
@@ -630,7 +617,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
              struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
              int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
              char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
-             char *name = type_name_no_tag (type);
+
              /* this is GNU C++ specific
                 how can we know constructor/destructor?
                 It might work for GNU pascal */
@@ -638,8 +625,8 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
                {
                  char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
 
-                 int is_constructor = DEPRECATED_STREQN (physname, "__ct__", 6);
-                 int is_destructor = DEPRECATED_STREQN (physname, "__dt__", 6);
+                 int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
+                 int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
 
                  QUIT;
                  if (TYPE_FN_FIELD_PROTECTED (f, j))
@@ -687,8 +674,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
                    {
                      fprintf_filtered (stream, "destructor  ");
                    }
-                 else if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0 &&
-                          TYPE_CODE (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
+                 else if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
+                          && TYPE_CODE (TYPE_TARGET_TYPE (
+                               TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
                    {
                      fprintf_filtered (stream, "function  ");
                    }
@@ -702,8 +690,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
                                                 method_name,
                                                 stream);
 
-                 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0 &&
-                     TYPE_CODE (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
+                 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
+                     && TYPE_CODE (TYPE_TARGET_TYPE (
+                          TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
                    {
                      fputs_filtered (" : ", stream);
                      type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
@@ -775,8 +764,6 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
     case TYPE_CODE_RANGE:
       {
        struct type *target = TYPE_TARGET_TYPE (type);
-       if (target == NULL)
-         target = builtin_type_long;
        print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
        fputs_filtered ("..", stream);
        print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
This page took 0.031156 seconds and 4 git commands to generate.