Commit | Line | Data |
---|---|---|
c8023e66 | 1 | /* Source-language-related definitions for GDB. |
75af490b | 2 | Copyright 1991, 1992 Free Software Foundation, Inc. |
c8023e66 JG |
3 | Contributed by the Department of Computer Science at the State University |
4 | of New York at Buffalo. | |
5 | ||
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
21 | ||
75af490b JG |
22 | #if !defined (LANGUAGE_H) |
23 | #define LANGUAGE_H 1 | |
24 | ||
f9e3b3cc | 25 | #ifdef __STDC__ /* Forward decls for prototypes */ |
75af490b | 26 | struct value; |
f9e3b3cc | 27 | /* enum exp_opcode; ANSI's `wisdom' didn't include forward enum decls. */ |
75af490b JG |
28 | #endif |
29 | ||
c8023e66 JG |
30 | /* This used to be included to configure GDB for one or more specific |
31 | languages. Now it is shortcutted to configure for all of them. FIXME. */ | |
32 | /* #include "lang_def.h" */ | |
33 | #define _LANG_c | |
34 | #define _LANG_m2 | |
19cfe25d | 35 | /* start-sanitize-chill */ |
e58de8a2 | 36 | #define _LANG_chill |
19cfe25d | 37 | /* end-sanitize-chill */ |
c8023e66 JG |
38 | |
39 | /* range_mode == | |
40 | range_mode_auto: range_check set automatically to default of language. | |
41 | range_mode_manual: range_check set manually by user. */ | |
42 | ||
43 | extern enum range_mode {range_mode_auto, range_mode_manual} range_mode; | |
44 | ||
45 | /* range_check == | |
46 | range_check_on: Ranges are checked in GDB expressions, producing errors. | |
47 | range_check_warn: Ranges are checked, producing warnings. | |
48 | range_check_off: Ranges are not checked in GDB expressions. */ | |
49 | ||
50 | extern enum range_check | |
51 | {range_check_off, range_check_warn, range_check_on} range_check; | |
52 | ||
53 | /* type_mode == | |
54 | type_mode_auto: type_check set automatically to default of language | |
55 | type_mode_manual: type_check set manually by user. */ | |
56 | ||
57 | extern enum type_mode {type_mode_auto, type_mode_manual} type_mode; | |
58 | ||
59 | /* type_check == | |
60 | type_check_on: Types are checked in GDB expressions, producing errors. | |
61 | type_check_warn: Types are checked, producing warnings. | |
62 | type_check_off: Types are not checked in GDB expressions. */ | |
63 | ||
64 | extern enum type_check | |
65 | {type_check_off, type_check_warn, type_check_on} type_check; | |
66 | \f | |
2e66cf7d FF |
67 | /* Information for doing language dependent formatting of printed values. */ |
68 | ||
69 | struct language_format_info | |
70 | { | |
71 | /* The format that can be passed directly to standard C printf functions | |
72 | to generate a completely formatted value in the format appropriate for | |
73 | the language. */ | |
74 | ||
75 | char *la_format; | |
76 | ||
77 | /* The prefix to be used when directly printing a value, or constructing | |
78 | a standard C printf format. This generally is everything up to the | |
79 | conversion specification (the part introduced by the '%' character | |
80 | and terminated by the conversion specifier character). */ | |
81 | ||
82 | char *la_format_prefix; | |
83 | ||
84 | /* The conversion specifier. This is generally everything after the | |
85 | field width and precision, typically only a single character such | |
86 | as 'o' for octal format or 'x' for hexadecimal format. */ | |
87 | ||
88 | char *la_format_specifier; | |
89 | ||
90 | /* The suffix to be used when directly printing a value, or constructing | |
91 | a standard C printf format. This generally is everything after the | |
92 | conversion specification (the part introduced by the '%' character | |
93 | and terminated by the conversion specifier character). */ | |
94 | ||
95 | char *la_format_suffix; /* Suffix for custom format string */ | |
96 | }; | |
97 | ||
c8023e66 JG |
98 | /* Structure tying together assorted information about a language. */ |
99 | ||
100 | struct language_defn { | |
101 | char * la_name; /* Name of the language */ | |
102 | enum language la_language; /* its symtab language-enum (defs.h) */ | |
103 | struct type ** const | |
104 | *la_builtin_type_vector; /* Its builtin types */ | |
105 | enum range_check la_range_check; /* Default range checking */ | |
106 | enum type_check la_type_check; /* Default type checking */ | |
75af490b JG |
107 | int (*la_parser) PARAMS((void)); /* Parser function */ |
108 | void (*la_error) PARAMS ((char *)); /* Parser error function */ | |
5d074aa9 FF |
109 | void (*la_printchar) PARAMS ((int, FILE *)); |
110 | void (*la_printstr) PARAMS ((FILE *, char *, unsigned int, int)); | |
c8023e66 JG |
111 | struct type **la_longest_int; /* Longest signed integral type */ |
112 | struct type **la_longest_unsigned_int; /* Longest uns integral type */ | |
113 | struct type **la_longest_float; /* Longest floating point type */ | |
2e66cf7d FF |
114 | struct language_format_info |
115 | la_binary_format; /* Base 2 (binary) formats. */ | |
116 | struct language_format_info | |
117 | la_octal_format; /* Base 8 (octal) formats. */ | |
118 | struct language_format_info | |
119 | la_decimal_format; /* Base 10 (decimal) formats */ | |
120 | struct language_format_info | |
121 | la_hex_format; /* Base 16 (hexadecimal) formats */ | |
122 | const struct op_print | |
c8023e66 JG |
123 | *la_op_print_tab; /* Table for printing expressions */ |
124 | /* Add fields above this point, so the magic number is always last. */ | |
125 | long la_magic; /* Magic number for compat checking */ | |
126 | }; | |
127 | ||
128 | #define LANG_MAGIC 910823L | |
129 | ||
130 | /* Pointer to the language_defn for our current language. This pointer | |
131 | always points to *some* valid struct; it can be used without checking | |
132 | it for validity. */ | |
133 | ||
0c6efbcc | 134 | extern const struct language_defn *current_language; |
c8023e66 | 135 | |
b5af69c3 JG |
136 | /* Pointer to the language_defn expected by the user, e.g. the language |
137 | of main(), or the language we last mentioned in a message, or C. */ | |
138 | ||
139 | extern const struct language_defn *expected_language; | |
140 | ||
c8023e66 JG |
141 | /* language_mode == |
142 | language_mode_auto: current_language automatically set upon selection | |
143 | of scope (e.g. stack frame) | |
144 | language_mode_manual: current_language set only by user. */ | |
145 | ||
146 | extern enum language_mode | |
147 | {language_mode_auto, language_mode_manual} language_mode; | |
148 | \f | |
149 | /* These macros define the behaviour of the expression | |
150 | evaluator. */ | |
151 | ||
152 | /* Should we strictly type check expressions? */ | |
1a5a8f2a | 153 | #define STRICT_TYPE (type_check != type_check_off) |
c8023e66 JG |
154 | |
155 | /* Should we range check values against the domain of their type? */ | |
1a5a8f2a | 156 | #define RANGE_CHECK (range_check != range_check_off) |
c8023e66 JG |
157 | |
158 | /* "cast" really means conversion */ | |
159 | /* FIXME -- should be a setting in language_defn */ | |
160 | #define CAST_IS_CONVERSION (current_language->la_language == language_c) | |
161 | ||
75af490b JG |
162 | extern void |
163 | language_info PARAMS ((int)); | |
164 | ||
165 | extern void | |
166 | set_language PARAMS ((enum language)); | |
167 | ||
c8023e66 JG |
168 | \f |
169 | /* This page contains functions that return things that are | |
170 | specific to languages. Each of these functions is based on | |
171 | the current setting of working_lang, which the user sets | |
172 | with the "set language" command. */ | |
173 | ||
174 | /* Returns some built-in types */ | |
175 | #define longest_int() (*current_language->la_longest_int) | |
176 | #define longest_unsigned_int() (*current_language->la_longest_unsigned_int) | |
177 | #define longest_float() (*current_language->la_longest_float) | |
c8023e66 | 178 | |
2e66cf7d FF |
179 | /* Return a format string for printf that will print a number in one of |
180 | the local (language-specific) formats. Result is static and is | |
181 | overwritten by the next call. Takes printf options like "08" or "l" | |
182 | (to produce e.g. %08x or %lx). */ | |
183 | ||
184 | #define local_binary_format() \ | |
185 | (current_language->la_binary_format.la_format) | |
186 | #define local_binary_format_prefix() \ | |
187 | (current_language->la_binary_format.la_format_prefix) | |
188 | #define local_binary_format_specifier() \ | |
189 | (current_language->la_binary_format.la_format_specifier) | |
190 | #define local_binary_format_suffix() \ | |
191 | (current_language->la_binary_format.la_format_suffix) | |
192 | ||
193 | #define local_octal_format() \ | |
194 | (current_language->la_octal_format.la_format) | |
195 | #define local_octal_format_prefix() \ | |
196 | (current_language->la_octal_format.la_format_prefix) | |
197 | #define local_octal_format_specifier() \ | |
198 | (current_language->la_octal_format.la_format_specifier) | |
199 | #define local_octal_format_suffix() \ | |
200 | (current_language->la_octal_format.la_format_suffix) | |
201 | ||
202 | #define local_decimal_format() \ | |
203 | (current_language->la_decimal_format.la_format) | |
204 | #define local_decimal_format_prefix() \ | |
205 | (current_language->la_decimal_format.la_format_prefix) | |
206 | #define local_decimal_format_specifier() \ | |
207 | (current_language->la_decimal_format.la_format_specifier) | |
208 | #define local_decimal_format_suffix() \ | |
209 | (current_language->la_decimal_format.la_format_suffix) | |
210 | ||
211 | #define local_hex_format() \ | |
212 | (current_language->la_hex_format.la_format) | |
213 | #define local_hex_format_prefix() \ | |
214 | (current_language->la_hex_format.la_format_prefix) | |
215 | #define local_hex_format_specifier() \ | |
216 | (current_language->la_hex_format.la_format_specifier) | |
217 | #define local_hex_format_suffix() \ | |
218 | (current_language->la_hex_format.la_format_suffix) | |
219 | ||
5d074aa9 FF |
220 | #define local_printchar(ch, stream) \ |
221 | (current_language->la_printchar(ch, stream)) | |
222 | #define local_printstr(stream, string, length, force_ellipses) \ | |
223 | (current_language->la_printstr(stream, string, length, force_ellipses)) | |
224 | ||
2e66cf7d FF |
225 | /* Return a format string for printf that will print a number in one of |
226 | the local (language-specific) formats. Result is static and is | |
227 | overwritten by the next call. Takes printf options like "08" or "l" | |
228 | (to produce e.g. %08x or %lx). */ | |
c8023e66 | 229 | |
2e66cf7d FF |
230 | extern char * |
231 | local_octal_format_custom PARAMS ((char *)); /* language.c */ | |
232 | ||
233 | extern char * | |
234 | local_hex_format_custom PARAMS ((char *)); /* language.c */ | |
c8023e66 | 235 | |
2e66cf7d FF |
236 | /* Return a string that contains a number formatted in one of the local |
237 | (language-specific) formats. Result is static and is overwritten by | |
238 | the next call. Takes printf options like "08" or "l". */ | |
239 | ||
240 | extern char * | |
241 | local_octal_string PARAMS ((int)); /* language.c */ | |
242 | ||
243 | extern char * | |
244 | local_octal_string_custom PARAMS ((int, char *));/* language.c */ | |
245 | ||
246 | extern char * | |
247 | local_hex_string PARAMS ((int)); /* language.c */ | |
75af490b JG |
248 | |
249 | extern char * | |
2e66cf7d | 250 | local_hex_string_custom PARAMS ((int, char *)); /* language.c */ |
c8023e66 JG |
251 | |
252 | /* Type predicates */ | |
75af490b JG |
253 | |
254 | extern int | |
255 | simple_type PARAMS ((struct type *)); | |
256 | ||
257 | extern int | |
258 | ordered_type PARAMS ((struct type *)); | |
259 | ||
260 | extern int | |
261 | same_type PARAMS ((struct type *, struct type *)); | |
262 | ||
263 | extern int | |
264 | integral_type PARAMS ((struct type *)); | |
265 | ||
266 | extern int | |
267 | numeric_type PARAMS ((struct type *)); | |
268 | ||
269 | extern int | |
270 | character_type PARAMS ((struct type *)); | |
271 | ||
272 | extern int | |
273 | boolean_type PARAMS ((struct type *)); | |
274 | ||
275 | extern int | |
276 | float_type PARAMS ((struct type *)); | |
277 | ||
278 | extern int | |
279 | pointer_type PARAMS ((struct type *)); | |
280 | ||
281 | extern int | |
282 | structured_type PARAMS ((struct type *)); | |
c8023e66 JG |
283 | |
284 | /* Checks Binary and Unary operations for semantic type correctness */ | |
75af490b | 285 | /* FIXME: Does not appear to be used */ |
c8023e66 JG |
286 | #define unop_type_check(v,o) binop_type_check((v),NULL,(o)) |
287 | ||
75af490b JG |
288 | extern void |
289 | binop_type_check PARAMS ((struct value *, struct value *, int)); | |
290 | ||
c8023e66 | 291 | /* Error messages */ |
75af490b JG |
292 | |
293 | extern void | |
294 | op_error PARAMS ((char *fmt, enum exp_opcode, int)); | |
295 | ||
c8023e66 JG |
296 | #define type_op_error(f,o) \ |
297 | op_error((f),(o),type_check==type_check_on ? 1 : 0) | |
298 | #define range_op_error(f,o) \ | |
299 | op_error((f),(o),range_check==range_check_on ? 1 : 0) | |
75af490b JG |
300 | |
301 | extern void | |
302 | type_error (); | |
303 | ||
304 | void | |
305 | range_error (); | |
c8023e66 JG |
306 | |
307 | /* Data: Does this value represent "truth" to the current language? */ | |
75af490b JG |
308 | |
309 | extern int | |
310 | value_true PARAMS ((struct value *)); | |
c8023e66 JG |
311 | |
312 | /* Misc: The string representing a particular enum language. */ | |
75af490b JG |
313 | |
314 | extern char * | |
315 | language_str PARAMS ((enum language)); | |
c8023e66 JG |
316 | |
317 | /* Add a language to the set known by GDB (at initialization time). */ | |
d8ce1326 | 318 | |
75af490b JG |
319 | extern void |
320 | add_language PARAMS ((const struct language_defn *)); | |
321 | ||
322 | extern enum language | |
323 | get_frame_language PARAMS ((void)); /* In stack.c */ | |
324 | ||
325 | #endif /* defined (LANGUAGE_H) */ |