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.
6 This file is part of GDB.
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.
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.
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. */
22 #if !defined (LANGUAGE_H)
25 #ifdef __STDC__ /* Forward decls for prototypes */
28 /* enum exp_opcode; ANSI's `wisdom' didn't include forward enum decls. */
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" */
36 /* start-sanitize-chill */
38 /* end-sanitize-chill */
41 range_mode_auto: range_check set automatically to default of language.
42 range_mode_manual: range_check set manually by user. */
44 extern enum range_mode
{range_mode_auto
, range_mode_manual
} range_mode
;
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. */
51 extern enum range_check
52 {range_check_off
, range_check_warn
, range_check_on
} range_check
;
55 type_mode_auto: type_check set automatically to default of language
56 type_mode_manual: type_check set manually by user. */
58 extern enum type_mode
{type_mode_auto
, type_mode_manual
} type_mode
;
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. */
65 extern enum type_check
66 {type_check_off
, type_check_warn
, type_check_on
} type_check
;
68 /* Information for doing language dependent formatting of printed values. */
70 struct language_format_info
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
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). */
83 char *la_format_prefix
;
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. */
89 char *la_format_specifier
;
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). */
96 char *la_format_suffix
; /* Suffix for custom format string */
99 /* Structure tying together assorted information about a language. */
103 /* Name of the language */
107 /* its symtab language-enum (defs.h) */
109 enum language la_language
;
111 /* Its builtin types */
113 struct type
** const *la_builtin_type_vector
;
115 /* Default range checking */
117 enum range_check la_range_check
;
119 /* Default type checking */
121 enum type_check la_type_check
;
123 /* Parser function. */
125 int (*la_parser
) PARAMS((void));
127 /* Parser error function */
129 void (*la_error
) PARAMS ((char *));
131 void (*la_printchar
) PARAMS ((int, FILE *));
133 void (*la_printstr
) PARAMS ((FILE *, char *, unsigned int, int));
135 struct type
*(*la_fund_type
) PARAMS ((struct objfile
*, int));
137 /* Print a type using syntax appropriate for this language. */
139 void (*la_print_type
) PARAMS ((struct type
*, char *, FILE *, int, int));
141 /* Print a value using syntax appropriate for this language. */
143 int (*la_val_print
) PARAMS ((struct type
*, char *, CORE_ADDR
, FILE *,
144 int, int, int, enum val_prettyprint
));
146 /* Longest signed integral type */
148 struct type
**la_longest_int
;
150 /* Longest unsigned integral type */
152 struct type
**la_longest_unsigned_int
;
154 /* Longest floating point type */
156 struct type
**la_longest_float
;
158 /* Base 2 (binary) formats. */
160 struct language_format_info la_binary_format
;
162 /* Base 8 (octal) formats. */
164 struct language_format_info la_octal_format
;
166 /* Base 10 (decimal) formats */
168 struct language_format_info la_decimal_format
;
170 /* Base 16 (hexadecimal) formats */
172 struct language_format_info la_hex_format
;
175 /* Table for printing expressions */
177 const struct op_print
*la_op_print_tab
;
179 /* Add fields above this point, so the magic number is always last. */
180 /* Magic number for compat checking */
186 #define LANG_MAGIC 910823L
188 /* Pointer to the language_defn for our current language. This pointer
189 always points to *some* valid struct; it can be used without checking
192 extern const struct language_defn
*current_language
;
194 /* Pointer to the language_defn expected by the user, e.g. the language
195 of main(), or the language we last mentioned in a message, or C. */
197 extern const struct language_defn
*expected_language
;
200 language_mode_auto: current_language automatically set upon selection
201 of scope (e.g. stack frame)
202 language_mode_manual: current_language set only by user. */
204 extern enum language_mode
205 {language_mode_auto
, language_mode_manual
} language_mode
;
207 /* These macros define the behaviour of the expression
210 /* Should we strictly type check expressions? */
211 #define STRICT_TYPE (type_check != type_check_off)
213 /* Should we range check values against the domain of their type? */
214 #define RANGE_CHECK (range_check != range_check_off)
216 /* "cast" really means conversion */
217 /* FIXME -- should be a setting in language_defn */
218 #define CAST_IS_CONVERSION (current_language->la_language == language_c)
221 language_info
PARAMS ((int));
224 set_language
PARAMS ((enum language
));
227 /* This page contains functions that return things that are
228 specific to languages. Each of these functions is based on
229 the current setting of working_lang, which the user sets
230 with the "set language" command. */
232 /* Returns some built-in types */
233 #define longest_int() (*current_language->la_longest_int)
234 #define longest_unsigned_int() (*current_language->la_longest_unsigned_int)
235 #define longest_float() (*current_language->la_longest_float)
237 #define create_fundamental_type(objfile,typeid) \
238 (current_language->la_fund_type(objfile, typeid))
240 #define LA_PRINT_TYPE(type,varstring,stream,show,level) \
241 (current_language->la_print_type(type,varstring,stream,show,level))
243 #define LA_VAL_PRINT(type,valaddr,addr,stream,fmt,deref,recurse,pretty) \
244 (current_language->la_val_print(type,valaddr,addr,stream,fmt,deref, \
247 /* Return a format string for printf that will print a number in one of
248 the local (language-specific) formats. Result is static and is
249 overwritten by the next call. Takes printf options like "08" or "l"
250 (to produce e.g. %08x or %lx). */
252 #define local_binary_format() \
253 (current_language->la_binary_format.la_format)
254 #define local_binary_format_prefix() \
255 (current_language->la_binary_format.la_format_prefix)
256 #define local_binary_format_specifier() \
257 (current_language->la_binary_format.la_format_specifier)
258 #define local_binary_format_suffix() \
259 (current_language->la_binary_format.la_format_suffix)
261 #define local_octal_format() \
262 (current_language->la_octal_format.la_format)
263 #define local_octal_format_prefix() \
264 (current_language->la_octal_format.la_format_prefix)
265 #define local_octal_format_specifier() \
266 (current_language->la_octal_format.la_format_specifier)
267 #define local_octal_format_suffix() \
268 (current_language->la_octal_format.la_format_suffix)
270 #define local_decimal_format() \
271 (current_language->la_decimal_format.la_format)
272 #define local_decimal_format_prefix() \
273 (current_language->la_decimal_format.la_format_prefix)
274 #define local_decimal_format_specifier() \
275 (current_language->la_decimal_format.la_format_specifier)
276 #define local_decimal_format_suffix() \
277 (current_language->la_decimal_format.la_format_suffix)
279 #define local_hex_format() \
280 (current_language->la_hex_format.la_format)
281 #define local_hex_format_prefix() \
282 (current_language->la_hex_format.la_format_prefix)
283 #define local_hex_format_specifier() \
284 (current_language->la_hex_format.la_format_specifier)
285 #define local_hex_format_suffix() \
286 (current_language->la_hex_format.la_format_suffix)
288 #define LA_PRINT_CHAR(ch, stream) \
289 (current_language->la_printchar(ch, stream))
290 #define LA_PRINT_STRING(stream, string, length, force_ellipses) \
291 (current_language->la_printstr(stream, string, length, force_ellipses))
293 /* Test a character to decide whether it can be printed in literal form
294 or needs to be printed in another representation. For example,
295 in C the literal form of the character with octal value 141 is 'a'
296 and the "other representation" is '\141'. The "other representation"
297 is program language dependent. */
299 #define PRINT_LITERAL_FORM(c) \
300 ((c)>=0x20 && ((c)<0x7F || (c)>=0xA0) && (!sevenbit_strings || (c)<0x80))
302 /* Return a format string for printf that will print a number in one of
303 the local (language-specific) formats. Result is static and is
304 overwritten by the next call. Takes printf options like "08" or "l"
305 (to produce e.g. %08x or %lx). */
308 local_octal_format_custom
PARAMS ((char *)); /* language.c */
311 local_hex_format_custom
PARAMS ((char *)); /* language.c */
313 /* Return a string that contains a number formatted in one of the local
314 (language-specific) formats. Result is static and is overwritten by
315 the next call. Takes printf options like "08" or "l". */
318 local_octal_string
PARAMS ((int)); /* language.c */
321 local_octal_string_custom
PARAMS ((int, char *));/* language.c */
324 local_hex_string
PARAMS ((int)); /* language.c */
327 local_hex_string_custom
PARAMS ((int, char *)); /* language.c */
329 /* Type predicates */
332 simple_type
PARAMS ((struct type
*));
335 ordered_type
PARAMS ((struct type
*));
338 same_type
PARAMS ((struct type
*, struct type
*));
341 integral_type
PARAMS ((struct type
*));
344 numeric_type
PARAMS ((struct type
*));
347 character_type
PARAMS ((struct type
*));
350 boolean_type
PARAMS ((struct type
*));
353 float_type
PARAMS ((struct type
*));
356 pointer_type
PARAMS ((struct type
*));
359 structured_type
PARAMS ((struct type
*));
361 /* Checks Binary and Unary operations for semantic type correctness */
362 /* FIXME: Does not appear to be used */
363 #define unop_type_check(v,o) binop_type_check((v),NULL,(o))
366 binop_type_check
PARAMS ((struct value
*, struct value
*, int));
371 op_error
PARAMS ((char *fmt
, enum exp_opcode
, int));
373 #define type_op_error(f,o) \
374 op_error((f),(o),type_check==type_check_on ? 1 : 0)
375 #define range_op_error(f,o) \
376 op_error((f),(o),range_check==range_check_on ? 1 : 0)
384 /* Data: Does this value represent "truth" to the current language? */
387 value_true
PARAMS ((struct value
*));
389 /* Misc: The string representing a particular enum language. */
391 extern const struct language_defn
*
392 language_def
PARAMS ((enum language
));
395 language_str
PARAMS ((enum language
));
397 /* Add a language to the set known by GDB (at initialization time). */
400 add_language
PARAMS ((const struct language_defn
*));
403 get_frame_language
PARAMS ((void)); /* In stack.c */
405 #endif /* defined (LANGUAGE_H) */