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