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"
39 chill_print_type_base PARAMS ((struct type *, FILE *, int, int));
42 chill_print_type (type, varstring, stream, show, level)
49 struct type *index_type;
50 struct type *range_type;
54 if (varstring != NULL && *varstring != '\0')
56 fputs_filtered (varstring, stream);
57 fputs_filtered (" ", stream);
59 switch (TYPE_CODE (type))
62 range_type = TYPE_FIELD_TYPE (type, 0);
63 index_type = TYPE_TARGET_TYPE (range_type);
64 low_bound = TYPE_FIELD_BITPOS (range_type, 0);
65 high_bound = TYPE_FIELD_BITPOS (range_type, 1);
66 fputs_filtered ("array (", stream);
67 print_type_scalar (index_type, low_bound, stream);
68 fputs_filtered (":", stream);
69 print_type_scalar (index_type, high_bound, stream);
70 fputs_filtered (") ", stream);
71 chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
74 case TYPE_CODE_STRING:
75 range_type = TYPE_FIELD_TYPE (type, 0);
76 index_type = TYPE_TARGET_TYPE (range_type);
77 high_bound = TYPE_FIELD_BITPOS (range_type, 1);
78 fputs_filtered ("char (", stream);
79 print_type_scalar (index_type, high_bound + 1, stream);
80 fputs_filtered (") ", stream);
84 chill_print_type_base (type, stream, show, level);
89 /* Print the name of the type (or the ultimate pointer target,
90 function value or array element).
92 SHOW nonzero means don't print this type as just its name;
93 show its real definition even if it has a name.
94 SHOW zero means print just typename or tag if there is one
95 SHOW negative means abbreviate structure elements.
96 SHOW is decremented for printing of structure elements.
98 LEVEL is the depth to indent by.
99 We increase it for some recursive calls. */
102 chill_print_type_base (type, stream, show, level)
113 fputs_filtered ("<type unknown>", stream);
117 /* When SHOW is zero or less, and there is a valid type name, then always
118 just print the type name directly from the type. */
120 if ((show <= 0) && (TYPE_NAME (type) != NULL))
122 fputs_filtered (TYPE_NAME (type), stream);
126 switch (TYPE_CODE (type))
128 case TYPE_CODE_ARRAY:
130 case TYPE_CODE_MEMBER:
133 chill_print_type_base (TYPE_TARGET_TYPE (type), stream, show, level);
137 case TYPE_CODE_UNDEF:
138 case TYPE_CODE_ERROR:
139 case TYPE_CODE_RANGE:
141 case TYPE_CODE_UNION:
142 case TYPE_CODE_STRUCT:
143 case TYPE_CODE_METHOD:
144 error ("missing language support in chill_print_type_base");
149 /* Handle types not explicitly handled by the other cases,
150 such as fundamental types. For these, just print whatever
151 the type name is, as recorded in the type itself. If there
152 is no type name, then complain. */
154 if (TYPE_NAME (type) != NULL)
156 fputs_filtered (TYPE_NAME (type), stream);
160 error ("Unrecognized type code (%d) in symbol table.",