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. */
101 struct language_defn
{
102 char * la_name
; /* Name of the language */
103 enum language la_language
; /* its symtab language-enum (defs.h) */
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 */
130 #define LANG_MAGIC 910823L
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
136 extern const struct language_defn
*current_language
;
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. */
141 extern const struct language_defn
*expected_language
;
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. */
148 extern enum language_mode
149 {language_mode_auto
, language_mode_manual
} language_mode
;
151 /* These macros define the behaviour of the expression
154 /* Should we strictly type check expressions? */
155 #define STRICT_TYPE (type_check != type_check_off)
157 /* Should we range check values against the domain of their type? */
158 #define RANGE_CHECK (range_check != range_check_off)
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)
165 language_info
PARAMS ((int));
168 set_language
PARAMS ((enum language
));
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. */
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)
181 #define create_fundamental_type(objfile,typeid) \
182 (current_language->la_fund_type(objfile, typeid))
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). */
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)
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)
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)
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)
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))
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. */
236 #define PRINT_LITERAL_FORM(c) \
237 ((c)>=0x20 && ((c)<0x7F || (c)>=0xA0) && (!sevenbit_strings || (c)<0x80))
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). */
245 local_octal_format_custom
PARAMS ((char *)); /* language.c */
248 local_hex_format_custom
PARAMS ((char *)); /* language.c */
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". */
255 local_octal_string
PARAMS ((int)); /* language.c */
258 local_octal_string_custom
PARAMS ((int, char *));/* language.c */
261 local_hex_string
PARAMS ((int)); /* language.c */
264 local_hex_string_custom
PARAMS ((int, char *)); /* language.c */
266 /* Type predicates */
269 simple_type
PARAMS ((struct type
*));
272 ordered_type
PARAMS ((struct type
*));
275 same_type
PARAMS ((struct type
*, struct type
*));
278 integral_type
PARAMS ((struct type
*));
281 numeric_type
PARAMS ((struct type
*));
284 character_type
PARAMS ((struct type
*));
287 boolean_type
PARAMS ((struct type
*));
290 float_type
PARAMS ((struct type
*));
293 pointer_type
PARAMS ((struct type
*));
296 structured_type
PARAMS ((struct type
*));
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))
303 binop_type_check
PARAMS ((struct value
*, struct value
*, int));
308 op_error
PARAMS ((char *fmt
, enum exp_opcode
, int));
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)
321 /* Data: Does this value represent "truth" to the current language? */
324 value_true
PARAMS ((struct value
*));
326 /* Misc: The string representing a particular enum language. */
328 extern const struct language_defn
*
329 language_def
PARAMS ((enum language
));
332 language_str
PARAMS ((enum language
));
334 /* Add a language to the set known by GDB (at initialization time). */
337 add_language
PARAMS ((const struct language_defn
*));
340 get_frame_language
PARAMS ((void)); /* In stack.c */
342 #endif /* defined (LANGUAGE_H) */