1 /* Support for printing Chill types for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
22 #include "bfd.h" /* Binary File Description */
25 #include "expression.h"
34 #include "typeprint.h"
40 chill_type_print_base
PARAMS ((struct type
*, GDB_FILE
*, int, int));
43 chill_print_type (type
, varstring
, stream
, show
, level
)
50 if (varstring
!= NULL
&& *varstring
!= '\0')
52 fputs_filtered (varstring
, stream
);
53 fputs_filtered (" ", stream
);
55 chill_type_print_base (type
, stream
, show
, level
);
58 /* Print the name of the type (or the ultimate pointer target,
59 function value or array element).
61 SHOW nonzero means don't print this type as just its name;
62 show its real definition even if it has a name.
63 SHOW zero means print just typename or tag if there is one
64 SHOW negative means abbreviate structure elements.
65 SHOW is decremented for printing of structure elements.
67 LEVEL is the depth to indent by.
68 We increase it for some recursive calls. */
71 chill_type_print_base (type
, stream
, show
, level
)
80 struct type
*index_type
;
81 struct type
*range_type
;
90 fputs_filtered ("<type unknown>", stream
);
94 /* When SHOW is zero or less, and there is a valid type name, then always
95 just print the type name directly from the type. */
97 if ((show
<= 0) && (TYPE_NAME (type
) != NULL
))
99 fputs_filtered (TYPE_NAME (type
), stream
);
103 check_stub_type (type
);
105 switch (TYPE_CODE (type
))
108 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_VOID
)
110 fprintf_filtered (stream
, "PTR");
113 fprintf_filtered (stream
, "REF ");
114 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
117 case TYPE_CODE_ARRAY
:
118 range_type
= TYPE_FIELD_TYPE (type
, 0);
119 index_type
= TYPE_TARGET_TYPE (range_type
);
120 low_bound
= TYPE_FIELD_BITPOS (range_type
, 0);
121 high_bound
= TYPE_FIELD_BITPOS (range_type
, 1);
122 fputs_filtered ("ARRAY (", stream
);
123 print_type_scalar (index_type
, low_bound
, stream
);
124 fputs_filtered (":", stream
);
125 print_type_scalar (index_type
, high_bound
, stream
);
126 fputs_filtered (") ", stream
);
127 chill_print_type (TYPE_TARGET_TYPE (type
), "", stream
, show
, level
);
130 case TYPE_CODE_STRING
:
131 range_type
= TYPE_FIELD_TYPE (type
, 0);
132 index_type
= TYPE_TARGET_TYPE (range_type
);
133 high_bound
= TYPE_FIELD_BITPOS (range_type
, 1);
134 fputs_filtered ("CHAR (", stream
);
135 print_type_scalar (index_type
, high_bound
+ 1, stream
);
136 fputs_filtered (")", stream
);
139 case TYPE_CODE_MEMBER
:
140 fprintf_filtered (stream
, "MEMBER ");
141 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
144 fprintf_filtered (stream
, "/*LOC*/ ");
145 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
148 fprintf_filtered (stream
, "PROC (?)");
149 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
152 case TYPE_CODE_STRUCT
:
153 fprintf_filtered (stream
, "STRUCT ");
154 if ((name
= type_name_no_tag (type
)) != NULL
)
156 fputs_filtered (name
, stream
);
157 fputs_filtered (" ", stream
);
162 fprintf_filtered (stream
, "(...)");
166 fprintf_filtered (stream
, "(\n");
167 if ((TYPE_NFIELDS (type
) == 0) && (TYPE_NFN_FIELDS (type
) == 0))
169 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
171 fprintfi_filtered (level
+ 4, stream
, "<incomplete type>\n");
175 fprintfi_filtered (level
+ 4, stream
, "<no data fields>\n");
180 len
= TYPE_NFIELDS (type
);
181 for (i
= TYPE_N_BASECLASSES (type
); i
< len
; i
++)
184 print_spaces_filtered (level
+ 4, stream
);
185 chill_print_type (TYPE_FIELD_TYPE (type
, i
),
186 TYPE_FIELD_NAME (type
, i
),
187 stream
, show
- 1, level
+ 4);
190 fputs_filtered (",", stream
);
192 fputs_filtered ("\n", stream
);
195 fprintfi_filtered (level
, stream
, ")");
200 case TYPE_CODE_UNDEF
:
201 case TYPE_CODE_ERROR
:
202 case TYPE_CODE_RANGE
:
204 case TYPE_CODE_UNION
:
205 case TYPE_CODE_METHOD
:
206 error ("missing language support in chill_type_print_base");
211 /* Handle types not explicitly handled by the other cases,
212 such as fundamental types. For these, just print whatever
213 the type name is, as recorded in the type itself. If there
214 is no type name, then complain. */
216 if (TYPE_NAME (type
) != NULL
)
218 fputs_filtered (TYPE_NAME (type
), stream
);
222 error ("Unrecognized type code (%d) in symbol table.",