1 /* Support for printing Chill types for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991, 2000 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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 #include "bfd.h" /* Binary File Description */
26 #include "expression.h"
35 #include "typeprint.h"
37 #include "gdb_string.h"
40 static void chill_type_print_base (struct type
*, struct ui_file
*, int, int);
43 chill_print_type (type
, varstring
, stream
, show
, level
)
46 struct ui_file
*stream
;
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
)
73 struct ui_file
*stream
;
79 struct type
*index_type
;
80 struct type
*range_type
;
89 fputs_filtered ("<type unknown>", stream
);
93 /* When SHOW is zero or less, and there is a valid type name, then always
94 just print the type name directly from the type. */
96 if ((show
<= 0) && (TYPE_NAME (type
) != NULL
))
98 fputs_filtered (TYPE_NAME (type
), stream
);
102 if (TYPE_CODE (type
) != TYPE_CODE_TYPEDEF
)
103 CHECK_TYPEDEF (type
);
105 switch (TYPE_CODE (type
))
107 case TYPE_CODE_TYPEDEF
:
108 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, 0, level
);
111 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_VOID
)
113 fprintf_filtered (stream
,
114 TYPE_NAME (type
) ? TYPE_NAME (type
) : "PTR");
117 fprintf_filtered (stream
, "REF ");
118 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, 0, level
);
122 /* FIXME: we should probably just print the TYPE_NAME, in case
123 anyone ever fixes the compiler to give us the real names
124 in the presence of the chill equivalent of typedef (assuming
126 fprintf_filtered (stream
,
127 TYPE_NAME (type
) ? TYPE_NAME (type
) : "BOOL");
130 case TYPE_CODE_ARRAY
:
131 fputs_filtered ("ARRAY (", stream
);
132 range_type
= TYPE_FIELD_TYPE (type
, 0);
133 if (TYPE_CODE (range_type
) != TYPE_CODE_RANGE
)
134 chill_print_type (range_type
, "", stream
, 0, level
);
137 index_type
= TYPE_TARGET_TYPE (range_type
);
138 low_bound
= TYPE_FIELD_BITPOS (range_type
, 0);
139 high_bound
= TYPE_FIELD_BITPOS (range_type
, 1);
140 print_type_scalar (index_type
, low_bound
, stream
);
141 fputs_filtered (":", stream
);
142 print_type_scalar (index_type
, high_bound
, stream
);
144 fputs_filtered (") ", stream
);
145 chill_print_type (TYPE_TARGET_TYPE (type
), "", stream
, 0, level
);
148 case TYPE_CODE_BITSTRING
:
149 fprintf_filtered (stream
, "BOOLS (%d)",
150 TYPE_FIELD_BITPOS (TYPE_FIELD_TYPE (type
, 0), 1) + 1);
154 fputs_filtered ("POWERSET ", stream
);
155 chill_print_type (TYPE_INDEX_TYPE (type
), "", stream
,
159 case TYPE_CODE_STRING
:
160 range_type
= TYPE_FIELD_TYPE (type
, 0);
161 index_type
= TYPE_TARGET_TYPE (range_type
);
162 high_bound
= TYPE_FIELD_BITPOS (range_type
, 1);
163 fputs_filtered ("CHARS (", stream
);
164 print_type_scalar (index_type
, high_bound
+ 1, stream
);
165 fputs_filtered (")", stream
);
168 case TYPE_CODE_MEMBER
:
169 fprintf_filtered (stream
, "MEMBER ");
170 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, 0, level
);
173 fprintf_filtered (stream
, "/*LOC*/ ");
174 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
177 fprintf_filtered (stream
, "PROC (");
178 len
= TYPE_NFIELDS (type
);
179 for (i
= 0; i
< len
; i
++)
181 struct type
*param_type
= TYPE_FIELD_TYPE (type
, i
);
184 fputs_filtered (", ", stream
);
187 if (TYPE_CODE (param_type
) == TYPE_CODE_REF
)
189 chill_type_print_base (TYPE_TARGET_TYPE (param_type
),
191 fputs_filtered (" LOC", stream
);
194 chill_type_print_base (param_type
, stream
, show
, level
);
196 fprintf_filtered (stream
, ")");
197 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) != TYPE_CODE_VOID
)
199 fputs_filtered (" RETURNS (", stream
);
200 chill_type_print_base (TYPE_TARGET_TYPE (type
), stream
, 0, level
);
201 fputs_filtered (")", stream
);
205 case TYPE_CODE_STRUCT
:
206 if (chill_varying_type (type
))
208 chill_type_print_base (TYPE_FIELD_TYPE (type
, 1),
210 fputs_filtered (" VARYING", stream
);
214 fprintf_filtered (stream
, "STRUCT ");
216 fprintf_filtered (stream
, "(\n");
217 if ((TYPE_NFIELDS (type
) == 0) && (TYPE_NFN_FIELDS (type
) == 0))
219 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
221 fprintfi_filtered (level
+ 4, stream
, "<incomplete type>\n");
225 fprintfi_filtered (level
+ 4, stream
, "<no data fields>\n");
230 len
= TYPE_NFIELDS (type
);
231 for (i
= TYPE_N_BASECLASSES (type
); i
< len
; i
++)
233 struct type
*field_type
= TYPE_FIELD_TYPE (type
, i
);
235 print_spaces_filtered (level
+ 4, stream
);
236 if (TYPE_CODE (field_type
) == TYPE_CODE_UNION
)
238 int j
; /* variant number */
239 fputs_filtered ("CASE OF\n", stream
);
240 for (j
= 0; j
< TYPE_NFIELDS (field_type
); j
++)
242 int k
; /* variant field index */
243 struct type
*variant_type
244 = TYPE_FIELD_TYPE (field_type
, j
);
245 int var_len
= TYPE_NFIELDS (variant_type
);
246 print_spaces_filtered (level
+ 4, stream
);
247 if (strcmp (TYPE_FIELD_NAME (field_type
, j
),
249 fputs_filtered ("ELSE\n", stream
);
251 fputs_filtered (":\n", stream
);
252 if (TYPE_CODE (variant_type
) != TYPE_CODE_STRUCT
)
253 error ("variant record confusion");
254 for (k
= 0; k
< var_len
; k
++)
256 print_spaces_filtered (level
+ 8, stream
);
257 chill_print_type (TYPE_FIELD_TYPE (variant_type
, k
),
258 TYPE_FIELD_NAME (variant_type
, k
),
259 stream
, show
- 1, level
+ 8);
260 if (k
< (var_len
- 1))
261 fputs_filtered (",", stream
);
262 fputs_filtered ("\n", stream
);
265 print_spaces_filtered (level
+ 4, stream
);
266 fputs_filtered ("ESAC", stream
);
269 chill_print_type (field_type
,
270 TYPE_FIELD_NAME (type
, i
),
271 stream
, show
- 1, level
+ 4);
274 fputs_filtered (",", stream
);
276 fputs_filtered ("\n", stream
);
279 fprintfi_filtered (level
, stream
, ")");
283 case TYPE_CODE_RANGE
:
285 struct type
*target
= TYPE_TARGET_TYPE (type
);
286 if (target
&& TYPE_NAME (target
))
287 fputs_filtered (TYPE_NAME (target
), stream
);
289 fputs_filtered ("RANGE", stream
);
291 target
= builtin_type_long
;
292 fputs_filtered (" (", stream
);
293 print_type_scalar (target
, TYPE_LOW_BOUND (type
), stream
);
294 fputs_filtered (":", stream
);
295 print_type_scalar (target
, TYPE_HIGH_BOUND (type
), stream
);
296 fputs_filtered (")", stream
);
302 register int lastval
= 0;
303 fprintf_filtered (stream
, "SET (");
304 len
= TYPE_NFIELDS (type
);
305 for (i
= 0; i
< len
; i
++)
309 fprintf_filtered (stream
, ", ");
311 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
312 if (lastval
!= TYPE_FIELD_BITPOS (type
, i
))
314 fprintf_filtered (stream
, " = %d", TYPE_FIELD_BITPOS (type
, i
));
315 lastval
= TYPE_FIELD_BITPOS (type
, i
);
319 fprintf_filtered (stream
, ")");
324 case TYPE_CODE_UNDEF
:
325 case TYPE_CODE_ERROR
:
326 case TYPE_CODE_UNION
:
327 case TYPE_CODE_METHOD
:
328 error ("missing language support in chill_type_print_base");
333 /* Handle types not explicitly handled by the other cases,
334 such as fundamental types. For these, just print whatever
335 the type name is, as recorded in the type itself. If there
336 is no type name, then complain. */
338 if (TYPE_NAME (type
) != NULL
)
340 fputs_filtered (TYPE_NAME (type
), stream
);
344 error ("Unrecognized type code (%d) in symbol table.",
This page took 0.035214 seconds and 4 git commands to generate.