1 // OBSOLETE /* Support for printing Chill types for GDB, the GNU debugger.
2 // OBSOLETE Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 2000
3 // OBSOLETE Free Software Foundation, Inc.
5 // OBSOLETE This file is part of GDB.
7 // OBSOLETE This program is free software; you can redistribute it and/or modify
8 // OBSOLETE it under the terms of the GNU General Public License as published by
9 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
10 // OBSOLETE (at your option) any later version.
12 // OBSOLETE This program is distributed in the hope that it will be useful,
13 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // OBSOLETE GNU General Public License for more details.
17 // OBSOLETE You should have received a copy of the GNU General Public License
18 // OBSOLETE along with this program; if not, write to the Free Software
19 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
20 // OBSOLETE Boston, MA 02111-1307, USA. */
22 // OBSOLETE #include "defs.h"
23 // OBSOLETE #include "gdb_obstack.h"
24 // OBSOLETE #include "bfd.h" /* Binary File Description */
25 // OBSOLETE #include "symtab.h"
26 // OBSOLETE #include "gdbtypes.h"
27 // OBSOLETE #include "expression.h"
28 // OBSOLETE #include "value.h"
29 // OBSOLETE #include "gdbcore.h"
30 // OBSOLETE #include "target.h"
31 // OBSOLETE #include "language.h"
32 // OBSOLETE #include "ch-lang.h"
33 // OBSOLETE #include "typeprint.h"
35 // OBSOLETE #include "gdb_string.h"
36 // OBSOLETE #include <errno.h>
38 // OBSOLETE static void chill_type_print_base (struct type *, struct ui_file *, int, int);
41 // OBSOLETE chill_print_type (struct type *type, char *varstring, struct ui_file *stream,
42 // OBSOLETE int show, int level)
44 // OBSOLETE if (varstring != NULL && *varstring != '\0')
46 // OBSOLETE fputs_filtered (varstring, stream);
47 // OBSOLETE fputs_filtered (" ", stream);
49 // OBSOLETE chill_type_print_base (type, stream, show, level);
52 // OBSOLETE /* Print the name of the type (or the ultimate pointer target,
53 // OBSOLETE function value or array element).
55 // OBSOLETE SHOW nonzero means don't print this type as just its name;
56 // OBSOLETE show its real definition even if it has a name.
57 // OBSOLETE SHOW zero means print just typename or tag if there is one
58 // OBSOLETE SHOW negative means abbreviate structure elements.
59 // OBSOLETE SHOW is decremented for printing of structure elements.
61 // OBSOLETE LEVEL is the depth to indent by.
62 // OBSOLETE We increase it for some recursive calls. */
64 // OBSOLETE static void
65 // OBSOLETE chill_type_print_base (struct type *type, struct ui_file *stream, int show,
66 // OBSOLETE int level)
68 // OBSOLETE register int len;
69 // OBSOLETE register int i;
70 // OBSOLETE struct type *index_type;
71 // OBSOLETE struct type *range_type;
72 // OBSOLETE LONGEST low_bound;
73 // OBSOLETE LONGEST high_bound;
77 // OBSOLETE wrap_here (" ");
78 // OBSOLETE if (type == NULL)
80 // OBSOLETE fputs_filtered ("<type unknown>", stream);
84 // OBSOLETE /* When SHOW is zero or less, and there is a valid type name, then always
85 // OBSOLETE just print the type name directly from the type. */
87 // OBSOLETE if ((show <= 0) && (TYPE_NAME (type) != NULL))
89 // OBSOLETE fputs_filtered (TYPE_NAME (type), stream);
93 // OBSOLETE if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
94 // OBSOLETE CHECK_TYPEDEF (type);
96 // OBSOLETE switch (TYPE_CODE (type))
98 // OBSOLETE case TYPE_CODE_TYPEDEF:
99 // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
101 // OBSOLETE case TYPE_CODE_PTR:
102 // OBSOLETE if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
104 // OBSOLETE fprintf_filtered (stream,
105 // OBSOLETE TYPE_NAME (type) ? TYPE_NAME (type) : "PTR");
108 // OBSOLETE fprintf_filtered (stream, "REF ");
109 // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
112 // OBSOLETE case TYPE_CODE_BOOL:
113 // OBSOLETE /* FIXME: we should probably just print the TYPE_NAME, in case
114 // OBSOLETE anyone ever fixes the compiler to give us the real names
115 // OBSOLETE in the presence of the chill equivalent of typedef (assuming
116 // OBSOLETE there is one). */
117 // OBSOLETE fprintf_filtered (stream,
118 // OBSOLETE TYPE_NAME (type) ? TYPE_NAME (type) : "BOOL");
121 // OBSOLETE case TYPE_CODE_ARRAY:
122 // OBSOLETE fputs_filtered ("ARRAY (", stream);
123 // OBSOLETE range_type = TYPE_FIELD_TYPE (type, 0);
124 // OBSOLETE if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
125 // OBSOLETE chill_print_type (range_type, "", stream, 0, level);
128 // OBSOLETE index_type = TYPE_TARGET_TYPE (range_type);
129 // OBSOLETE low_bound = TYPE_FIELD_BITPOS (range_type, 0);
130 // OBSOLETE high_bound = TYPE_FIELD_BITPOS (range_type, 1);
131 // OBSOLETE print_type_scalar (index_type, low_bound, stream);
132 // OBSOLETE fputs_filtered (":", stream);
133 // OBSOLETE print_type_scalar (index_type, high_bound, stream);
135 // OBSOLETE fputs_filtered (") ", stream);
136 // OBSOLETE chill_print_type (TYPE_TARGET_TYPE (type), "", stream, 0, level);
139 // OBSOLETE case TYPE_CODE_BITSTRING:
140 // OBSOLETE fprintf_filtered (stream, "BOOLS (%d)",
141 // OBSOLETE TYPE_FIELD_BITPOS (TYPE_FIELD_TYPE (type, 0), 1) + 1);
144 // OBSOLETE case TYPE_CODE_SET:
145 // OBSOLETE fputs_filtered ("POWERSET ", stream);
146 // OBSOLETE chill_print_type (TYPE_INDEX_TYPE (type), "", stream,
147 // OBSOLETE show - 1, level);
150 // OBSOLETE case TYPE_CODE_STRING:
151 // OBSOLETE range_type = TYPE_FIELD_TYPE (type, 0);
152 // OBSOLETE index_type = TYPE_TARGET_TYPE (range_type);
153 // OBSOLETE high_bound = TYPE_FIELD_BITPOS (range_type, 1);
154 // OBSOLETE fputs_filtered ("CHARS (", stream);
155 // OBSOLETE print_type_scalar (index_type, high_bound + 1, stream);
156 // OBSOLETE fputs_filtered (")", stream);
159 // OBSOLETE case TYPE_CODE_MEMBER:
160 // OBSOLETE fprintf_filtered (stream, "MEMBER ");
161 // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
163 // OBSOLETE case TYPE_CODE_REF:
164 // OBSOLETE fprintf_filtered (stream, "/*LOC*/ ");
165 // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
167 // OBSOLETE case TYPE_CODE_FUNC:
168 // OBSOLETE fprintf_filtered (stream, "PROC (");
169 // OBSOLETE len = TYPE_NFIELDS (type);
170 // OBSOLETE for (i = 0; i < len; i++)
172 // OBSOLETE struct type *param_type = TYPE_FIELD_TYPE (type, i);
173 // OBSOLETE if (i > 0)
175 // OBSOLETE fputs_filtered (", ", stream);
176 // OBSOLETE wrap_here (" ");
178 // OBSOLETE if (TYPE_CODE (param_type) == TYPE_CODE_REF)
180 // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (param_type),
181 // OBSOLETE stream, 0, level);
182 // OBSOLETE fputs_filtered (" LOC", stream);
185 // OBSOLETE chill_type_print_base (param_type, stream, show, level);
187 // OBSOLETE fprintf_filtered (stream, ")");
188 // OBSOLETE if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
190 // OBSOLETE fputs_filtered (" RETURNS (", stream);
191 // OBSOLETE chill_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
192 // OBSOLETE fputs_filtered (")", stream);
196 // OBSOLETE case TYPE_CODE_STRUCT:
197 // OBSOLETE if (chill_varying_type (type))
199 // OBSOLETE chill_type_print_base (TYPE_FIELD_TYPE (type, 1),
200 // OBSOLETE stream, 0, level);
201 // OBSOLETE fputs_filtered (" VARYING", stream);
205 // OBSOLETE fprintf_filtered (stream, "STRUCT ");
207 // OBSOLETE fprintf_filtered (stream, "(\n");
208 // OBSOLETE if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
210 // OBSOLETE if (TYPE_STUB (type))
212 // OBSOLETE fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
216 // OBSOLETE fprintfi_filtered (level + 4, stream, "<no data fields>\n");
221 // OBSOLETE len = TYPE_NFIELDS (type);
222 // OBSOLETE for (i = TYPE_N_BASECLASSES (type); i < len; i++)
224 // OBSOLETE struct type *field_type = TYPE_FIELD_TYPE (type, i);
226 // OBSOLETE print_spaces_filtered (level + 4, stream);
227 // OBSOLETE if (TYPE_CODE (field_type) == TYPE_CODE_UNION)
229 // OBSOLETE int j; /* variant number */
230 // OBSOLETE fputs_filtered ("CASE OF\n", stream);
231 // OBSOLETE for (j = 0; j < TYPE_NFIELDS (field_type); j++)
233 // OBSOLETE int k; /* variant field index */
234 // OBSOLETE struct type *variant_type
235 // OBSOLETE = TYPE_FIELD_TYPE (field_type, j);
236 // OBSOLETE int var_len = TYPE_NFIELDS (variant_type);
237 // OBSOLETE print_spaces_filtered (level + 4, stream);
238 // OBSOLETE if (strcmp (TYPE_FIELD_NAME (field_type, j),
239 // OBSOLETE "else") == 0)
240 // OBSOLETE fputs_filtered ("ELSE\n", stream);
242 // OBSOLETE fputs_filtered (":\n", stream);
243 // OBSOLETE if (TYPE_CODE (variant_type) != TYPE_CODE_STRUCT)
244 // OBSOLETE error ("variant record confusion");
245 // OBSOLETE for (k = 0; k < var_len; k++)
247 // OBSOLETE print_spaces_filtered (level + 8, stream);
248 // OBSOLETE chill_print_type (TYPE_FIELD_TYPE (variant_type, k),
249 // OBSOLETE TYPE_FIELD_NAME (variant_type, k),
250 // OBSOLETE stream, show - 1, level + 8);
251 // OBSOLETE if (k < (var_len - 1))
252 // OBSOLETE fputs_filtered (",", stream);
253 // OBSOLETE fputs_filtered ("\n", stream);
256 // OBSOLETE print_spaces_filtered (level + 4, stream);
257 // OBSOLETE fputs_filtered ("ESAC", stream);
260 // OBSOLETE chill_print_type (field_type,
261 // OBSOLETE TYPE_FIELD_NAME (type, i),
262 // OBSOLETE stream, show - 1, level + 4);
263 // OBSOLETE if (i < (len - 1))
265 // OBSOLETE fputs_filtered (",", stream);
267 // OBSOLETE fputs_filtered ("\n", stream);
270 // OBSOLETE fprintfi_filtered (level, stream, ")");
274 // OBSOLETE case TYPE_CODE_RANGE:
276 // OBSOLETE struct type *target = TYPE_TARGET_TYPE (type);
277 // OBSOLETE if (target && TYPE_NAME (target))
278 // OBSOLETE fputs_filtered (TYPE_NAME (target), stream);
280 // OBSOLETE fputs_filtered ("RANGE", stream);
281 // OBSOLETE if (target == NULL)
282 // OBSOLETE target = builtin_type_long;
283 // OBSOLETE fputs_filtered (" (", stream);
284 // OBSOLETE print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
285 // OBSOLETE fputs_filtered (":", stream);
286 // OBSOLETE print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
287 // OBSOLETE fputs_filtered (")", stream);
291 // OBSOLETE case TYPE_CODE_ENUM:
293 // OBSOLETE register int lastval = 0;
294 // OBSOLETE fprintf_filtered (stream, "SET (");
295 // OBSOLETE len = TYPE_NFIELDS (type);
296 // OBSOLETE for (i = 0; i < len; i++)
300 // OBSOLETE fprintf_filtered (stream, ", ");
301 // OBSOLETE wrap_here (" ");
302 // OBSOLETE fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
303 // OBSOLETE if (lastval != TYPE_FIELD_BITPOS (type, i))
305 // OBSOLETE fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
306 // OBSOLETE lastval = TYPE_FIELD_BITPOS (type, i);
308 // OBSOLETE lastval++;
310 // OBSOLETE fprintf_filtered (stream, ")");
314 // OBSOLETE case TYPE_CODE_VOID:
315 // OBSOLETE case TYPE_CODE_UNDEF:
316 // OBSOLETE case TYPE_CODE_ERROR:
317 // OBSOLETE case TYPE_CODE_UNION:
318 // OBSOLETE case TYPE_CODE_METHOD:
319 // OBSOLETE error ("missing language support in chill_type_print_base");
324 // OBSOLETE /* Handle types not explicitly handled by the other cases,
325 // OBSOLETE such as fundamental types. For these, just print whatever
326 // OBSOLETE the type name is, as recorded in the type itself. If there
327 // OBSOLETE is no type name, then complain. */
329 // OBSOLETE if (TYPE_NAME (type) != NULL)
331 // OBSOLETE fputs_filtered (TYPE_NAME (type), stream);
335 // OBSOLETE error ("Unrecognized type code (%d) in symbol table.",
336 // OBSOLETE TYPE_CODE (type));
This page took 0.037162 seconds and 4 git commands to generate.