Changes for Amiga Unix from rhealey@ub.d.umn.edu.
[deliverable/binutils-gdb.git] / gdb / language.h
CommitLineData
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
6This file is part of GDB.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, 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 26struct 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
43extern 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
50extern 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
57extern 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
64extern 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
69struct 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
100struct 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));
bf229b4e 111 struct type *(*la_fund_type) PARAMS ((struct objfile *, int));
c8023e66
JG
112 struct type **la_longest_int; /* Longest signed integral type */
113 struct type **la_longest_unsigned_int; /* Longest uns integral type */
114 struct type **la_longest_float; /* Longest floating point type */
2e66cf7d
FF
115 struct language_format_info
116 la_binary_format; /* Base 2 (binary) formats. */
117 struct language_format_info
118 la_octal_format; /* Base 8 (octal) formats. */
119 struct language_format_info
120 la_decimal_format; /* Base 10 (decimal) formats */
121 struct language_format_info
122 la_hex_format; /* Base 16 (hexadecimal) formats */
123 const struct op_print
c8023e66
JG
124 *la_op_print_tab; /* Table for printing expressions */
125/* Add fields above this point, so the magic number is always last. */
126 long la_magic; /* Magic number for compat checking */
127};
128
129#define LANG_MAGIC 910823L
130
131/* Pointer to the language_defn for our current language. This pointer
132 always points to *some* valid struct; it can be used without checking
133 it for validity. */
134
0c6efbcc 135extern const struct language_defn *current_language;
c8023e66 136
b5af69c3
JG
137/* Pointer to the language_defn expected by the user, e.g. the language
138 of main(), or the language we last mentioned in a message, or C. */
139
140extern const struct language_defn *expected_language;
141
c8023e66
JG
142/* language_mode ==
143 language_mode_auto: current_language automatically set upon selection
144 of scope (e.g. stack frame)
145 language_mode_manual: current_language set only by user. */
146
147extern enum language_mode
148 {language_mode_auto, language_mode_manual} language_mode;
149\f
150/* These macros define the behaviour of the expression
151 evaluator. */
152
153/* Should we strictly type check expressions? */
1a5a8f2a 154#define STRICT_TYPE (type_check != type_check_off)
c8023e66
JG
155
156/* Should we range check values against the domain of their type? */
1a5a8f2a 157#define RANGE_CHECK (range_check != range_check_off)
c8023e66
JG
158
159/* "cast" really means conversion */
160/* FIXME -- should be a setting in language_defn */
161#define CAST_IS_CONVERSION (current_language->la_language == language_c)
162
75af490b
JG
163extern void
164language_info PARAMS ((int));
165
166extern void
167set_language PARAMS ((enum language));
168
c8023e66
JG
169\f
170/* This page contains functions that return things that are
171 specific to languages. Each of these functions is based on
172 the current setting of working_lang, which the user sets
173 with the "set language" command. */
174
175/* Returns some built-in types */
176#define longest_int() (*current_language->la_longest_int)
177#define longest_unsigned_int() (*current_language->la_longest_unsigned_int)
178#define longest_float() (*current_language->la_longest_float)
c8023e66 179
bf229b4e
FF
180#define create_fundamental_type(objfile,typeid) \
181 (current_language->la_fund_type(objfile, typeid))
182
2e66cf7d
FF
183/* Return a format string for printf that will print a number in one of
184 the local (language-specific) formats. Result is static and is
185 overwritten by the next call. Takes printf options like "08" or "l"
186 (to produce e.g. %08x or %lx). */
187
188#define local_binary_format() \
189 (current_language->la_binary_format.la_format)
190#define local_binary_format_prefix() \
191 (current_language->la_binary_format.la_format_prefix)
192#define local_binary_format_specifier() \
193 (current_language->la_binary_format.la_format_specifier)
194#define local_binary_format_suffix() \
195 (current_language->la_binary_format.la_format_suffix)
196
197#define local_octal_format() \
198 (current_language->la_octal_format.la_format)
199#define local_octal_format_prefix() \
200 (current_language->la_octal_format.la_format_prefix)
201#define local_octal_format_specifier() \
202 (current_language->la_octal_format.la_format_specifier)
203#define local_octal_format_suffix() \
204 (current_language->la_octal_format.la_format_suffix)
205
206#define local_decimal_format() \
207 (current_language->la_decimal_format.la_format)
208#define local_decimal_format_prefix() \
209 (current_language->la_decimal_format.la_format_prefix)
210#define local_decimal_format_specifier() \
211 (current_language->la_decimal_format.la_format_specifier)
212#define local_decimal_format_suffix() \
213 (current_language->la_decimal_format.la_format_suffix)
214
215#define local_hex_format() \
216 (current_language->la_hex_format.la_format)
217#define local_hex_format_prefix() \
218 (current_language->la_hex_format.la_format_prefix)
219#define local_hex_format_specifier() \
220 (current_language->la_hex_format.la_format_specifier)
221#define local_hex_format_suffix() \
222 (current_language->la_hex_format.la_format_suffix)
223
5d074aa9
FF
224#define local_printchar(ch, stream) \
225 (current_language->la_printchar(ch, stream))
226#define local_printstr(stream, string, length, force_ellipses) \
227 (current_language->la_printstr(stream, string, length, force_ellipses))
228
5707ea9f
FF
229/* Test a character to decide whether it can be printed in literal form
230 or needs to be printed in another representation. For example,
231 in C the literal form of the character with octal value 141 is 'a'
232 and the "other representation" is '\141'. The "other representation"
233 is program language dependent. */
234
235#define PRINT_LITERAL_FORM(c) \
236 ((c)>=0x20 && ((c)<0x7F || (c)>=0xA0) && (!sevenbit_strings || (c)<0x80))
237
2e66cf7d
FF
238/* Return a format string for printf that will print a number in one of
239 the local (language-specific) formats. Result is static and is
240 overwritten by the next call. Takes printf options like "08" or "l"
241 (to produce e.g. %08x or %lx). */
c8023e66 242
2e66cf7d
FF
243extern char *
244local_octal_format_custom PARAMS ((char *)); /* language.c */
245
246extern char *
247local_hex_format_custom PARAMS ((char *)); /* language.c */
c8023e66 248
2e66cf7d
FF
249/* Return a string that contains a number formatted in one of the local
250 (language-specific) formats. Result is static and is overwritten by
251 the next call. Takes printf options like "08" or "l". */
252
253extern char *
254local_octal_string PARAMS ((int)); /* language.c */
255
256extern char *
257local_octal_string_custom PARAMS ((int, char *));/* language.c */
258
259extern char *
260local_hex_string PARAMS ((int)); /* language.c */
75af490b
JG
261
262extern char *
2e66cf7d 263local_hex_string_custom PARAMS ((int, char *)); /* language.c */
c8023e66
JG
264
265/* Type predicates */
75af490b
JG
266
267extern int
268simple_type PARAMS ((struct type *));
269
270extern int
271ordered_type PARAMS ((struct type *));
272
273extern int
274same_type PARAMS ((struct type *, struct type *));
275
276extern int
277integral_type PARAMS ((struct type *));
278
279extern int
280numeric_type PARAMS ((struct type *));
281
282extern int
283character_type PARAMS ((struct type *));
284
285extern int
286boolean_type PARAMS ((struct type *));
287
288extern int
289float_type PARAMS ((struct type *));
290
291extern int
292pointer_type PARAMS ((struct type *));
293
294extern int
295structured_type PARAMS ((struct type *));
c8023e66
JG
296
297/* Checks Binary and Unary operations for semantic type correctness */
75af490b 298/* FIXME: Does not appear to be used */
c8023e66
JG
299#define unop_type_check(v,o) binop_type_check((v),NULL,(o))
300
75af490b
JG
301extern void
302binop_type_check PARAMS ((struct value *, struct value *, int));
303
c8023e66 304/* Error messages */
75af490b
JG
305
306extern void
307op_error PARAMS ((char *fmt, enum exp_opcode, int));
308
c8023e66
JG
309#define type_op_error(f,o) \
310 op_error((f),(o),type_check==type_check_on ? 1 : 0)
311#define range_op_error(f,o) \
312 op_error((f),(o),range_check==range_check_on ? 1 : 0)
75af490b
JG
313
314extern void
315type_error ();
316
317void
318range_error ();
c8023e66
JG
319
320/* Data: Does this value represent "truth" to the current language? */
75af490b
JG
321
322extern int
323value_true PARAMS ((struct value *));
c8023e66
JG
324
325/* Misc: The string representing a particular enum language. */
75af490b 326
bf229b4e
FF
327extern const struct language_defn *
328language_def PARAMS ((enum language));
329
75af490b
JG
330extern char *
331language_str PARAMS ((enum language));
c8023e66
JG
332
333/* Add a language to the set known by GDB (at initialization time). */
d8ce1326 334
75af490b
JG
335extern void
336add_language PARAMS ((const struct language_defn *));
337
338extern enum language
339get_frame_language PARAMS ((void)); /* In stack.c */
340
341#endif /* defined (LANGUAGE_H) */
This page took 0.078869 seconds and 4 git commands to generate.