15796c8dcSSimon Schubert /* Support for printing Pascal types for GDB, the GNU debugger.
2*ef5ccd6cSJohn Marino Copyright (C) 2000-2013 Free Software Foundation, Inc.
35796c8dcSSimon Schubert
45796c8dcSSimon Schubert This file is part of GDB.
55796c8dcSSimon Schubert
65796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify
75796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by
85796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or
95796c8dcSSimon Schubert (at your option) any later version.
105796c8dcSSimon Schubert
115796c8dcSSimon Schubert This program is distributed in the hope that it will be useful,
125796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of
135796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145796c8dcSSimon Schubert GNU General Public License for more details.
155796c8dcSSimon Schubert
165796c8dcSSimon Schubert You should have received a copy of the GNU General Public License
175796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */
185796c8dcSSimon Schubert
195796c8dcSSimon Schubert /* This file is derived from p-typeprint.c */
205796c8dcSSimon Schubert
215796c8dcSSimon Schubert #include "defs.h"
225796c8dcSSimon Schubert #include "gdb_obstack.h"
235796c8dcSSimon Schubert #include "bfd.h" /* Binary File Description */
245796c8dcSSimon Schubert #include "symtab.h"
255796c8dcSSimon Schubert #include "gdbtypes.h"
265796c8dcSSimon Schubert #include "expression.h"
275796c8dcSSimon Schubert #include "value.h"
285796c8dcSSimon Schubert #include "gdbcore.h"
295796c8dcSSimon Schubert #include "target.h"
305796c8dcSSimon Schubert #include "language.h"
315796c8dcSSimon Schubert #include "p-lang.h"
325796c8dcSSimon Schubert #include "typeprint.h"
33a45ae5f8SJohn Marino #include "gdb-demangle.h"
345796c8dcSSimon Schubert #include "gdb_string.h"
355796c8dcSSimon Schubert #include <errno.h>
365796c8dcSSimon Schubert #include <ctype.h>
375796c8dcSSimon Schubert
38c50c785cSJohn Marino static void pascal_type_print_varspec_suffix (struct type *, struct ui_file *,
39*ef5ccd6cSJohn Marino int, int, int,
40*ef5ccd6cSJohn Marino const struct type_print_options *);
415796c8dcSSimon Schubert
42c50c785cSJohn Marino static void pascal_type_print_derivation_info (struct ui_file *,
43c50c785cSJohn Marino struct type *);
445796c8dcSSimon Schubert
455796c8dcSSimon Schubert
465796c8dcSSimon Schubert
475796c8dcSSimon Schubert /* LEVEL is the depth to indent lines by. */
485796c8dcSSimon Schubert
495796c8dcSSimon Schubert void
pascal_print_type(struct type * type,const char * varstring,struct ui_file * stream,int show,int level,const struct type_print_options * flags)50cf7f2e2dSJohn Marino pascal_print_type (struct type *type, const char *varstring,
51*ef5ccd6cSJohn Marino struct ui_file *stream, int show, int level,
52*ef5ccd6cSJohn Marino const struct type_print_options *flags)
535796c8dcSSimon Schubert {
545796c8dcSSimon Schubert enum type_code code;
555796c8dcSSimon Schubert int demangled_args;
565796c8dcSSimon Schubert
575796c8dcSSimon Schubert code = TYPE_CODE (type);
585796c8dcSSimon Schubert
595796c8dcSSimon Schubert if (show > 0)
605796c8dcSSimon Schubert CHECK_TYPEDEF (type);
615796c8dcSSimon Schubert
625796c8dcSSimon Schubert if ((code == TYPE_CODE_FUNC
635796c8dcSSimon Schubert || code == TYPE_CODE_METHOD))
645796c8dcSSimon Schubert {
65*ef5ccd6cSJohn Marino pascal_type_print_varspec_prefix (type, stream, show, 0, flags);
665796c8dcSSimon Schubert }
675796c8dcSSimon Schubert /* first the name */
685796c8dcSSimon Schubert fputs_filtered (varstring, stream);
695796c8dcSSimon Schubert
705796c8dcSSimon Schubert if ((varstring != NULL && *varstring != '\0')
715796c8dcSSimon Schubert && !(code == TYPE_CODE_FUNC
725796c8dcSSimon Schubert || code == TYPE_CODE_METHOD))
735796c8dcSSimon Schubert {
745796c8dcSSimon Schubert fputs_filtered (" : ", stream);
755796c8dcSSimon Schubert }
765796c8dcSSimon Schubert
775796c8dcSSimon Schubert if (!(code == TYPE_CODE_FUNC
785796c8dcSSimon Schubert || code == TYPE_CODE_METHOD))
795796c8dcSSimon Schubert {
80*ef5ccd6cSJohn Marino pascal_type_print_varspec_prefix (type, stream, show, 0, flags);
815796c8dcSSimon Schubert }
825796c8dcSSimon Schubert
83*ef5ccd6cSJohn Marino pascal_type_print_base (type, stream, show, level, flags);
845796c8dcSSimon Schubert /* For demangled function names, we have the arglist as part of the name,
85c50c785cSJohn Marino so don't print an additional pair of ()'s. */
865796c8dcSSimon Schubert
875796c8dcSSimon Schubert demangled_args = varstring ? strchr (varstring, '(') != NULL : 0;
88*ef5ccd6cSJohn Marino pascal_type_print_varspec_suffix (type, stream, show, 0, demangled_args,
89*ef5ccd6cSJohn Marino flags);
905796c8dcSSimon Schubert
915796c8dcSSimon Schubert }
925796c8dcSSimon Schubert
935796c8dcSSimon Schubert /* Print a typedef using Pascal syntax. TYPE is the underlying type.
945796c8dcSSimon Schubert NEW_SYMBOL is the symbol naming the type. STREAM is the stream on
955796c8dcSSimon Schubert which to print. */
965796c8dcSSimon Schubert
975796c8dcSSimon Schubert void
pascal_print_typedef(struct type * type,struct symbol * new_symbol,struct ui_file * stream)985796c8dcSSimon Schubert pascal_print_typedef (struct type *type, struct symbol *new_symbol,
995796c8dcSSimon Schubert struct ui_file *stream)
1005796c8dcSSimon Schubert {
1015796c8dcSSimon Schubert CHECK_TYPEDEF (type);
1025796c8dcSSimon Schubert fprintf_filtered (stream, "type ");
1035796c8dcSSimon Schubert fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new_symbol));
1045796c8dcSSimon Schubert type_print (type, "", stream, 0);
1055796c8dcSSimon Schubert fprintf_filtered (stream, ";\n");
1065796c8dcSSimon Schubert }
1075796c8dcSSimon Schubert
1085796c8dcSSimon Schubert /* If TYPE is a derived type, then print out derivation information.
1095796c8dcSSimon Schubert Print only the actual base classes of this type, not the base classes
110c50c785cSJohn Marino of the base classes. I.e. for the derivation hierarchy:
1115796c8dcSSimon Schubert
1125796c8dcSSimon Schubert class A { int a; };
1135796c8dcSSimon Schubert class B : public A {int b; };
1145796c8dcSSimon Schubert class C : public B {int c; };
1155796c8dcSSimon Schubert
1165796c8dcSSimon Schubert Print the type of class C as:
1175796c8dcSSimon Schubert
1185796c8dcSSimon Schubert class C : public B {
1195796c8dcSSimon Schubert int c;
1205796c8dcSSimon Schubert }
1215796c8dcSSimon Schubert
1225796c8dcSSimon Schubert Not as the following (like gdb used to), which is not legal C++ syntax for
1235796c8dcSSimon Schubert derived types and may be confused with the multiple inheritance form:
1245796c8dcSSimon Schubert
1255796c8dcSSimon Schubert class C : public B : public A {
1265796c8dcSSimon Schubert int c;
1275796c8dcSSimon Schubert }
1285796c8dcSSimon Schubert
1295796c8dcSSimon Schubert In general, gdb should try to print the types as closely as possible to
1305796c8dcSSimon Schubert the form that they appear in the source code. */
1315796c8dcSSimon Schubert
1325796c8dcSSimon Schubert static void
pascal_type_print_derivation_info(struct ui_file * stream,struct type * type)1335796c8dcSSimon Schubert pascal_type_print_derivation_info (struct ui_file *stream, struct type *type)
1345796c8dcSSimon Schubert {
135*ef5ccd6cSJohn Marino const char *name;
1365796c8dcSSimon Schubert int i;
1375796c8dcSSimon Schubert
1385796c8dcSSimon Schubert for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
1395796c8dcSSimon Schubert {
1405796c8dcSSimon Schubert fputs_filtered (i == 0 ? ": " : ", ", stream);
1415796c8dcSSimon Schubert fprintf_filtered (stream, "%s%s ",
1425796c8dcSSimon Schubert BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private",
1435796c8dcSSimon Schubert BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
1445796c8dcSSimon Schubert name = type_name_no_tag (TYPE_BASECLASS (type, i));
1455796c8dcSSimon Schubert fprintf_filtered (stream, "%s", name ? name : "(null)");
1465796c8dcSSimon Schubert }
1475796c8dcSSimon Schubert if (i > 0)
1485796c8dcSSimon Schubert {
1495796c8dcSSimon Schubert fputs_filtered (" ", stream);
1505796c8dcSSimon Schubert }
1515796c8dcSSimon Schubert }
1525796c8dcSSimon Schubert
1535796c8dcSSimon Schubert /* Print the Pascal method arguments ARGS to the file STREAM. */
1545796c8dcSSimon Schubert
1555796c8dcSSimon Schubert void
pascal_type_print_method_args(const char * physname,const char * methodname,struct ui_file * stream)156a45ae5f8SJohn Marino pascal_type_print_method_args (const char *physname, const char *methodname,
1575796c8dcSSimon Schubert struct ui_file *stream)
1585796c8dcSSimon Schubert {
1595796c8dcSSimon Schubert int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
1605796c8dcSSimon Schubert int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
1615796c8dcSSimon Schubert
1625796c8dcSSimon Schubert if (is_constructor || is_destructor)
1635796c8dcSSimon Schubert {
1645796c8dcSSimon Schubert physname += 6;
1655796c8dcSSimon Schubert }
1665796c8dcSSimon Schubert
1675796c8dcSSimon Schubert fputs_filtered (methodname, stream);
1685796c8dcSSimon Schubert
1695796c8dcSSimon Schubert if (physname && (*physname != 0))
1705796c8dcSSimon Schubert {
1715796c8dcSSimon Schubert fputs_filtered (" (", stream);
172c50c785cSJohn Marino /* We must demangle this. */
1735796c8dcSSimon Schubert while (isdigit (physname[0]))
1745796c8dcSSimon Schubert {
175c50c785cSJohn Marino int len = 0;
176a45ae5f8SJohn Marino int i, j;
177c50c785cSJohn Marino char *argname;
178c50c785cSJohn Marino
1795796c8dcSSimon Schubert while (isdigit (physname[len]))
1805796c8dcSSimon Schubert {
1815796c8dcSSimon Schubert len++;
1825796c8dcSSimon Schubert }
1835796c8dcSSimon Schubert i = strtol (physname, &argname, 0);
1845796c8dcSSimon Schubert physname += len;
185a45ae5f8SJohn Marino
186a45ae5f8SJohn Marino for (j = 0; j < i; ++j)
187a45ae5f8SJohn Marino fputc_filtered (physname[j], stream);
188a45ae5f8SJohn Marino
1895796c8dcSSimon Schubert physname += i;
1905796c8dcSSimon Schubert if (physname[0] != 0)
1915796c8dcSSimon Schubert {
1925796c8dcSSimon Schubert fputs_filtered (", ", stream);
1935796c8dcSSimon Schubert }
1945796c8dcSSimon Schubert }
1955796c8dcSSimon Schubert fputs_filtered (")", stream);
1965796c8dcSSimon Schubert }
1975796c8dcSSimon Schubert }
1985796c8dcSSimon Schubert
1995796c8dcSSimon Schubert /* Print any asterisks or open-parentheses needed before the
2005796c8dcSSimon Schubert variable name (to describe its type).
2015796c8dcSSimon Schubert
2025796c8dcSSimon Schubert On outermost call, pass 0 for PASSED_A_PTR.
2035796c8dcSSimon Schubert On outermost call, SHOW > 0 means should ignore
2045796c8dcSSimon Schubert any typename for TYPE and show its details.
2055796c8dcSSimon Schubert SHOW is always zero on recursive calls. */
2065796c8dcSSimon Schubert
2075796c8dcSSimon Schubert void
pascal_type_print_varspec_prefix(struct type * type,struct ui_file * stream,int show,int passed_a_ptr,const struct type_print_options * flags)2085796c8dcSSimon Schubert pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
209*ef5ccd6cSJohn Marino int show, int passed_a_ptr,
210*ef5ccd6cSJohn Marino const struct type_print_options *flags)
2115796c8dcSSimon Schubert {
2125796c8dcSSimon Schubert if (type == 0)
2135796c8dcSSimon Schubert return;
2145796c8dcSSimon Schubert
2155796c8dcSSimon Schubert if (TYPE_NAME (type) && show <= 0)
2165796c8dcSSimon Schubert return;
2175796c8dcSSimon Schubert
2185796c8dcSSimon Schubert QUIT;
2195796c8dcSSimon Schubert
2205796c8dcSSimon Schubert switch (TYPE_CODE (type))
2215796c8dcSSimon Schubert {
2225796c8dcSSimon Schubert case TYPE_CODE_PTR:
2235796c8dcSSimon Schubert fprintf_filtered (stream, "^");
224*ef5ccd6cSJohn Marino pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1,
225*ef5ccd6cSJohn Marino flags);
226c50c785cSJohn Marino break; /* Pointer should be handled normally
227c50c785cSJohn Marino in pascal. */
2285796c8dcSSimon Schubert
2295796c8dcSSimon Schubert case TYPE_CODE_METHOD:
2305796c8dcSSimon Schubert if (passed_a_ptr)
2315796c8dcSSimon Schubert fprintf_filtered (stream, "(");
2325796c8dcSSimon Schubert if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
2335796c8dcSSimon Schubert {
2345796c8dcSSimon Schubert fprintf_filtered (stream, "function ");
2355796c8dcSSimon Schubert }
2365796c8dcSSimon Schubert else
2375796c8dcSSimon Schubert {
2385796c8dcSSimon Schubert fprintf_filtered (stream, "procedure ");
2395796c8dcSSimon Schubert }
2405796c8dcSSimon Schubert
2415796c8dcSSimon Schubert if (passed_a_ptr)
2425796c8dcSSimon Schubert {
2435796c8dcSSimon Schubert fprintf_filtered (stream, " ");
244c50c785cSJohn Marino pascal_type_print_base (TYPE_DOMAIN_TYPE (type),
245*ef5ccd6cSJohn Marino stream, 0, passed_a_ptr, flags);
2465796c8dcSSimon Schubert fprintf_filtered (stream, "::");
2475796c8dcSSimon Schubert }
2485796c8dcSSimon Schubert break;
2495796c8dcSSimon Schubert
2505796c8dcSSimon Schubert case TYPE_CODE_REF:
251*ef5ccd6cSJohn Marino pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1,
252*ef5ccd6cSJohn Marino flags);
2535796c8dcSSimon Schubert fprintf_filtered (stream, "&");
2545796c8dcSSimon Schubert break;
2555796c8dcSSimon Schubert
2565796c8dcSSimon Schubert case TYPE_CODE_FUNC:
2575796c8dcSSimon Schubert if (passed_a_ptr)
2585796c8dcSSimon Schubert fprintf_filtered (stream, "(");
2595796c8dcSSimon Schubert
2605796c8dcSSimon Schubert if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
2615796c8dcSSimon Schubert {
2625796c8dcSSimon Schubert fprintf_filtered (stream, "function ");
2635796c8dcSSimon Schubert }
2645796c8dcSSimon Schubert else
2655796c8dcSSimon Schubert {
2665796c8dcSSimon Schubert fprintf_filtered (stream, "procedure ");
2675796c8dcSSimon Schubert }
2685796c8dcSSimon Schubert
2695796c8dcSSimon Schubert break;
2705796c8dcSSimon Schubert
2715796c8dcSSimon Schubert case TYPE_CODE_ARRAY:
2725796c8dcSSimon Schubert if (passed_a_ptr)
2735796c8dcSSimon Schubert fprintf_filtered (stream, "(");
2745796c8dcSSimon Schubert fprintf_filtered (stream, "array ");
2755796c8dcSSimon Schubert if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
2765796c8dcSSimon Schubert && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
277cf7f2e2dSJohn Marino fprintf_filtered (stream, "[%s..%s] ",
278cf7f2e2dSJohn Marino plongest (TYPE_ARRAY_LOWER_BOUND_VALUE (type)),
279cf7f2e2dSJohn Marino plongest (TYPE_ARRAY_UPPER_BOUND_VALUE (type)));
2805796c8dcSSimon Schubert fprintf_filtered (stream, "of ");
2815796c8dcSSimon Schubert break;
2825796c8dcSSimon Schubert
2835796c8dcSSimon Schubert case TYPE_CODE_UNDEF:
2845796c8dcSSimon Schubert case TYPE_CODE_STRUCT:
2855796c8dcSSimon Schubert case TYPE_CODE_UNION:
2865796c8dcSSimon Schubert case TYPE_CODE_ENUM:
2875796c8dcSSimon Schubert case TYPE_CODE_INT:
2885796c8dcSSimon Schubert case TYPE_CODE_FLT:
2895796c8dcSSimon Schubert case TYPE_CODE_VOID:
2905796c8dcSSimon Schubert case TYPE_CODE_ERROR:
2915796c8dcSSimon Schubert case TYPE_CODE_CHAR:
2925796c8dcSSimon Schubert case TYPE_CODE_BOOL:
2935796c8dcSSimon Schubert case TYPE_CODE_SET:
2945796c8dcSSimon Schubert case TYPE_CODE_RANGE:
2955796c8dcSSimon Schubert case TYPE_CODE_STRING:
2965796c8dcSSimon Schubert case TYPE_CODE_COMPLEX:
2975796c8dcSSimon Schubert case TYPE_CODE_TYPEDEF:
2985796c8dcSSimon Schubert /* These types need no prefix. They are listed here so that
2995796c8dcSSimon Schubert gcc -Wall will reveal any types that haven't been handled. */
3005796c8dcSSimon Schubert break;
3015796c8dcSSimon Schubert default:
3025796c8dcSSimon Schubert error (_("type not handled in pascal_type_print_varspec_prefix()"));
3035796c8dcSSimon Schubert break;
3045796c8dcSSimon Schubert }
3055796c8dcSSimon Schubert }
3065796c8dcSSimon Schubert
3075796c8dcSSimon Schubert static void
pascal_print_func_args(struct type * type,struct ui_file * stream,const struct type_print_options * flags)308*ef5ccd6cSJohn Marino pascal_print_func_args (struct type *type, struct ui_file *stream,
309*ef5ccd6cSJohn Marino const struct type_print_options *flags)
3105796c8dcSSimon Schubert {
3115796c8dcSSimon Schubert int i, len = TYPE_NFIELDS (type);
312cf7f2e2dSJohn Marino
3135796c8dcSSimon Schubert if (len)
3145796c8dcSSimon Schubert {
3155796c8dcSSimon Schubert fprintf_filtered (stream, "(");
3165796c8dcSSimon Schubert }
3175796c8dcSSimon Schubert for (i = 0; i < len; i++)
3185796c8dcSSimon Schubert {
3195796c8dcSSimon Schubert if (i > 0)
3205796c8dcSSimon Schubert {
3215796c8dcSSimon Schubert fputs_filtered (", ", stream);
3225796c8dcSSimon Schubert wrap_here (" ");
3235796c8dcSSimon Schubert }
324c50c785cSJohn Marino /* Can we find if it is a var parameter ??
3255796c8dcSSimon Schubert if ( TYPE_FIELD(type, i) == )
3265796c8dcSSimon Schubert {
3275796c8dcSSimon Schubert fprintf_filtered (stream, "var ");
3285796c8dcSSimon Schubert } */
329c50c785cSJohn Marino pascal_print_type (TYPE_FIELD_TYPE (type, i), "" /* TYPE_FIELD_NAME
330c50c785cSJohn Marino seems invalid! */
331*ef5ccd6cSJohn Marino ,stream, -1, 0, flags);
3325796c8dcSSimon Schubert }
3335796c8dcSSimon Schubert if (len)
3345796c8dcSSimon Schubert {
3355796c8dcSSimon Schubert fprintf_filtered (stream, ")");
3365796c8dcSSimon Schubert }
3375796c8dcSSimon Schubert }
3385796c8dcSSimon Schubert
3395796c8dcSSimon Schubert /* Print any array sizes, function arguments or close parentheses
3405796c8dcSSimon Schubert needed after the variable name (to describe its type).
3415796c8dcSSimon Schubert Args work like pascal_type_print_varspec_prefix. */
3425796c8dcSSimon Schubert
3435796c8dcSSimon Schubert static void
pascal_type_print_varspec_suffix(struct type * type,struct ui_file * stream,int show,int passed_a_ptr,int demangled_args,const struct type_print_options * flags)3445796c8dcSSimon Schubert pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
3455796c8dcSSimon Schubert int show, int passed_a_ptr,
346*ef5ccd6cSJohn Marino int demangled_args,
347*ef5ccd6cSJohn Marino const struct type_print_options *flags)
3485796c8dcSSimon Schubert {
3495796c8dcSSimon Schubert if (type == 0)
3505796c8dcSSimon Schubert return;
3515796c8dcSSimon Schubert
3525796c8dcSSimon Schubert if (TYPE_NAME (type) && show <= 0)
3535796c8dcSSimon Schubert return;
3545796c8dcSSimon Schubert
3555796c8dcSSimon Schubert QUIT;
3565796c8dcSSimon Schubert
3575796c8dcSSimon Schubert switch (TYPE_CODE (type))
3585796c8dcSSimon Schubert {
3595796c8dcSSimon Schubert case TYPE_CODE_ARRAY:
3605796c8dcSSimon Schubert if (passed_a_ptr)
3615796c8dcSSimon Schubert fprintf_filtered (stream, ")");
3625796c8dcSSimon Schubert break;
3635796c8dcSSimon Schubert
3645796c8dcSSimon Schubert case TYPE_CODE_METHOD:
3655796c8dcSSimon Schubert if (passed_a_ptr)
3665796c8dcSSimon Schubert fprintf_filtered (stream, ")");
3675796c8dcSSimon Schubert pascal_type_print_method_args ("",
3685796c8dcSSimon Schubert "",
3695796c8dcSSimon Schubert stream);
3705796c8dcSSimon Schubert if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
3715796c8dcSSimon Schubert {
3725796c8dcSSimon Schubert fprintf_filtered (stream, " : ");
373c50c785cSJohn Marino pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
374*ef5ccd6cSJohn Marino stream, 0, 0, flags);
375*ef5ccd6cSJohn Marino pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
376*ef5ccd6cSJohn Marino flags);
3775796c8dcSSimon Schubert pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
378*ef5ccd6cSJohn Marino passed_a_ptr, 0, flags);
3795796c8dcSSimon Schubert }
3805796c8dcSSimon Schubert break;
3815796c8dcSSimon Schubert
3825796c8dcSSimon Schubert case TYPE_CODE_PTR:
3835796c8dcSSimon Schubert case TYPE_CODE_REF:
384c50c785cSJohn Marino pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type),
385*ef5ccd6cSJohn Marino stream, 0, 1, 0, flags);
3865796c8dcSSimon Schubert break;
3875796c8dcSSimon Schubert
3885796c8dcSSimon Schubert case TYPE_CODE_FUNC:
3895796c8dcSSimon Schubert if (passed_a_ptr)
3905796c8dcSSimon Schubert fprintf_filtered (stream, ")");
3915796c8dcSSimon Schubert if (!demangled_args)
392*ef5ccd6cSJohn Marino pascal_print_func_args (type, stream, flags);
3935796c8dcSSimon Schubert if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
3945796c8dcSSimon Schubert {
3955796c8dcSSimon Schubert fprintf_filtered (stream, " : ");
396c50c785cSJohn Marino pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
397*ef5ccd6cSJohn Marino stream, 0, 0, flags);
398*ef5ccd6cSJohn Marino pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
399*ef5ccd6cSJohn Marino flags);
4005796c8dcSSimon Schubert pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
401*ef5ccd6cSJohn Marino passed_a_ptr, 0, flags);
4025796c8dcSSimon Schubert }
4035796c8dcSSimon Schubert break;
4045796c8dcSSimon Schubert
4055796c8dcSSimon Schubert case TYPE_CODE_UNDEF:
4065796c8dcSSimon Schubert case TYPE_CODE_STRUCT:
4075796c8dcSSimon Schubert case TYPE_CODE_UNION:
4085796c8dcSSimon Schubert case TYPE_CODE_ENUM:
4095796c8dcSSimon Schubert case TYPE_CODE_INT:
4105796c8dcSSimon Schubert case TYPE_CODE_FLT:
4115796c8dcSSimon Schubert case TYPE_CODE_VOID:
4125796c8dcSSimon Schubert case TYPE_CODE_ERROR:
4135796c8dcSSimon Schubert case TYPE_CODE_CHAR:
4145796c8dcSSimon Schubert case TYPE_CODE_BOOL:
4155796c8dcSSimon Schubert case TYPE_CODE_SET:
4165796c8dcSSimon Schubert case TYPE_CODE_RANGE:
4175796c8dcSSimon Schubert case TYPE_CODE_STRING:
4185796c8dcSSimon Schubert case TYPE_CODE_COMPLEX:
4195796c8dcSSimon Schubert case TYPE_CODE_TYPEDEF:
4205796c8dcSSimon Schubert /* These types do not need a suffix. They are listed so that
4215796c8dcSSimon Schubert gcc -Wall will report types that may not have been considered. */
4225796c8dcSSimon Schubert break;
4235796c8dcSSimon Schubert default:
4245796c8dcSSimon Schubert error (_("type not handled in pascal_type_print_varspec_suffix()"));
4255796c8dcSSimon Schubert break;
4265796c8dcSSimon Schubert }
4275796c8dcSSimon Schubert }
4285796c8dcSSimon Schubert
4295796c8dcSSimon Schubert /* Print the name of the type (or the ultimate pointer target,
4305796c8dcSSimon Schubert function value or array element), or the description of a
4315796c8dcSSimon Schubert structure or union.
4325796c8dcSSimon Schubert
4335796c8dcSSimon Schubert SHOW positive means print details about the type (e.g. enum values),
4345796c8dcSSimon Schubert and print structure elements passing SHOW - 1 for show.
4355796c8dcSSimon Schubert SHOW negative means just print the type name or struct tag if there is one.
4365796c8dcSSimon Schubert If there is no name, print something sensible but concise like
4375796c8dcSSimon Schubert "struct {...}".
4385796c8dcSSimon Schubert SHOW zero means just print the type name or struct tag if there is one.
4395796c8dcSSimon Schubert If there is no name, print something sensible but not as concise like
4405796c8dcSSimon Schubert "struct {int x; int y;}".
4415796c8dcSSimon Schubert
4425796c8dcSSimon Schubert LEVEL is the number of spaces to indent by.
4435796c8dcSSimon Schubert We increase it for some recursive calls. */
4445796c8dcSSimon Schubert
4455796c8dcSSimon Schubert void
pascal_type_print_base(struct type * type,struct ui_file * stream,int show,int level,const struct type_print_options * flags)4465796c8dcSSimon Schubert pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
447*ef5ccd6cSJohn Marino int level, const struct type_print_options *flags)
4485796c8dcSSimon Schubert {
4495796c8dcSSimon Schubert int i;
4505796c8dcSSimon Schubert int len;
451*ef5ccd6cSJohn Marino LONGEST lastval;
4525796c8dcSSimon Schubert enum
4535796c8dcSSimon Schubert {
4545796c8dcSSimon Schubert s_none, s_public, s_private, s_protected
4555796c8dcSSimon Schubert }
4565796c8dcSSimon Schubert section_type;
4575796c8dcSSimon Schubert
458cf7f2e2dSJohn Marino QUIT;
4595796c8dcSSimon Schubert wrap_here (" ");
4605796c8dcSSimon Schubert if (type == NULL)
4615796c8dcSSimon Schubert {
4625796c8dcSSimon Schubert fputs_filtered ("<type unknown>", stream);
4635796c8dcSSimon Schubert return;
4645796c8dcSSimon Schubert }
4655796c8dcSSimon Schubert
4665796c8dcSSimon Schubert /* void pointer */
467c50c785cSJohn Marino if ((TYPE_CODE (type) == TYPE_CODE_PTR)
468c50c785cSJohn Marino && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID))
4695796c8dcSSimon Schubert {
4705796c8dcSSimon Schubert fputs_filtered (TYPE_NAME (type) ? TYPE_NAME (type) : "pointer",
4715796c8dcSSimon Schubert stream);
4725796c8dcSSimon Schubert return;
4735796c8dcSSimon Schubert }
4745796c8dcSSimon Schubert /* When SHOW is zero or less, and there is a valid type name, then always
4755796c8dcSSimon Schubert just print the type name directly from the type. */
4765796c8dcSSimon Schubert
4775796c8dcSSimon Schubert if (show <= 0
4785796c8dcSSimon Schubert && TYPE_NAME (type) != NULL)
4795796c8dcSSimon Schubert {
4805796c8dcSSimon Schubert fputs_filtered (TYPE_NAME (type), stream);
4815796c8dcSSimon Schubert return;
4825796c8dcSSimon Schubert }
4835796c8dcSSimon Schubert
4845796c8dcSSimon Schubert CHECK_TYPEDEF (type);
4855796c8dcSSimon Schubert
4865796c8dcSSimon Schubert switch (TYPE_CODE (type))
4875796c8dcSSimon Schubert {
4885796c8dcSSimon Schubert case TYPE_CODE_TYPEDEF:
4895796c8dcSSimon Schubert case TYPE_CODE_PTR:
4905796c8dcSSimon Schubert case TYPE_CODE_REF:
4915796c8dcSSimon Schubert /* case TYPE_CODE_FUNC:
4925796c8dcSSimon Schubert case TYPE_CODE_METHOD: */
493*ef5ccd6cSJohn Marino pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level,
494*ef5ccd6cSJohn Marino flags);
4955796c8dcSSimon Schubert break;
4965796c8dcSSimon Schubert
4975796c8dcSSimon Schubert case TYPE_CODE_ARRAY:
498c50c785cSJohn Marino /* pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
499c50c785cSJohn Marino stream, 0, 0);
500c50c785cSJohn Marino pascal_type_print_base (TYPE_TARGET_TYPE (type),
501c50c785cSJohn Marino stream, show, level);
502c50c785cSJohn Marino pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type),
503c50c785cSJohn Marino stream, 0, 0, 0); */
504*ef5ccd6cSJohn Marino pascal_print_type (TYPE_TARGET_TYPE (type), NULL, stream, 0, 0, flags);
5055796c8dcSSimon Schubert break;
5065796c8dcSSimon Schubert
5075796c8dcSSimon Schubert case TYPE_CODE_FUNC:
5085796c8dcSSimon Schubert case TYPE_CODE_METHOD:
5095796c8dcSSimon Schubert /*
5105796c8dcSSimon Schubert pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
5115796c8dcSSimon Schubert only after args !! */
5125796c8dcSSimon Schubert break;
5135796c8dcSSimon Schubert case TYPE_CODE_STRUCT:
5145796c8dcSSimon Schubert if (TYPE_TAG_NAME (type) != NULL)
5155796c8dcSSimon Schubert {
5165796c8dcSSimon Schubert fputs_filtered (TYPE_TAG_NAME (type), stream);
5175796c8dcSSimon Schubert fputs_filtered (" = ", stream);
5185796c8dcSSimon Schubert }
5195796c8dcSSimon Schubert if (HAVE_CPLUS_STRUCT (type))
5205796c8dcSSimon Schubert {
5215796c8dcSSimon Schubert fprintf_filtered (stream, "class ");
5225796c8dcSSimon Schubert }
5235796c8dcSSimon Schubert else
5245796c8dcSSimon Schubert {
5255796c8dcSSimon Schubert fprintf_filtered (stream, "record ");
5265796c8dcSSimon Schubert }
5275796c8dcSSimon Schubert goto struct_union;
5285796c8dcSSimon Schubert
5295796c8dcSSimon Schubert case TYPE_CODE_UNION:
5305796c8dcSSimon Schubert if (TYPE_TAG_NAME (type) != NULL)
5315796c8dcSSimon Schubert {
5325796c8dcSSimon Schubert fputs_filtered (TYPE_TAG_NAME (type), stream);
5335796c8dcSSimon Schubert fputs_filtered (" = ", stream);
5345796c8dcSSimon Schubert }
5355796c8dcSSimon Schubert fprintf_filtered (stream, "case <?> of ");
5365796c8dcSSimon Schubert
5375796c8dcSSimon Schubert struct_union:
5385796c8dcSSimon Schubert wrap_here (" ");
5395796c8dcSSimon Schubert if (show < 0)
5405796c8dcSSimon Schubert {
5415796c8dcSSimon Schubert /* If we just printed a tag name, no need to print anything else. */
5425796c8dcSSimon Schubert if (TYPE_TAG_NAME (type) == NULL)
5435796c8dcSSimon Schubert fprintf_filtered (stream, "{...}");
5445796c8dcSSimon Schubert }
5455796c8dcSSimon Schubert else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
5465796c8dcSSimon Schubert {
5475796c8dcSSimon Schubert pascal_type_print_derivation_info (stream, type);
5485796c8dcSSimon Schubert
5495796c8dcSSimon Schubert fprintf_filtered (stream, "\n");
5505796c8dcSSimon Schubert if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
5515796c8dcSSimon Schubert {
5525796c8dcSSimon Schubert if (TYPE_STUB (type))
5535796c8dcSSimon Schubert fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
5545796c8dcSSimon Schubert else
5555796c8dcSSimon Schubert fprintfi_filtered (level + 4, stream, "<no data fields>\n");
5565796c8dcSSimon Schubert }
5575796c8dcSSimon Schubert
5585796c8dcSSimon Schubert /* Start off with no specific section type, so we can print
5595796c8dcSSimon Schubert one for the first field we find, and use that section type
5605796c8dcSSimon Schubert thereafter until we find another type. */
5615796c8dcSSimon Schubert
5625796c8dcSSimon Schubert section_type = s_none;
5635796c8dcSSimon Schubert
5645796c8dcSSimon Schubert /* If there is a base class for this type,
5655796c8dcSSimon Schubert do not print the field that it occupies. */
5665796c8dcSSimon Schubert
5675796c8dcSSimon Schubert len = TYPE_NFIELDS (type);
5685796c8dcSSimon Schubert for (i = TYPE_N_BASECLASSES (type); i < len; i++)
5695796c8dcSSimon Schubert {
5705796c8dcSSimon Schubert QUIT;
5715796c8dcSSimon Schubert /* Don't print out virtual function table. */
5725796c8dcSSimon Schubert if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0)
5735796c8dcSSimon Schubert && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
5745796c8dcSSimon Schubert continue;
5755796c8dcSSimon Schubert
5765796c8dcSSimon Schubert /* If this is a pascal object or class we can print the
5775796c8dcSSimon Schubert various section labels. */
5785796c8dcSSimon Schubert
5795796c8dcSSimon Schubert if (HAVE_CPLUS_STRUCT (type))
5805796c8dcSSimon Schubert {
5815796c8dcSSimon Schubert if (TYPE_FIELD_PROTECTED (type, i))
5825796c8dcSSimon Schubert {
5835796c8dcSSimon Schubert if (section_type != s_protected)
5845796c8dcSSimon Schubert {
5855796c8dcSSimon Schubert section_type = s_protected;
5865796c8dcSSimon Schubert fprintfi_filtered (level + 2, stream,
5875796c8dcSSimon Schubert "protected\n");
5885796c8dcSSimon Schubert }
5895796c8dcSSimon Schubert }
5905796c8dcSSimon Schubert else if (TYPE_FIELD_PRIVATE (type, i))
5915796c8dcSSimon Schubert {
5925796c8dcSSimon Schubert if (section_type != s_private)
5935796c8dcSSimon Schubert {
5945796c8dcSSimon Schubert section_type = s_private;
5955796c8dcSSimon Schubert fprintfi_filtered (level + 2, stream, "private\n");
5965796c8dcSSimon Schubert }
5975796c8dcSSimon Schubert }
5985796c8dcSSimon Schubert else
5995796c8dcSSimon Schubert {
6005796c8dcSSimon Schubert if (section_type != s_public)
6015796c8dcSSimon Schubert {
6025796c8dcSSimon Schubert section_type = s_public;
6035796c8dcSSimon Schubert fprintfi_filtered (level + 2, stream, "public\n");
6045796c8dcSSimon Schubert }
6055796c8dcSSimon Schubert }
6065796c8dcSSimon Schubert }
6075796c8dcSSimon Schubert
6085796c8dcSSimon Schubert print_spaces_filtered (level + 4, stream);
6095796c8dcSSimon Schubert if (field_is_static (&TYPE_FIELD (type, i)))
6105796c8dcSSimon Schubert fprintf_filtered (stream, "static ");
6115796c8dcSSimon Schubert pascal_print_type (TYPE_FIELD_TYPE (type, i),
6125796c8dcSSimon Schubert TYPE_FIELD_NAME (type, i),
613*ef5ccd6cSJohn Marino stream, show - 1, level + 4, flags);
6145796c8dcSSimon Schubert if (!field_is_static (&TYPE_FIELD (type, i))
6155796c8dcSSimon Schubert && TYPE_FIELD_PACKED (type, i))
6165796c8dcSSimon Schubert {
6175796c8dcSSimon Schubert /* It is a bitfield. This code does not attempt
6185796c8dcSSimon Schubert to look at the bitpos and reconstruct filler,
6195796c8dcSSimon Schubert unnamed fields. This would lead to misleading
6205796c8dcSSimon Schubert results if the compiler does not put out fields
6215796c8dcSSimon Schubert for such things (I don't know what it does). */
6225796c8dcSSimon Schubert fprintf_filtered (stream, " : %d",
6235796c8dcSSimon Schubert TYPE_FIELD_BITSIZE (type, i));
6245796c8dcSSimon Schubert }
6255796c8dcSSimon Schubert fprintf_filtered (stream, ";\n");
6265796c8dcSSimon Schubert }
6275796c8dcSSimon Schubert
6285796c8dcSSimon Schubert /* If there are both fields and methods, put a space between. */
6295796c8dcSSimon Schubert len = TYPE_NFN_FIELDS (type);
6305796c8dcSSimon Schubert if (len && section_type != s_none)
6315796c8dcSSimon Schubert fprintf_filtered (stream, "\n");
6325796c8dcSSimon Schubert
633c50c785cSJohn Marino /* Object pascal: print out the methods. */
6345796c8dcSSimon Schubert
6355796c8dcSSimon Schubert for (i = 0; i < len; i++)
6365796c8dcSSimon Schubert {
6375796c8dcSSimon Schubert struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
6385796c8dcSSimon Schubert int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
639*ef5ccd6cSJohn Marino const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
640cf7f2e2dSJohn Marino
6415796c8dcSSimon Schubert /* this is GNU C++ specific
6425796c8dcSSimon Schubert how can we know constructor/destructor?
643c50c785cSJohn Marino It might work for GNU pascal. */
6445796c8dcSSimon Schubert for (j = 0; j < len2; j++)
6455796c8dcSSimon Schubert {
646a45ae5f8SJohn Marino const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
6475796c8dcSSimon Schubert
6485796c8dcSSimon Schubert int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
6495796c8dcSSimon Schubert int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
6505796c8dcSSimon Schubert
6515796c8dcSSimon Schubert QUIT;
6525796c8dcSSimon Schubert if (TYPE_FN_FIELD_PROTECTED (f, j))
6535796c8dcSSimon Schubert {
6545796c8dcSSimon Schubert if (section_type != s_protected)
6555796c8dcSSimon Schubert {
6565796c8dcSSimon Schubert section_type = s_protected;
6575796c8dcSSimon Schubert fprintfi_filtered (level + 2, stream,
6585796c8dcSSimon Schubert "protected\n");
6595796c8dcSSimon Schubert }
6605796c8dcSSimon Schubert }
6615796c8dcSSimon Schubert else if (TYPE_FN_FIELD_PRIVATE (f, j))
6625796c8dcSSimon Schubert {
6635796c8dcSSimon Schubert if (section_type != s_private)
6645796c8dcSSimon Schubert {
6655796c8dcSSimon Schubert section_type = s_private;
6665796c8dcSSimon Schubert fprintfi_filtered (level + 2, stream, "private\n");
6675796c8dcSSimon Schubert }
6685796c8dcSSimon Schubert }
6695796c8dcSSimon Schubert else
6705796c8dcSSimon Schubert {
6715796c8dcSSimon Schubert if (section_type != s_public)
6725796c8dcSSimon Schubert {
6735796c8dcSSimon Schubert section_type = s_public;
6745796c8dcSSimon Schubert fprintfi_filtered (level + 2, stream, "public\n");
6755796c8dcSSimon Schubert }
6765796c8dcSSimon Schubert }
6775796c8dcSSimon Schubert
6785796c8dcSSimon Schubert print_spaces_filtered (level + 4, stream);
6795796c8dcSSimon Schubert if (TYPE_FN_FIELD_STATIC_P (f, j))
6805796c8dcSSimon Schubert fprintf_filtered (stream, "static ");
6815796c8dcSSimon Schubert if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
6825796c8dcSSimon Schubert {
6835796c8dcSSimon Schubert /* Keep GDB from crashing here. */
6845796c8dcSSimon Schubert fprintf_filtered (stream, "<undefined type> %s;\n",
6855796c8dcSSimon Schubert TYPE_FN_FIELD_PHYSNAME (f, j));
6865796c8dcSSimon Schubert break;
6875796c8dcSSimon Schubert }
6885796c8dcSSimon Schubert
6895796c8dcSSimon Schubert if (is_constructor)
6905796c8dcSSimon Schubert {
6915796c8dcSSimon Schubert fprintf_filtered (stream, "constructor ");
6925796c8dcSSimon Schubert }
6935796c8dcSSimon Schubert else if (is_destructor)
6945796c8dcSSimon Schubert {
6955796c8dcSSimon Schubert fprintf_filtered (stream, "destructor ");
6965796c8dcSSimon Schubert }
6975796c8dcSSimon Schubert else if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
6985796c8dcSSimon Schubert && TYPE_CODE (TYPE_TARGET_TYPE (
6995796c8dcSSimon Schubert TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
7005796c8dcSSimon Schubert {
7015796c8dcSSimon Schubert fprintf_filtered (stream, "function ");
7025796c8dcSSimon Schubert }
7035796c8dcSSimon Schubert else
7045796c8dcSSimon Schubert {
7055796c8dcSSimon Schubert fprintf_filtered (stream, "procedure ");
7065796c8dcSSimon Schubert }
707c50c785cSJohn Marino /* This does not work, no idea why !! */
7085796c8dcSSimon Schubert
7095796c8dcSSimon Schubert pascal_type_print_method_args (physname,
7105796c8dcSSimon Schubert method_name,
7115796c8dcSSimon Schubert stream);
7125796c8dcSSimon Schubert
7135796c8dcSSimon Schubert if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) != 0
7145796c8dcSSimon Schubert && TYPE_CODE (TYPE_TARGET_TYPE (
7155796c8dcSSimon Schubert TYPE_FN_FIELD_TYPE (f, j))) != TYPE_CODE_VOID)
7165796c8dcSSimon Schubert {
7175796c8dcSSimon Schubert fputs_filtered (" : ", stream);
7185796c8dcSSimon Schubert type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
7195796c8dcSSimon Schubert "", stream, -1);
7205796c8dcSSimon Schubert }
7215796c8dcSSimon Schubert if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
7225796c8dcSSimon Schubert fprintf_filtered (stream, "; virtual");
7235796c8dcSSimon Schubert
7245796c8dcSSimon Schubert fprintf_filtered (stream, ";\n");
7255796c8dcSSimon Schubert }
7265796c8dcSSimon Schubert }
7275796c8dcSSimon Schubert fprintfi_filtered (level, stream, "end");
7285796c8dcSSimon Schubert }
7295796c8dcSSimon Schubert break;
7305796c8dcSSimon Schubert
7315796c8dcSSimon Schubert case TYPE_CODE_ENUM:
7325796c8dcSSimon Schubert if (TYPE_TAG_NAME (type) != NULL)
7335796c8dcSSimon Schubert {
7345796c8dcSSimon Schubert fputs_filtered (TYPE_TAG_NAME (type), stream);
7355796c8dcSSimon Schubert if (show > 0)
7365796c8dcSSimon Schubert fputs_filtered (" ", stream);
7375796c8dcSSimon Schubert }
7385796c8dcSSimon Schubert /* enum is just defined by
7395796c8dcSSimon Schubert type enume_name = (enum_member1,enum_member2,...) */
7405796c8dcSSimon Schubert fprintf_filtered (stream, " = ");
7415796c8dcSSimon Schubert wrap_here (" ");
7425796c8dcSSimon Schubert if (show < 0)
7435796c8dcSSimon Schubert {
7445796c8dcSSimon Schubert /* If we just printed a tag name, no need to print anything else. */
7455796c8dcSSimon Schubert if (TYPE_TAG_NAME (type) == NULL)
7465796c8dcSSimon Schubert fprintf_filtered (stream, "(...)");
7475796c8dcSSimon Schubert }
7485796c8dcSSimon Schubert else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
7495796c8dcSSimon Schubert {
7505796c8dcSSimon Schubert fprintf_filtered (stream, "(");
7515796c8dcSSimon Schubert len = TYPE_NFIELDS (type);
7525796c8dcSSimon Schubert lastval = 0;
7535796c8dcSSimon Schubert for (i = 0; i < len; i++)
7545796c8dcSSimon Schubert {
7555796c8dcSSimon Schubert QUIT;
7565796c8dcSSimon Schubert if (i)
7575796c8dcSSimon Schubert fprintf_filtered (stream, ", ");
7585796c8dcSSimon Schubert wrap_here (" ");
7595796c8dcSSimon Schubert fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
760*ef5ccd6cSJohn Marino if (lastval != TYPE_FIELD_ENUMVAL (type, i))
7615796c8dcSSimon Schubert {
762c50c785cSJohn Marino fprintf_filtered (stream,
763*ef5ccd6cSJohn Marino " := %s",
764*ef5ccd6cSJohn Marino plongest (TYPE_FIELD_ENUMVAL (type, i)));
765*ef5ccd6cSJohn Marino lastval = TYPE_FIELD_ENUMVAL (type, i);
7665796c8dcSSimon Schubert }
7675796c8dcSSimon Schubert lastval++;
7685796c8dcSSimon Schubert }
7695796c8dcSSimon Schubert fprintf_filtered (stream, ")");
7705796c8dcSSimon Schubert }
7715796c8dcSSimon Schubert break;
7725796c8dcSSimon Schubert
7735796c8dcSSimon Schubert case TYPE_CODE_VOID:
7745796c8dcSSimon Schubert fprintf_filtered (stream, "void");
7755796c8dcSSimon Schubert break;
7765796c8dcSSimon Schubert
7775796c8dcSSimon Schubert case TYPE_CODE_UNDEF:
7785796c8dcSSimon Schubert fprintf_filtered (stream, "record <unknown>");
7795796c8dcSSimon Schubert break;
7805796c8dcSSimon Schubert
7815796c8dcSSimon Schubert case TYPE_CODE_ERROR:
782cf7f2e2dSJohn Marino fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
7835796c8dcSSimon Schubert break;
7845796c8dcSSimon Schubert
785c50c785cSJohn Marino /* this probably does not work for enums. */
7865796c8dcSSimon Schubert case TYPE_CODE_RANGE:
7875796c8dcSSimon Schubert {
7885796c8dcSSimon Schubert struct type *target = TYPE_TARGET_TYPE (type);
789cf7f2e2dSJohn Marino
7905796c8dcSSimon Schubert print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
7915796c8dcSSimon Schubert fputs_filtered ("..", stream);
7925796c8dcSSimon Schubert print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
7935796c8dcSSimon Schubert }
7945796c8dcSSimon Schubert break;
7955796c8dcSSimon Schubert
7965796c8dcSSimon Schubert case TYPE_CODE_SET:
7975796c8dcSSimon Schubert fputs_filtered ("set of ", stream);
7985796c8dcSSimon Schubert pascal_print_type (TYPE_INDEX_TYPE (type), "", stream,
799*ef5ccd6cSJohn Marino show - 1, level, flags);
8005796c8dcSSimon Schubert break;
8015796c8dcSSimon Schubert
8025796c8dcSSimon Schubert case TYPE_CODE_STRING:
8035796c8dcSSimon Schubert fputs_filtered ("String", stream);
8045796c8dcSSimon Schubert break;
8055796c8dcSSimon Schubert
8065796c8dcSSimon Schubert default:
8075796c8dcSSimon Schubert /* Handle types not explicitly handled by the other cases,
8085796c8dcSSimon Schubert such as fundamental types. For these, just print whatever
8095796c8dcSSimon Schubert the type name is, as recorded in the type itself. If there
8105796c8dcSSimon Schubert is no type name, then complain. */
8115796c8dcSSimon Schubert if (TYPE_NAME (type) != NULL)
8125796c8dcSSimon Schubert {
8135796c8dcSSimon Schubert fputs_filtered (TYPE_NAME (type), stream);
8145796c8dcSSimon Schubert }
8155796c8dcSSimon Schubert else
8165796c8dcSSimon Schubert {
8175796c8dcSSimon Schubert /* At least for dump_symtab, it is important that this not be
8185796c8dcSSimon Schubert an error (). */
8195796c8dcSSimon Schubert fprintf_filtered (stream, "<invalid unnamed pascal type code %d>",
8205796c8dcSSimon Schubert TYPE_CODE (type));
8215796c8dcSSimon Schubert }
8225796c8dcSSimon Schubert break;
8235796c8dcSSimon Schubert }
8245796c8dcSSimon Schubert }
825