* rs6000-tdep.c (single_step): Misc cleanups (CORE_ADDR not int,
[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;
22e39759 27struct objfile;
f9e3b3cc 28/* enum exp_opcode; ANSI's `wisdom' didn't include forward enum decls. */
75af490b
JG
29#endif
30
c8023e66
JG
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
19cfe25d 36/* start-sanitize-chill */
e58de8a2 37#define _LANG_chill
19cfe25d 38/* end-sanitize-chill */
c8023e66
JG
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
44extern 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
51extern 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
58extern 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
65extern enum type_check
66 {type_check_off, type_check_warn, type_check_on} type_check;
67\f
2e66cf7d
FF
68/* Information for doing language dependent formatting of printed values. */
69
70struct 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
c8023e66
JG
99/* Structure tying together assorted information about a language. */
100
a8a69e63
FF
101struct language_defn
102{
103 /* Name of the language */
104
105 char *la_name;
106
107 /* its symtab language-enum (defs.h) */
108
109 enum language la_language;
110
111 /* Its builtin types */
112
113 struct type ** const *la_builtin_type_vector;
114
115 /* Default range checking */
116
117 enum range_check la_range_check;
118
119 /* Default type checking */
120
121 enum type_check la_type_check;
122
123 /* Parser function. */
124
125 int (*la_parser) PARAMS((void));
126
127 /* Parser error function */
128
129 void (*la_error) PARAMS ((char *));
130
131 void (*la_printchar) PARAMS ((int, FILE *));
132
133 void (*la_printstr) PARAMS ((FILE *, char *, unsigned int, int));
134
135 struct type *(*la_fund_type) PARAMS ((struct objfile *, int));
136
137 /* Print a type using syntax appropriate for this language. */
138
139 void (*la_print_type) PARAMS ((struct type *, char *, FILE *, int, int));
140
141 /* Print a value using syntax appropriate for this language. */
142
143 int (*la_val_print) PARAMS ((struct type *, char *, CORE_ADDR, FILE *,
144 int, int, int, enum val_prettyprint));
145
146 /* Longest signed integral type */
147
148 struct type **la_longest_int;
149
150 /* Longest unsigned integral type */
151
152 struct type **la_longest_unsigned_int;
153
154 /* Longest floating point type */
155
156 struct type **la_longest_float;
157
158 /* Base 2 (binary) formats. */
159
160 struct language_format_info la_binary_format;
161
162 /* Base 8 (octal) formats. */
163
164 struct language_format_info la_octal_format;
165
166 /* Base 10 (decimal) formats */
167
168 struct language_format_info la_decimal_format;
169
170 /* Base 16 (hexadecimal) formats */
171
172 struct language_format_info la_hex_format;
173
174
175 /* Table for printing expressions */
176
177 const struct op_print *la_op_print_tab;
178
179 /* Add fields above this point, so the magic number is always last. */
180 /* Magic number for compat checking */
181
182 long la_magic;
183
c8023e66
JG
184};
185
186#define LANG_MAGIC 910823L
187
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
190 it for validity. */
191
0c6efbcc 192extern const struct language_defn *current_language;
c8023e66 193
b5af69c3
JG
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. */
196
197extern const struct language_defn *expected_language;
198
c8023e66
JG
199/* language_mode ==
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. */
203
204extern enum language_mode
205 {language_mode_auto, language_mode_manual} language_mode;
206\f
207/* These macros define the behaviour of the expression
208 evaluator. */
209
210/* Should we strictly type check expressions? */
1a5a8f2a 211#define STRICT_TYPE (type_check != type_check_off)
c8023e66
JG
212
213/* Should we range check values against the domain of their type? */
1a5a8f2a 214#define RANGE_CHECK (range_check != range_check_off)
c8023e66
JG
215
216/* "cast" really means conversion */
217/* FIXME -- should be a setting in language_defn */
f77ad505
FF
218#define CAST_IS_CONVERSION (current_language->la_language == language_c || \
219 current_language->la_language == language_cplus)
c8023e66 220
75af490b
JG
221extern void
222language_info PARAMS ((int));
223
224extern void
225set_language PARAMS ((enum language));
226
c8023e66
JG
227\f
228/* This page contains functions that return things that are
229 specific to languages. Each of these functions is based on
230 the current setting of working_lang, which the user sets
231 with the "set language" command. */
232
233/* Returns some built-in types */
234#define longest_int() (*current_language->la_longest_int)
235#define longest_unsigned_int() (*current_language->la_longest_unsigned_int)
236#define longest_float() (*current_language->la_longest_float)
c8023e66 237
bf229b4e
FF
238#define create_fundamental_type(objfile,typeid) \
239 (current_language->la_fund_type(objfile, typeid))
240
a8a69e63
FF
241#define LA_PRINT_TYPE(type,varstring,stream,show,level) \
242 (current_language->la_print_type(type,varstring,stream,show,level))
243
244#define LA_VAL_PRINT(type,valaddr,addr,stream,fmt,deref,recurse,pretty) \
245 (current_language->la_val_print(type,valaddr,addr,stream,fmt,deref, \
246 recurse,pretty))
247
2e66cf7d
FF
248/* Return a format string for printf that will print a number in one of
249 the local (language-specific) formats. Result is static and is
250 overwritten by the next call. Takes printf options like "08" or "l"
251 (to produce e.g. %08x or %lx). */
252
253#define local_binary_format() \
254 (current_language->la_binary_format.la_format)
255#define local_binary_format_prefix() \
256 (current_language->la_binary_format.la_format_prefix)
257#define local_binary_format_specifier() \
258 (current_language->la_binary_format.la_format_specifier)
259#define local_binary_format_suffix() \
260 (current_language->la_binary_format.la_format_suffix)
261
262#define local_octal_format() \
263 (current_language->la_octal_format.la_format)
264#define local_octal_format_prefix() \
265 (current_language->la_octal_format.la_format_prefix)
266#define local_octal_format_specifier() \
267 (current_language->la_octal_format.la_format_specifier)
268#define local_octal_format_suffix() \
269 (current_language->la_octal_format.la_format_suffix)
270
271#define local_decimal_format() \
272 (current_language->la_decimal_format.la_format)
273#define local_decimal_format_prefix() \
274 (current_language->la_decimal_format.la_format_prefix)
275#define local_decimal_format_specifier() \
276 (current_language->la_decimal_format.la_format_specifier)
277#define local_decimal_format_suffix() \
278 (current_language->la_decimal_format.la_format_suffix)
279
280#define local_hex_format() \
281 (current_language->la_hex_format.la_format)
282#define local_hex_format_prefix() \
283 (current_language->la_hex_format.la_format_prefix)
284#define local_hex_format_specifier() \
285 (current_language->la_hex_format.la_format_specifier)
286#define local_hex_format_suffix() \
287 (current_language->la_hex_format.la_format_suffix)
288
a8a69e63 289#define LA_PRINT_CHAR(ch, stream) \
5d074aa9 290 (current_language->la_printchar(ch, stream))
a8a69e63 291#define LA_PRINT_STRING(stream, string, length, force_ellipses) \
5d074aa9
FF
292 (current_language->la_printstr(stream, string, length, force_ellipses))
293
5707ea9f
FF
294/* Test a character to decide whether it can be printed in literal form
295 or needs to be printed in another representation. For example,
296 in C the literal form of the character with octal value 141 is 'a'
297 and the "other representation" is '\141'. The "other representation"
298 is program language dependent. */
299
300#define PRINT_LITERAL_FORM(c) \
301 ((c)>=0x20 && ((c)<0x7F || (c)>=0xA0) && (!sevenbit_strings || (c)<0x80))
302
2e66cf7d
FF
303/* Return a format string for printf that will print a number in one of
304 the local (language-specific) formats. Result is static and is
305 overwritten by the next call. Takes printf options like "08" or "l"
306 (to produce e.g. %08x or %lx). */
c8023e66 307
58a66e24
FF
308extern char *
309local_decimal_format_custom PARAMS ((char *)); /* language.c */
310
2e66cf7d
FF
311extern char *
312local_octal_format_custom PARAMS ((char *)); /* language.c */
313
314extern char *
315local_hex_format_custom PARAMS ((char *)); /* language.c */
c8023e66 316
2e66cf7d
FF
317/* Return a string that contains a number formatted in one of the local
318 (language-specific) formats. Result is static and is overwritten by
319 the next call. Takes printf options like "08" or "l". */
320
321extern char *
322local_octal_string PARAMS ((int)); /* language.c */
323
324extern char *
325local_octal_string_custom PARAMS ((int, char *));/* language.c */
326
327extern char *
328local_hex_string PARAMS ((int)); /* language.c */
75af490b
JG
329
330extern char *
2e66cf7d 331local_hex_string_custom PARAMS ((int, char *)); /* language.c */
c8023e66
JG
332
333/* Type predicates */
75af490b
JG
334
335extern int
336simple_type PARAMS ((struct type *));
337
338extern int
339ordered_type PARAMS ((struct type *));
340
341extern int
342same_type PARAMS ((struct type *, struct type *));
343
344extern int
345integral_type PARAMS ((struct type *));
346
347extern int
348numeric_type PARAMS ((struct type *));
349
350extern int
351character_type PARAMS ((struct type *));
352
353extern int
354boolean_type PARAMS ((struct type *));
355
356extern int
357float_type PARAMS ((struct type *));
358
359extern int
360pointer_type PARAMS ((struct type *));
361
362extern int
363structured_type PARAMS ((struct type *));
c8023e66
JG
364
365/* Checks Binary and Unary operations for semantic type correctness */
75af490b 366/* FIXME: Does not appear to be used */
c8023e66
JG
367#define unop_type_check(v,o) binop_type_check((v),NULL,(o))
368
75af490b
JG
369extern void
370binop_type_check PARAMS ((struct value *, struct value *, int));
371
c8023e66 372/* Error messages */
75af490b
JG
373
374extern void
375op_error PARAMS ((char *fmt, enum exp_opcode, int));
376
c8023e66
JG
377#define type_op_error(f,o) \
378 op_error((f),(o),type_check==type_check_on ? 1 : 0)
379#define range_op_error(f,o) \
380 op_error((f),(o),range_check==range_check_on ? 1 : 0)
75af490b
JG
381
382extern void
383type_error ();
384
385void
386range_error ();
c8023e66
JG
387
388/* Data: Does this value represent "truth" to the current language? */
75af490b
JG
389
390extern int
391value_true PARAMS ((struct value *));
c8023e66
JG
392
393/* Misc: The string representing a particular enum language. */
75af490b 394
bf229b4e
FF
395extern const struct language_defn *
396language_def PARAMS ((enum language));
397
75af490b
JG
398extern char *
399language_str PARAMS ((enum language));
c8023e66
JG
400
401/* Add a language to the set known by GDB (at initialization time). */
d8ce1326 402
75af490b
JG
403extern void
404add_language PARAMS ((const struct language_defn *));
405
406extern enum language
407get_frame_language PARAMS ((void)); /* In stack.c */
408
409#endif /* defined (LANGUAGE_H) */
This page took 0.088763 seconds and 4 git commands to generate.