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