* c-typeprint.c (c_type_print_varspec_prefix,
[deliverable/binutils-gdb.git] / gdb / c-typeprint.c
1 /* Support for printing C and C++ types for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include "defs.h"
21 #include "obstack.h"
22 #include "bfd.h" /* Binary File Description */
23 #include "symtab.h"
24 #include "gdbtypes.h"
25 #include "expression.h"
26 #include "value.h"
27 #include "gdbcore.h"
28 #include "target.h"
29 #include "command.h"
30 #include "gdbcmd.h"
31 #include "language.h"
32 #include "demangle.h"
33 #include "c-lang.h"
34 #include "typeprint.h"
35
36 #include <string.h>
37 #include <errno.h>
38
39 static void
40 c_type_print_args PARAMS ((struct type *, GDB_FILE *));
41
42 static void
43 c_type_print_varspec_suffix PARAMS ((struct type *, GDB_FILE *, int, int, int));
44
45 static void
46 cp_type_print_derivation_info PARAMS ((GDB_FILE *, struct type *));
47
48 void
49 c_type_print_varspec_prefix PARAMS ((struct type *, GDB_FILE *, int, int));
50
51 void
52 c_type_print_base PARAMS ((struct type *, GDB_FILE *, int, int));
53
54 \f
55 /* Print a description of a type in the format of a
56 typedef for the current language.
57 NEW is the new name for a type TYPE. */
58
59 void
60 c_typedef_print (type, new, stream)
61 struct type *type;
62 struct symbol *new;
63 GDB_FILE *stream;
64 {
65 switch (current_language->la_language)
66 {
67 #ifdef _LANG_c
68 case language_c:
69 case language_cplus:
70 fprintf_filtered(stream, "typedef ");
71 type_print(type,"",stream,0);
72 if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0
73 || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)))
74 fprintf_filtered(stream, " %s", SYMBOL_SOURCE_NAME(new));
75 break;
76 #endif
77 #ifdef _LANG_m2
78 case language_m2:
79 fprintf_filtered(stream, "TYPE ");
80 if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
81 !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
82 fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
83 else
84 fprintf_filtered(stream, "<builtin> = ");
85 type_print(type,"",stream,0);
86 break;
87 #endif
88 #ifdef _LANG_chill
89 case language_chill:
90 fprintf_filtered(stream, "SYNMODE ");
91 if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
92 !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
93 fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
94 else
95 fprintf_filtered(stream, "<builtin> = ");
96 type_print(type,"",stream,0);
97 break;
98 #endif
99 default:
100 error("Language not supported.");
101 }
102 fprintf_filtered(stream, ";\n");
103 }
104
105
106 /* LEVEL is the depth to indent lines by. */
107
108 void
109 c_print_type (type, varstring, stream, show, level)
110 struct type *type;
111 char *varstring;
112 GDB_FILE *stream;
113 int show;
114 int level;
115 {
116 register enum type_code code;
117 int demangled_args;
118
119 c_type_print_base (type, stream, show, level);
120 code = TYPE_CODE (type);
121 if ((varstring != NULL && *varstring != '\0')
122 ||
123 /* Need a space if going to print stars or brackets;
124 but not if we will print just a type name. */
125 ((show > 0 || TYPE_NAME (type) == 0)
126 &&
127 (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
128 || code == TYPE_CODE_METHOD
129 || code == TYPE_CODE_ARRAY
130 || code == TYPE_CODE_MEMBER
131 || code == TYPE_CODE_REF)))
132 fputs_filtered (" ", stream);
133 c_type_print_varspec_prefix (type, stream, show, 0);
134
135 fputs_filtered (varstring, stream);
136
137 /* For demangled function names, we have the arglist as part of the name,
138 so don't print an additional pair of ()'s */
139
140 demangled_args = strchr(varstring, '(') != NULL;
141 c_type_print_varspec_suffix (type, stream, show, 0, demangled_args);
142
143 }
144
145 /* Print the C++ method arguments ARGS to the file STREAM. */
146
147 void
148 cp_type_print_method_args (args, prefix, varstring, staticp, stream)
149 struct type **args;
150 char *prefix;
151 char *varstring;
152 int staticp;
153 GDB_FILE *stream;
154 {
155 int i;
156
157 fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
158 fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
159 fputs_filtered (" (", stream);
160 if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
161 {
162 i = !staticp; /* skip the class variable */
163 while (1)
164 {
165 type_print (args[i++], "", stream, 0);
166 if (!args[i])
167 {
168 fprintf_filtered (stream, " ...");
169 break;
170 }
171 else if (args[i]->code != TYPE_CODE_VOID)
172 {
173 fprintf_filtered (stream, ", ");
174 }
175 else break;
176 }
177 }
178 fprintf_filtered (stream, ")");
179 }
180
181 /* If TYPE is a derived type, then print out derivation information.
182 Print only the actual base classes of this type, not the base classes
183 of the base classes. I.E. for the derivation hierarchy:
184
185 class A { int a; };
186 class B : public A {int b; };
187 class C : public B {int c; };
188
189 Print the type of class C as:
190
191 class C : public B {
192 int c;
193 }
194
195 Not as the following (like gdb used to), which is not legal C++ syntax for
196 derived types and may be confused with the multiple inheritance form:
197
198 class C : public B : public A {
199 int c;
200 }
201
202 In general, gdb should try to print the types as closely as possible to
203 the form that they appear in the source code. */
204
205 static void
206 cp_type_print_derivation_info (stream, type)
207 GDB_FILE *stream;
208 struct type *type;
209 {
210 char *name;
211 int i;
212
213 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
214 {
215 fputs_filtered (i == 0 ? ": " : ", ", stream);
216 fprintf_filtered (stream, "%s%s ",
217 BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private",
218 BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : "");
219 name = type_name_no_tag (TYPE_BASECLASS (type, i));
220 fprintf_filtered (stream, "%s", name ? name : "(null)");
221 }
222 if (i > 0)
223 {
224 fputs_filtered (" ", stream);
225 }
226 }
227
228 /* Print any asterisks or open-parentheses needed before the
229 variable name (to describe its type).
230
231 On outermost call, pass 0 for PASSED_A_PTR.
232 On outermost call, SHOW > 0 means should ignore
233 any typename for TYPE and show its details.
234 SHOW is always zero on recursive calls. */
235
236 void
237 c_type_print_varspec_prefix (type, stream, show, passed_a_ptr)
238 struct type *type;
239 GDB_FILE *stream;
240 int show;
241 int passed_a_ptr;
242 {
243 char *name;
244 if (type == 0)
245 return;
246
247 if (TYPE_NAME (type) && show <= 0)
248 return;
249
250 QUIT;
251
252 switch (TYPE_CODE (type))
253 {
254 case TYPE_CODE_PTR:
255 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
256 fprintf_filtered (stream, "*");
257 break;
258
259 case TYPE_CODE_MEMBER:
260 if (passed_a_ptr)
261 fprintf_filtered (stream, "(");
262 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
263 fprintf_filtered (stream, " ");
264 name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
265 if (name)
266 fputs_filtered (name, stream);
267 else
268 c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
269 fprintf_filtered (stream, "::");
270 break;
271
272 case TYPE_CODE_METHOD:
273 if (passed_a_ptr)
274 fprintf_unfiltered (stream, "(");
275 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
276 if (passed_a_ptr)
277 {
278 fprintf_filtered (stream, " ");
279 c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
280 fprintf_filtered (stream, "::");
281 }
282 break;
283
284 case TYPE_CODE_REF:
285 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
286 fprintf_filtered (stream, "&");
287 break;
288
289 case TYPE_CODE_FUNC:
290 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
291 if (passed_a_ptr)
292 fprintf_filtered (stream, "(");
293 break;
294
295 case TYPE_CODE_ARRAY:
296 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
297 if (passed_a_ptr)
298 fprintf_filtered (stream, "(");
299 break;
300
301 case TYPE_CODE_UNDEF:
302 case TYPE_CODE_STRUCT:
303 case TYPE_CODE_UNION:
304 case TYPE_CODE_ENUM:
305 case TYPE_CODE_INT:
306 case TYPE_CODE_FLT:
307 case TYPE_CODE_VOID:
308 case TYPE_CODE_ERROR:
309 case TYPE_CODE_CHAR:
310 case TYPE_CODE_BOOL:
311 case TYPE_CODE_SET:
312 case TYPE_CODE_RANGE:
313 case TYPE_CODE_STRING:
314 case TYPE_CODE_BITSTRING:
315 case TYPE_CODE_COMPLEX:
316 case TYPE_CODE_LITERAL_COMPLEX:
317 case TYPE_CODE_LITERAL_STRING:
318 /* These types need no prefix. They are listed here so that
319 gcc -Wall will reveal any types that haven't been handled. */
320 break;
321 }
322 }
323
324 static void
325 c_type_print_args (type, stream)
326 struct type *type;
327 GDB_FILE *stream;
328 {
329 int i;
330 struct type **args;
331
332 fprintf_filtered (stream, "(");
333 args = TYPE_ARG_TYPES (type);
334 if (args != NULL)
335 {
336 if (args[1] == NULL)
337 {
338 fprintf_filtered (stream, "...");
339 }
340 else
341 {
342 for (i = 1;
343 args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
344 i++)
345 {
346 c_print_type (args[i], "", stream, -1, 0);
347 if (args[i+1] == NULL)
348 {
349 fprintf_filtered (stream, "...");
350 }
351 else if (args[i+1]->code != TYPE_CODE_VOID)
352 {
353 fprintf_filtered (stream, ",");
354 wrap_here (" ");
355 }
356 }
357 }
358 }
359 fprintf_filtered (stream, ")");
360 }
361
362 /* Print any array sizes, function arguments or close parentheses
363 needed after the variable name (to describe its type).
364 Args work like c_type_print_varspec_prefix. */
365
366 static void
367 c_type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args)
368 struct type *type;
369 GDB_FILE *stream;
370 int show;
371 int passed_a_ptr;
372 int demangled_args;
373 {
374 if (type == 0)
375 return;
376
377 if (TYPE_NAME (type) && show <= 0)
378 return;
379
380 QUIT;
381
382 switch (TYPE_CODE (type))
383 {
384 case TYPE_CODE_ARRAY:
385 if (passed_a_ptr)
386 fprintf_filtered (stream, ")");
387
388 fprintf_filtered (stream, "[");
389 if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
390 fprintf_filtered (stream, "%d",
391 (TYPE_LENGTH (type)
392 / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
393 fprintf_filtered (stream, "]");
394
395 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
396 break;
397
398 case TYPE_CODE_MEMBER:
399 if (passed_a_ptr)
400 fprintf_filtered (stream, ")");
401 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
402 break;
403
404 case TYPE_CODE_METHOD:
405 if (passed_a_ptr)
406 fprintf_filtered (stream, ")");
407 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
408 if (passed_a_ptr)
409 {
410 c_type_print_args (type, stream);
411 }
412 break;
413
414 case TYPE_CODE_PTR:
415 case TYPE_CODE_REF:
416 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
417 break;
418
419 case TYPE_CODE_FUNC:
420 if (passed_a_ptr)
421 fprintf_filtered (stream, ")");
422 if (!demangled_args)
423 fprintf_filtered (stream, "()");
424 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
425 passed_a_ptr, 0);
426 break;
427
428 case TYPE_CODE_UNDEF:
429 case TYPE_CODE_STRUCT:
430 case TYPE_CODE_UNION:
431 case TYPE_CODE_ENUM:
432 case TYPE_CODE_INT:
433 case TYPE_CODE_FLT:
434 case TYPE_CODE_VOID:
435 case TYPE_CODE_ERROR:
436 case TYPE_CODE_CHAR:
437 case TYPE_CODE_BOOL:
438 case TYPE_CODE_SET:
439 case TYPE_CODE_RANGE:
440 case TYPE_CODE_STRING:
441 case TYPE_CODE_BITSTRING:
442 case TYPE_CODE_COMPLEX:
443 case TYPE_CODE_LITERAL_COMPLEX:
444 case TYPE_CODE_LITERAL_STRING:
445 /* These types do not need a suffix. They are listed so that
446 gcc -Wall will report types that may not have been considered. */
447 break;
448 }
449 }
450
451 /* Print the name of the type (or the ultimate pointer target,
452 function value or array element), or the description of a
453 structure or union.
454
455 SHOW positive means print details about the type (e.g. enum values),
456 and print structure elements passing SHOW - 1 for show.
457 SHOW negative means just print the type name or struct tag if there is one.
458 If there is no name, print something sensible but concise like
459 "struct {...}".
460 SHOW zero means just print the type name or struct tag if there is one.
461 If there is no name, print something sensible but not as concise like
462 "struct {int x; int y;}".
463
464 LEVEL is the number of spaces to indent by.
465 We increase it for some recursive calls. */
466
467 void
468 c_type_print_base (type, stream, show, level)
469 struct type *type;
470 GDB_FILE *stream;
471 int show;
472 int level;
473 {
474 register int i;
475 register int len;
476 register int lastval;
477 char *mangled_name;
478 char *demangled_name;
479 enum {s_none, s_public, s_private, s_protected} section_type;
480 QUIT;
481
482 wrap_here (" ");
483 if (type == NULL)
484 {
485 fputs_filtered ("<type unknown>", stream);
486 return;
487 }
488
489 /* When SHOW is zero or less, and there is a valid type name, then always
490 just print the type name directly from the type. */
491 /* If we have "typedef struct foo {. . .} bar;" do we want to print it
492 as "struct foo" or as "bar"? Pick the latter, because C++ folk tend
493 to expect things like "class5 *foo" rather than "struct class5 *foo". */
494
495 if (show <= 0
496 && TYPE_NAME (type) != NULL)
497 {
498 fputs_filtered (TYPE_NAME (type), stream);
499 return;
500 }
501
502 check_stub_type (type);
503
504 switch (TYPE_CODE (type))
505 {
506 case TYPE_CODE_ARRAY:
507 case TYPE_CODE_PTR:
508 case TYPE_CODE_MEMBER:
509 case TYPE_CODE_REF:
510 case TYPE_CODE_FUNC:
511 case TYPE_CODE_METHOD:
512 c_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
513 break;
514
515 case TYPE_CODE_STRUCT:
516 if (HAVE_CPLUS_STRUCT (type))
517 {
518 fprintf_filtered (stream, "class ");
519 }
520 else
521 {
522 fprintf_filtered (stream, "struct ");
523 }
524 goto struct_union;
525
526 case TYPE_CODE_UNION:
527 fprintf_filtered (stream, "union ");
528
529 struct_union:
530 if (TYPE_TAG_NAME (type) != NULL)
531 {
532 fputs_filtered (TYPE_TAG_NAME (type), stream);
533 if (show > 0)
534 fputs_filtered (" ", stream);
535 }
536 wrap_here (" ");
537 if (show < 0)
538 {
539 /* If we just printed a tag name, no need to print anything else. */
540 if (TYPE_TAG_NAME (type) == NULL)
541 fprintf_filtered (stream, "{...}");
542 }
543 else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
544 {
545 cp_type_print_derivation_info (stream, type);
546
547 fprintf_filtered (stream, "{\n");
548 if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
549 {
550 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
551 fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
552 else
553 fprintfi_filtered (level + 4, stream, "<no data fields>\n");
554 }
555
556 /* Start off with no specific section type, so we can print
557 one for the first field we find, and use that section type
558 thereafter until we find another type. */
559
560 section_type = s_none;
561
562 /* If there is a base class for this type,
563 do not print the field that it occupies. */
564
565 len = TYPE_NFIELDS (type);
566 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
567 {
568 QUIT;
569 /* Don't print out virtual function table. */
570 if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER &&
571 !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5))
572 continue;
573
574 /* If this is a C++ class we can print the various C++ section
575 labels. */
576
577 if (HAVE_CPLUS_STRUCT (type))
578 {
579 if (TYPE_FIELD_PROTECTED (type, i))
580 {
581 if (section_type != s_protected)
582 {
583 section_type = s_protected;
584 fprintfi_filtered (level + 2, stream,
585 "protected:\n");
586 }
587 }
588 else if (TYPE_FIELD_PRIVATE (type, i))
589 {
590 if (section_type != s_private)
591 {
592 section_type = s_private;
593 fprintfi_filtered (level + 2, stream, "private:\n");
594 }
595 }
596 else
597 {
598 if (section_type != s_public)
599 {
600 section_type = s_public;
601 fprintfi_filtered (level + 2, stream, "public:\n");
602 }
603 }
604 }
605
606 print_spaces_filtered (level + 4, stream);
607 if (TYPE_FIELD_STATIC (type, i))
608 {
609 fprintf_filtered (stream, "static ");
610 }
611 c_print_type (TYPE_FIELD_TYPE (type, i),
612 TYPE_FIELD_NAME (type, i),
613 stream, show - 1, level + 4);
614 if (!TYPE_FIELD_STATIC (type, i)
615 && TYPE_FIELD_PACKED (type, i))
616 {
617 /* It is a bitfield. This code does not attempt
618 to look at the bitpos and reconstruct filler,
619 unnamed fields. This would lead to misleading
620 results if the compiler does not put out fields
621 for such things (I don't know what it does). */
622 fprintf_filtered (stream, " : %d",
623 TYPE_FIELD_BITSIZE (type, i));
624 }
625 fprintf_filtered (stream, ";\n");
626 }
627
628 /* If there are both fields and methods, put a space between. */
629 len = TYPE_NFN_FIELDS (type);
630 if (len && section_type != s_none)
631 fprintf_filtered (stream, "\n");
632
633 /* C++: print out the methods */
634
635 for (i = 0; i < len; i++)
636 {
637 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
638 int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
639 char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
640 char *name = type_name_no_tag (type);
641 int is_constructor = name && STREQ(method_name, name);
642 for (j = 0; j < len2; j++)
643 {
644 QUIT;
645 if (TYPE_FN_FIELD_PROTECTED (f, j))
646 {
647 if (section_type != s_protected)
648 {
649 section_type = s_protected;
650 fprintfi_filtered (level + 2, stream,
651 "protected:\n");
652 }
653 }
654 else if (TYPE_FN_FIELD_PRIVATE (f, j))
655 {
656 if (section_type != s_private)
657 {
658 section_type = s_private;
659 fprintfi_filtered (level + 2, stream, "private:\n");
660 }
661 }
662 else
663 {
664 if (section_type != s_public)
665 {
666 section_type = s_public;
667 fprintfi_filtered (level + 2, stream, "public:\n");
668 }
669 }
670
671 print_spaces_filtered (level + 4, stream);
672 if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
673 fprintf_filtered (stream, "virtual ");
674 else if (TYPE_FN_FIELD_STATIC_P (f, j))
675 fprintf_filtered (stream, "static ");
676 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
677 {
678 /* Keep GDB from crashing here. */
679 fprintf_unfiltered (stream, "<undefined type> %s;\n",
680 TYPE_FN_FIELD_PHYSNAME (f, j));
681 break;
682 }
683 else if (!is_constructor)
684 {
685 type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
686 "", stream, 0);
687 fputs_filtered (" ", stream);
688 }
689 if (TYPE_FN_FIELD_STUB (f, j))
690 {
691 /* Build something we can demangle. */
692 mangled_name = gdb_mangle_name (type, i, j);
693 demangled_name =
694 cplus_demangle (mangled_name,
695 DMGL_ANSI | DMGL_PARAMS);
696 if (demangled_name == NULL)
697 fprintf_filtered (stream, "<badly mangled name %s>",
698 mangled_name);
699 else
700 {
701 char *demangled_no_class =
702 strchr (demangled_name, ':');
703
704 if (demangled_no_class == NULL)
705 demangled_no_class = demangled_name;
706 else
707 {
708 if (*++demangled_no_class == ':')
709 ++demangled_no_class;
710 }
711 fputs_filtered (demangled_no_class, stream);
712 free (demangled_name);
713 }
714 free (mangled_name);
715 }
716 else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
717 && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
718 cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j) + 1,
719 "~", method_name, 0, stream);
720 else
721 cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j), "",
722 method_name,
723 TYPE_FN_FIELD_STATIC_P (f, j),
724 stream);
725
726 fprintf_filtered (stream, ";\n");
727 }
728 }
729
730 fprintfi_filtered (level, stream, "}");
731 }
732 break;
733
734 case TYPE_CODE_ENUM:
735 fprintf_filtered (stream, "enum ");
736 if (TYPE_TAG_NAME (type) != NULL)
737 {
738 fputs_filtered (TYPE_TAG_NAME (type), stream);
739 if (show > 0)
740 fputs_filtered (" ", stream);
741 }
742
743 wrap_here (" ");
744 if (show < 0)
745 {
746 /* If we just printed a tag name, no need to print anything else. */
747 if (TYPE_TAG_NAME (type) == NULL)
748 fprintf_filtered (stream, "{...}");
749 }
750 else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
751 {
752 fprintf_filtered (stream, "{");
753 len = TYPE_NFIELDS (type);
754 lastval = 0;
755 for (i = 0; i < len; i++)
756 {
757 QUIT;
758 if (i) fprintf_filtered (stream, ", ");
759 wrap_here (" ");
760 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
761 if (lastval != TYPE_FIELD_BITPOS (type, i))
762 {
763 fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
764 lastval = TYPE_FIELD_BITPOS (type, i);
765 }
766 lastval++;
767 }
768 fprintf_filtered (stream, "}");
769 }
770 break;
771
772 case TYPE_CODE_VOID:
773 fprintf_filtered (stream, "void");
774 break;
775
776 case TYPE_CODE_UNDEF:
777 fprintf_filtered (stream, "struct <unknown>");
778 break;
779
780 case TYPE_CODE_ERROR:
781 fprintf_filtered (stream, "<unknown type>");
782 break;
783
784 case TYPE_CODE_RANGE:
785 /* This should not occur */
786 fprintf_filtered (stream, "<range type>");
787 break;
788
789 default:
790 /* Handle types not explicitly handled by the other cases,
791 such as fundamental types. For these, just print whatever
792 the type name is, as recorded in the type itself. If there
793 is no type name, then complain. */
794 if (TYPE_NAME (type) != NULL)
795 {
796 fputs_filtered (TYPE_NAME (type), stream);
797 }
798 else
799 {
800 /* At least for dump_symtab, it is important that this not be
801 an error (). */
802 fprintf_filtered (stream, "<invalid type code %d>",
803 TYPE_CODE (type));
804 }
805 break;
806 }
807 }
808
This page took 0.045239 seconds and 5 git commands to generate.