GDB (API)
/home/stan/gdb/src/gdb/p-typeprint.c
Go to the documentation of this file.
00001 /* Support for printing Pascal types for GDB, the GNU debugger.
00002    Copyright (C) 2000-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 /* This file is derived from p-typeprint.c */
00020 
00021 #include "defs.h"
00022 #include "gdb_obstack.h"
00023 #include "bfd.h"                /* Binary File Description */
00024 #include "symtab.h"
00025 #include "gdbtypes.h"
00026 #include "expression.h"
00027 #include "value.h"
00028 #include "gdbcore.h"
00029 #include "target.h"
00030 #include "language.h"
00031 #include "p-lang.h"
00032 #include "typeprint.h"
00033 #include "gdb-demangle.h"
00034 #include "gdb_string.h"
00035 #include <errno.h>
00036 #include <ctype.h>
00037 
00038 static void pascal_type_print_varspec_suffix (struct type *, struct ui_file *,
00039                                               int, int, int,
00040                                               const struct type_print_options *);
00041 
00042 static void pascal_type_print_derivation_info (struct ui_file *,
00043                                                struct type *);
00044 
00045 
00046 
00047 /* LEVEL is the depth to indent lines by.  */
00048 
00049 void
00050 pascal_print_type (struct type *type, const char *varstring,
00051                    struct ui_file *stream, int show, int level,
00052                    const struct type_print_options *flags)
00053 {
00054   enum type_code code;
00055   int demangled_args;
00056 
00057   code = TYPE_CODE (type);
00058 
00059   if (show > 0)
00060     CHECK_TYPEDEF (type);
00061 
00062   if ((code == TYPE_CODE_FUNC
00063        || code == TYPE_CODE_METHOD))
00064     {
00065       pascal_type_print_varspec_prefix (type, stream, show, 0, flags);
00066     }
00067   /* first the name */
00068   fputs_filtered (varstring, stream);
00069 
00070   if ((varstring != NULL && *varstring != '\0')
00071       && !(code == TYPE_CODE_FUNC
00072            || code == TYPE_CODE_METHOD))
00073     {
00074       fputs_filtered (" : ", stream);
00075     }
00076 
00077   if (!(code == TYPE_CODE_FUNC
00078         || code == TYPE_CODE_METHOD))
00079     {
00080       pascal_type_print_varspec_prefix (type, stream, show, 0, flags);
00081     }
00082 
00083   pascal_type_print_base (type, stream, show, level, flags);
00084   /* For demangled function names, we have the arglist as part of the name,
00085      so don't print an additional pair of ()'s.  */
00086 
00087   demangled_args = varstring ? strchr (varstring, '(') != NULL : 0;
00088   pascal_type_print_varspec_suffix (type, stream, show, 0, demangled_args,
00089                                     flags);
00090 
00091 }
00092 
00093 /* Print a typedef using Pascal syntax.  TYPE is the underlying type.
00094    NEW_SYMBOL is the symbol naming the type.  STREAM is the stream on
00095    which to print.  */
00096 
00097 void
00098 pascal_print_typedef (struct type *type, struct symbol *new_symbol,
00099                       struct ui_file *stream)
00100 {
00101   CHECK_TYPEDEF (type);
00102   fprintf_filtered (stream, "type ");
00103   fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new_symbol));
00104   type_print (type, "", stream, 0);
00105   fprintf_filtered (stream, ";\n");
00106 }
00107 
00108 /* If TYPE is a derived type, then print out derivation information.
00109    Print only the actual base classes of this type, not the base classes
00110    of the base classes.  I.e. for the derivation hierarchy:
00111 
00112    class A { int a; };
00113    class B : public A {int b; };
00114    class C : public B {int c; };
00115 
00116    Print the type of class C as:
00117 
00118    class C : public B {
00119    int c;
00120    }
00121 
00122    Not as the following (like gdb used to), which is not legal C++ syntax for
00123    derived types and may be confused with the multiple inheritance form:
00124 
00125    class C : public B : public A {
00126    int c;
00127    }
00128 
00129    In general, gdb should try to print the types as closely as possible to
00130    the form that they appear in the source code.  */
00131 
00132 static void
00133 pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
00134 {
00135   const char *name;
00136   int i;
00137 
00138   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
00139     {
00140       fputs_filtered (i == 0 ? ": " : ", ", stream);
00141       fprintf_filtered (stream, "%s%s ",
00142                         BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private",
00143                         BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
00144       name = type_name_no_tag (TYPE_BASECLASS (type, i));
00145       fprintf_filtered (stream, "%s", name ? name : "(null)");
00146     }
00147   if (i > 0)
00148     {
00149       fputs_filtered (" ", stream);
00150     }
00151 }
00152 
00153 /* Print the Pascal method arguments ARGS to the file STREAM.  */
00154 
00155 void
00156 pascal_type_print_method_args (const char *physname, const char *methodname,
00157                                struct ui_file *stream)
00158 {
00159   int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
00160   int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
00161 
00162   if (is_constructor || is_destructor)
00163     {
00164       physname += 6;
00165     }
00166 
00167   fputs_filtered (methodname, stream);
00168 
00169   if (physname && (*physname != 0))
00170     {
00171       fputs_filtered (" (", stream);
00172       /* We must demangle this.  */
00173       while (isdigit (physname[0]))
00174         {
00175           int len = 0;
00176           int i, j;
00177           char *argname;
00178 
00179           while (isdigit (physname[len]))
00180             {
00181               len++;
00182             }
00183           i = strtol (physname, &argname, 0);
00184           physname += len;
00185 
00186           for (j = 0; j < i; ++j)
00187             fputc_filtered (physname[j], stream);
00188 
00189           physname += i;
00190           if (physname[0] != 0)
00191             {
00192               fputs_filtered (", ", stream);
00193             }
00194         }
00195       fputs_filtered (")", stream);
00196     }
00197 }
00198 
00199 /* Print any asterisks or open-parentheses needed before the
00200    variable name (to describe its type).
00201 
00202    On outermost call, pass 0 for PASSED_A_PTR.
00203    On outermost call, SHOW > 0 means should ignore
00204    any typename for TYPE and show its details.
00205    SHOW is always zero on recursive calls.  */
00206 
00207 void
00208 pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
00209                                   int show, int passed_a_ptr,
00210                                   const struct type_print_options *flags)
00211 {
00212   if (type == 0)
00213     return;
00214 
00215   if (TYPE_NAME (type) && show <= 0)
00216     return;
00217 
00218   QUIT;
00219 
00220   switch (TYPE_CODE (type))
00221     {
00222     case TYPE_CODE_PTR:
00223       fprintf_filtered (stream, "^");
00224       pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1,
00225                                         flags);
00226       break;                    /* Pointer should be handled normally
00227                                    in pascal.  */
00228 
00229     case TYPE_CODE_METHOD:
00230       if (passed_a_ptr)
00231         fprintf_filtered (stream, "(");
00232       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
00233         {
00234           fprintf_filtered (stream, "function  ");
00235         }
00236       else
00237         {
00238           fprintf_filtered (stream, "procedure ");
00239         }
00240 
00241       if (passed_a_ptr)
00242         {
00243           fprintf_filtered (stream, " ");
00244           pascal_type_print_base (TYPE_DOMAIN_TYPE (type),
00245                                   stream, 0, passed_a_ptr, flags);
00246           fprintf_filtered (stream, "::");
00247         }
00248       break;
00249 
00250     case TYPE_CODE_REF:
00251       pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1,
00252                                         flags);
00253       fprintf_filtered (stream, "&");
00254       break;
00255 
00256     case TYPE_CODE_FUNC:
00257       if (passed_a_ptr)
00258         fprintf_filtered (stream, "(");
00259 
00260       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
00261         {
00262           fprintf_filtered (stream, "function  ");
00263         }
00264       else
00265         {
00266           fprintf_filtered (stream, "procedure ");
00267         }
00268 
00269       break;
00270 
00271     case TYPE_CODE_ARRAY:
00272       if (passed_a_ptr)
00273         fprintf_filtered (stream, "(");
00274       fprintf_filtered (stream, "array ");
00275       if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
00276         && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
00277         fprintf_filtered (stream, "[%s..%s] ",
00278                           plongest (TYPE_ARRAY_LOWER_BOUND_VALUE (type)),
00279                           plongest (TYPE_ARRAY_UPPER_BOUND_VALUE (type)));
00280       fprintf_filtered (stream, "of ");
00281       break;
00282 
00283     case TYPE_CODE_UNDEF:
00284     case TYPE_CODE_STRUCT:
00285     case TYPE_CODE_UNION:
00286     case TYPE_CODE_ENUM:
00287     case TYPE_CODE_INT:
00288     case TYPE_CODE_FLT:
00289     case TYPE_CODE_VOID:
00290     case TYPE_CODE_ERROR:
00291     case TYPE_CODE_CHAR:
00292     case TYPE_CODE_BOOL:
00293     case TYPE_CODE_SET:
00294     case TYPE_CODE_RANGE:
00295     case TYPE_CODE_STRING:
00296     case TYPE_CODE_COMPLEX:
00297     case TYPE_CODE_TYPEDEF:
00298       /* These types need no prefix.  They are listed here so that
00299          gcc -Wall will reveal any types that haven't been handled.  */
00300       break;
00301     default:
00302       error (_("type not handled in pascal_type_print_varspec_prefix()"));
00303       break;
00304     }
00305 }
00306 
00307 static void
00308 pascal_print_func_args (struct type *type, struct ui_file *stream,
00309                         const struct type_print_options *flags)
00310 {
00311   int i, len = TYPE_NFIELDS (type);
00312 
00313   if (len)
00314     {
00315       fprintf_filtered (stream, "(");
00316     }
00317   for (i = 0; i < len; i++)
00318     {
00319       if (i > 0)
00320         {
00321           fputs_filtered (", ", stream);
00322           wrap_here ("    ");
00323         }
00324       /*  Can we find if it is a var parameter ??
00325          if ( TYPE_FIELD(type, i) == )
00326          {
00327          fprintf_filtered (stream, "var ");
00328          } */
00329       pascal_print_type (TYPE_FIELD_TYPE (type, i), ""  /* TYPE_FIELD_NAME
00330                                                            seems invalid!  */
00331                          ,stream, -1, 0, flags);
00332     }
00333   if (len)
00334     {
00335       fprintf_filtered (stream, ")");
00336     }
00337 }
00338 
00339 /* Print any array sizes, function arguments or close parentheses
00340    needed after the variable name (to describe its type).
00341    Args work like pascal_type_print_varspec_prefix.  */
00342 
00343 static void
00344 pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
00345                                   int show, int passed_a_ptr,
00346                                   int demangled_args,
00347                                   const struct type_print_options *flags)
00348 {
00349   if (type == 0)
00350     return;
00351 
00352   if (TYPE_NAME (type) && show <= 0)
00353     return;
00354 
00355   QUIT;
00356 
00357   switch (TYPE_CODE (type))
00358     {
00359     case TYPE_CODE_ARRAY:
00360       if (passed_a_ptr)
00361         fprintf_filtered (stream, ")");
00362       break;
00363 
00364     case TYPE_CODE_METHOD:
00365       if (passed_a_ptr)
00366         fprintf_filtered (stream, ")");
00367       pascal_type_print_method_args ("",
00368                                      "",
00369                                      stream);
00370       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
00371         {
00372           fprintf_filtered (stream, " : ");
00373           pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
00374                                             stream, 0, 0, flags);
00375           pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
00376                                   flags);
00377           pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
00378                                             passed_a_ptr, 0, flags);
00379         }
00380       break;
00381 
00382     case TYPE_CODE_PTR:
00383     case TYPE_CODE_REF:
00384       pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type),
00385                                         stream, 0, 1, 0, flags);
00386       break;
00387 
00388     case TYPE_CODE_FUNC:
00389       if (passed_a_ptr)
00390         fprintf_filtered (stream, ")");
00391       if (!demangled_args)
00392         pascal_print_func_args (type, stream, flags);
00393       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
00394         {
00395           fprintf_filtered (stream, " : ");
00396           pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
00397                                             stream, 0, 0, flags);
00398           pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
00399                                   flags);
00400           pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
00401                                             passed_a_ptr, 0, flags);
00402         }
00403       break;
00404 
00405     case TYPE_CODE_UNDEF:
00406     case TYPE_CODE_STRUCT:
00407     case TYPE_CODE_UNION:
00408     case TYPE_CODE_ENUM:
00409     case TYPE_CODE_INT:
00410     case TYPE_CODE_FLT:
00411     case TYPE_CODE_VOID:
00412     case TYPE_CODE_ERROR:
00413     case TYPE_CODE_CHAR:
00414     case TYPE_CODE_BOOL:
00415     case TYPE_CODE_SET:
00416     case TYPE_CODE_RANGE:
00417     case TYPE_CODE_STRING:
00418     case TYPE_CODE_COMPLEX:
00419     case TYPE_CODE_TYPEDEF:
00420       /* These types do not need a suffix.  They are listed so that
00421          gcc -Wall will report types that may not have been considered.  */
00422       break;
00423     default:
00424       error (_("type not handled in pascal_type_print_varspec_suffix()"));
00425       break;
00426     }
00427 }
00428 
00429 /* Print the name of the type (or the ultimate pointer target,
00430    function value or array element), or the description of a
00431    structure or union.
00432 
00433    SHOW positive means print details about the type (e.g. enum values),
00434    and print structure elements passing SHOW - 1 for show.
00435    SHOW negative means just print the type name or struct tag if there is one.
00436    If there is no name, print something sensible but concise like
00437    "struct {...}".
00438    SHOW zero means just print the type name or struct tag if there is one.
00439    If there is no name, print something sensible but not as concise like
00440    "struct {int x; int y;}".
00441 
00442    LEVEL is the number of spaces to indent by.
00443    We increase it for some recursive calls.  */
00444 
00445 void
00446 pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
00447                         int level, const struct type_print_options *flags)
00448 {
00449   int i;
00450   int len;
00451   LONGEST lastval;
00452   enum
00453     {
00454       s_none, s_public, s_private, s_protected
00455     }
00456   section_type;
00457 
00458   QUIT;
00459   wrap_here ("    ");
00460   if (type == NULL)
00461     {
00462       fputs_filtered ("<type unknown>", stream);
00463       return;
00464     }
00465 
00466   /* void pointer */
00467   if ((TYPE_CODE (type) == TYPE_CODE_PTR)
00468       && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID))
00469     {
00470       fputs_filtered (TYPE_NAME (type) ? TYPE_NAME (type) : "pointer",
00471                       stream);
00472       return;
00473     }
00474   /* When SHOW is zero or less, and there is a valid type name, then always
00475      just print the type name directly from the type.  */
00476 
00477   if (show <= 0
00478       && TYPE_NAME (type) != NULL)
00479     {
00480       fputs_filtered (TYPE_NAME (type), stream);
00481       return;
00482     }
00483 
00484   CHECK_TYPEDEF (type);
00485 
00486   switch (TYPE_CODE (type))
00487     {
00488     case TYPE_CODE_TYPEDEF:
00489     case TYPE_CODE_PTR:
00490     case TYPE_CODE_REF:
00491       /* case TYPE_CODE_FUNC:
00492          case TYPE_CODE_METHOD: */
00493       pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level,
00494                               flags);
00495       break;
00496 
00497     case TYPE_CODE_ARRAY:
00498       /* pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
00499                                            stream, 0, 0);
00500          pascal_type_print_base (TYPE_TARGET_TYPE (type),
00501                                  stream, show, level);
00502          pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type),
00503                                            stream, 0, 0, 0); */
00504       pascal_print_type (TYPE_TARGET_TYPE (type), NULL, stream, 0, 0, flags);
00505       break;
00506 
00507     case TYPE_CODE_FUNC:
00508     case TYPE_CODE_METHOD:
00509       /*
00510          pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
00511          only after args !!  */
00512       break;
00513     case TYPE_CODE_STRUCT:
00514       if (TYPE_TAG_NAME (type) != NULL)
00515         {
00516           fputs_filtered (TYPE_TAG_NAME (type), stream);
00517           fputs_filtered (" = ", stream);
00518         }
00519       if (HAVE_CPLUS_STRUCT (type))
00520         {
00521           fprintf_filtered (stream, "class ");
00522         }
00523       else
00524         {
00525           fprintf_filtered (stream, "record ");
00526         }
00527       goto struct_union;
00528 
00529     case TYPE_CODE_UNION:
00530       if (TYPE_TAG_NAME (type) != NULL)
00531         {
00532           fputs_filtered (TYPE_TAG_NAME (type), stream);
00533           fputs_filtered (" = ", stream);
00534         }
00535       fprintf_filtered (stream, "case <?> of ");
00536 
00537     struct_union:
00538       wrap_here ("    ");
00539       if (show < 0)
00540         {
00541           /* If we just printed a tag name, no need to print anything else.  */
00542           if (TYPE_TAG_NAME (type) == NULL)
00543             fprintf_filtered (stream, "{...}");
00544         }
00545       else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
00546         {
00547           pascal_type_print_derivation_info (stream, type);
00548 
00549           fprintf_filtered (stream, "\n");
00550           if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
00551             {
00552               if (TYPE_STUB (type))
00553                 fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
00554               else
00555                 fprintfi_filtered (level + 4, stream, "<no data fields>\n");
00556             }
00557 
00558           /* Start off with no specific section type, so we can print
00559              one for the first field we find, and use that section type
00560              thereafter until we find another type.  */
00561 
00562           section_type = s_none;
00563 
00564           /* If there is a base class for this type,
00565              do not print the field that it occupies.  */
00566 
00567           len = TYPE_NFIELDS (type);
00568           for (i = TYPE_N_BASECLASSES (type); i < len; i++)
00569             {
00570               QUIT;
00571               /* Don't print out virtual function table.  */
00572               if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0)
00573                   && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
00574                 continue;
00575 
00576               /* If this is a pascal object or class we can print the
00577                  various section labels.  */
00578 
00579               if (HAVE_CPLUS_STRUCT (type))
00580                 {
00581                   if (TYPE_FIELD_PROTECTED (type, i))
00582                     {
00583                       if (section_type != s_protected)
00584                         {
00585                           section_type = s_protected;
00586                           fprintfi_filtered (level + 2, stream,
00587                                              "protected\n");
00588                         }
00589                     }
00590                   else if (TYPE_FIELD_PRIVATE (type, i))
00591                     {
00592                       if (section_type != s_private)
00593                         {
00594                           section_type = s_private;
00595                           fprintfi_filtered (level + 2, stream, "private\n");
00596                         }
00597                     }
00598                   else
00599                     {
00600                       if (section_type != s_public)
00601                         {
00602                           section_type = s_public;
00603                           fprintfi_filtered (level + 2, stream, "public\n");
00604                         }
00605                     }
00606                 }
00607 
00608               print_spaces_filtered (level + 4, stream);
00609               if (field_is_static (&TYPE_FIELD (type, i)))
00610                 fprintf_filtered (stream, "static ");
00611               pascal_print_type (TYPE_FIELD_TYPE (type, i),
00612                                  TYPE_FIELD_NAME (type, i),
00613                                  stream, show - 1, level + 4, flags);
00614               if (!field_is_static (&TYPE_FIELD (type, i))
00615                   && TYPE_FIELD_PACKED (type, i))
00616                 {
00617                   /* It is a bitfield.  This code does not attempt
00618                      to look at the bitpos and reconstruct filler,
00619                      unnamed fields.  This would lead to misleading
00620                      results if the compiler does not put out fields
00621                      for such things (I don't know what it does).  */
00622                   fprintf_filtered (stream, " : %d",
00623                                     TYPE_FIELD_BITSIZE (type, i));
00624                 }
00625               fprintf_filtered (stream, ";\n");
00626             }
00627 
00628           /* If there are both fields and methods, put a space between.  */
00629           len = TYPE_NFN_FIELDS (type);
00630           if (len && section_type != s_none)
00631             fprintf_filtered (stream, "\n");
00632 
00633           /* Object pascal: print out the methods.  */
00634 
00635           for (i = 0; i < len; i++)
00636             {
00637               struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
00638               int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
00639               const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
00640 
00641               /* this is GNU C++ specific
00642                  how can we know constructor/destructor?
00643                  It might work for GNU pascal.  */
00644               for (j = 0; j < len2; j++)
00645                 {
00646                   const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
00647 
00648                   int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
00649                   int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
00650 
00651                   QUIT;
00652                   if (TYPE_FN_FIELD_PROTECTED (f, j))
00653                     {
00654                       if (section_type != s_protected)
00655                         {
00656                           section_type = s_protected;
00657                           fprintfi_filtered (level + 2, stream,
00658                                              "protected\n");
00659                         }
00660                     }
00661                   else if (TYPE_FN_FIELD_PRIVATE (f, j))
00662                     {
00663                       if (section_type != s_private)
00664                         {
00665                           section_type = s_private;
00666                           fprintfi_filtered (level + 2, stream, "private\n");
00667                         }
00668                     }
00669                   else
00670                     {
00671                       if (section_type != s_public)
00672                         {
00673                           section_type = s_public;
00674                           fprintfi_filtered (level + 2, stream, "public\n");
00675                         }
00676                     }
00677 
00678                   print_spaces_filtered (level + 4, stream);
00679                   if (TYPE_FN_FIELD_STATIC_P (f, j))
00680                     fprintf_filtered (stream, "static ");
00681                   if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
00682                     {
00683                       /* Keep GDB from crashing here.  */
00684                       fprintf_filtered (stream, "<undefined type> %s;\n",
00685                                         TYPE_FN_FIELD_PHYSNAME (f, j));
00686                       break;
00687                     }
00688 
00689                   if (is_constructor)
00690                     {
00691                       fprintf_filtered (stream, "constructor ");
00692                     }
00693                   else if (is_destructor)
00694                     {
00695                       fprintf_filtered (stream, "destructor  ");
00696                     }
00697                   else if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
00698                            && TYPE_CODE (TYPE_TARGET_TYPE (
00699                                 TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
00700                     {
00701                       fprintf_filtered (stream, "function  ");
00702                     }
00703                   else
00704                     {
00705                       fprintf_filtered (stream, "procedure ");
00706                     }
00707                   /* This does not work, no idea why !!  */
00708 
00709                   pascal_type_print_method_args (physname,
00710                                                  method_name,
00711                                                  stream);
00712 
00713                   if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
00714                       && TYPE_CODE (TYPE_TARGET_TYPE (
00715                            TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
00716                     {
00717                       fputs_filtered (" : ", stream);
00718                       type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
00719                                   "", stream, -1);
00720                     }
00721                   if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
00722                     fprintf_filtered (stream, "; virtual");
00723 
00724                   fprintf_filtered (stream, ";\n");
00725                 }
00726             }
00727           fprintfi_filtered (level, stream, "end");
00728         }
00729       break;
00730 
00731     case TYPE_CODE_ENUM:
00732       if (TYPE_TAG_NAME (type) != NULL)
00733         {
00734           fputs_filtered (TYPE_TAG_NAME (type), stream);
00735           if (show > 0)
00736             fputs_filtered (" ", stream);
00737         }
00738       /* enum is just defined by
00739          type enume_name = (enum_member1,enum_member2,...)  */
00740       fprintf_filtered (stream, " = ");
00741       wrap_here ("    ");
00742       if (show < 0)
00743         {
00744           /* If we just printed a tag name, no need to print anything else.  */
00745           if (TYPE_TAG_NAME (type) == NULL)
00746             fprintf_filtered (stream, "(...)");
00747         }
00748       else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
00749         {
00750           fprintf_filtered (stream, "(");
00751           len = TYPE_NFIELDS (type);
00752           lastval = 0;
00753           for (i = 0; i < len; i++)
00754             {
00755               QUIT;
00756               if (i)
00757                 fprintf_filtered (stream, ", ");
00758               wrap_here ("    ");
00759               fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
00760               if (lastval != TYPE_FIELD_ENUMVAL (type, i))
00761                 {
00762                   fprintf_filtered (stream,
00763                                     " := %s",
00764                                     plongest (TYPE_FIELD_ENUMVAL (type, i)));
00765                   lastval = TYPE_FIELD_ENUMVAL (type, i);
00766                 }
00767               lastval++;
00768             }
00769           fprintf_filtered (stream, ")");
00770         }
00771       break;
00772 
00773     case TYPE_CODE_VOID:
00774       fprintf_filtered (stream, "void");
00775       break;
00776 
00777     case TYPE_CODE_UNDEF:
00778       fprintf_filtered (stream, "record <unknown>");
00779       break;
00780 
00781     case TYPE_CODE_ERROR:
00782       fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
00783       break;
00784 
00785       /* this probably does not work for enums.  */
00786     case TYPE_CODE_RANGE:
00787       {
00788         struct type *target = TYPE_TARGET_TYPE (type);
00789 
00790         print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
00791         fputs_filtered ("..", stream);
00792         print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
00793       }
00794       break;
00795 
00796     case TYPE_CODE_SET:
00797       fputs_filtered ("set of ", stream);
00798       pascal_print_type (TYPE_INDEX_TYPE (type), "", stream,
00799                          show - 1, level, flags);
00800       break;
00801 
00802     case TYPE_CODE_STRING:
00803       fputs_filtered ("String", stream);
00804       break;
00805 
00806     default:
00807       /* Handle types not explicitly handled by the other cases,
00808          such as fundamental types.  For these, just print whatever
00809          the type name is, as recorded in the type itself.  If there
00810          is no type name, then complain.  */
00811       if (TYPE_NAME (type) != NULL)
00812         {
00813           fputs_filtered (TYPE_NAME (type), stream);
00814         }
00815       else
00816         {
00817           /* At least for dump_symtab, it is important that this not be
00818              an error ().  */
00819           fprintf_filtered (stream, "<invalid unnamed pascal type code %d>",
00820                             TYPE_CODE (type));
00821         }
00822       break;
00823     }
00824 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines