]> Git Repo - binutils.git/blob - gdb/language.h
z8000 documentation
[binutils.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 /* enum exp_opcode;     ANSI's `wisdom' didn't include forward enum decls. */
28 #endif
29
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
35 /* start-sanitize-chill */
36 #define _LANG_chill
37 /* end-sanitize-chill */
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
43 extern 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
50 extern 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
57 extern 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
64 extern enum type_check
65   {type_check_off, type_check_warn, type_check_on} type_check;
66 \f
67 /* Information for doing language dependent formatting of printed values. */
68
69 struct 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
98 /* Structure tying together assorted information about a language.  */
99
100 struct 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 */
107   int            (*la_parser) PARAMS((void));   /* Parser function */
108   void           (*la_error) PARAMS ((char *)); /* Parser error function */
109   struct type    **la_longest_int;      /* Longest signed integral type */
110   struct type    **la_longest_unsigned_int; /* Longest uns integral type */
111   struct type    **la_longest_float;    /* Longest floating point type */
112   struct language_format_info
113                    la_binary_format;    /* Base 2 (binary) formats. */
114   struct language_format_info
115                    la_octal_format;     /* Base 8 (octal) formats. */
116   struct language_format_info
117                    la_decimal_format;   /* Base 10 (decimal) formats */
118   struct language_format_info
119                    la_hex_format;       /* Base 16 (hexadecimal) formats */
120   const struct op_print
121                   *la_op_print_tab;     /* Table for printing expressions */
122 /* Add fields above this point, so the magic number is always last. */
123   long             la_magic;            /* Magic number for compat checking */
124 };
125
126 #define LANG_MAGIC      910823L
127
128 /* Pointer to the language_defn for our current language.  This pointer
129    always points to *some* valid struct; it can be used without checking
130    it for validity.  */
131
132 extern const struct language_defn *current_language;
133
134 /* Pointer to the language_defn expected by the user, e.g. the language
135    of main(), or the language we last mentioned in a message, or C.  */
136
137 extern const struct language_defn *expected_language;
138
139 /* language_mode == 
140    language_mode_auto:   current_language automatically set upon selection
141                          of scope (e.g. stack frame)
142    language_mode_manual: current_language set only by user.  */
143
144 extern enum language_mode
145   {language_mode_auto, language_mode_manual} language_mode;
146 \f
147 /* These macros define the behaviour of the expression 
148    evaluator.  */
149
150 /* Should we strictly type check expressions? */
151 #define STRICT_TYPE (type_check != type_check_off)
152
153 /* Should we range check values against the domain of their type? */
154 #define RANGE_CHECK (range_check != range_check_off)
155
156 /* "cast" really means conversion */
157 /* FIXME -- should be a setting in language_defn */
158 #define CAST_IS_CONVERSION (current_language->la_language == language_c)
159
160 extern void
161 language_info PARAMS ((int));
162
163 extern void
164 set_language PARAMS ((enum language));
165
166 \f
167 /* This page contains functions that return things that are
168    specific to languages.  Each of these functions is based on
169    the current setting of working_lang, which the user sets
170    with the "set language" command. */
171
172 /* Returns some built-in types */
173 #define longest_int()           (*current_language->la_longest_int)
174 #define longest_unsigned_int()  (*current_language->la_longest_unsigned_int)
175 #define longest_float()         (*current_language->la_longest_float)
176
177 /* Return a format string for printf that will print a number in one of
178    the local (language-specific) formats.  Result is static and is
179    overwritten by the next call.  Takes printf options like "08" or "l"
180    (to produce e.g. %08x or %lx).  */
181
182 #define local_binary_format() \
183   (current_language->la_binary_format.la_format)
184 #define local_binary_format_prefix() \
185   (current_language->la_binary_format.la_format_prefix)
186 #define local_binary_format_specifier() \
187   (current_language->la_binary_format.la_format_specifier)
188 #define local_binary_format_suffix() \
189   (current_language->la_binary_format.la_format_suffix)
190
191 #define local_octal_format() \
192   (current_language->la_octal_format.la_format)
193 #define local_octal_format_prefix() \
194   (current_language->la_octal_format.la_format_prefix)
195 #define local_octal_format_specifier() \
196   (current_language->la_octal_format.la_format_specifier)
197 #define local_octal_format_suffix() \
198   (current_language->la_octal_format.la_format_suffix)
199
200 #define local_decimal_format() \
201   (current_language->la_decimal_format.la_format)
202 #define local_decimal_format_prefix() \
203   (current_language->la_decimal_format.la_format_prefix)
204 #define local_decimal_format_specifier() \
205   (current_language->la_decimal_format.la_format_specifier)
206 #define local_decimal_format_suffix() \
207   (current_language->la_decimal_format.la_format_suffix)
208
209 #define local_hex_format() \
210   (current_language->la_hex_format.la_format)
211 #define local_hex_format_prefix() \
212   (current_language->la_hex_format.la_format_prefix)
213 #define local_hex_format_specifier() \
214   (current_language->la_hex_format.la_format_specifier)
215 #define local_hex_format_suffix() \
216   (current_language->la_hex_format.la_format_suffix)
217
218 /* Return a format string for printf that will print a number in one of
219    the local (language-specific) formats.  Result is static and is
220    overwritten by the next call.  Takes printf options like "08" or "l"
221    (to produce e.g. %08x or %lx).  */
222
223 extern char *
224 local_octal_format_custom PARAMS ((char *));    /* language.c */
225
226 extern char *
227 local_hex_format_custom PARAMS ((char *));      /* language.c */
228
229 /* Return a string that contains a number formatted in one of the local
230    (language-specific) formats.  Result is static and is overwritten by
231    the next call.  Takes printf options like "08" or "l".  */
232
233 extern char *
234 local_octal_string PARAMS ((int));              /* language.c */
235
236 extern char *
237 local_octal_string_custom PARAMS ((int, char *));/* language.c */
238
239 extern char *
240 local_hex_string PARAMS ((int));                /* language.c */
241
242 extern char *
243 local_hex_string_custom PARAMS ((int, char *)); /* language.c */
244
245 /* Type predicates */
246
247 extern int
248 simple_type PARAMS ((struct type *));
249
250 extern int
251 ordered_type PARAMS ((struct type *));
252
253 extern int
254 same_type PARAMS ((struct type *, struct type *));
255
256 extern int
257 integral_type PARAMS ((struct type *));
258
259 extern int
260 numeric_type PARAMS ((struct type *));
261
262 extern int
263 character_type PARAMS ((struct type *));
264
265 extern int
266 boolean_type PARAMS ((struct type *));
267
268 extern int
269 float_type PARAMS ((struct type *));
270
271 extern int
272 pointer_type PARAMS ((struct type *));
273
274 extern int
275 structured_type PARAMS ((struct type *));
276
277 /* Checks Binary and Unary operations for semantic type correctness */
278 /* FIXME:  Does not appear to be used */
279 #define unop_type_check(v,o) binop_type_check((v),NULL,(o))
280
281 extern void
282 binop_type_check PARAMS ((struct value *, struct value *, int));
283
284 /* Error messages */
285
286 extern void
287 op_error PARAMS ((char *fmt, enum exp_opcode, int));
288
289 #define type_op_error(f,o) \
290    op_error((f),(o),type_check==type_check_on ? 1 : 0)
291 #define range_op_error(f,o) \
292    op_error((f),(o),range_check==range_check_on ? 1 : 0)
293
294 extern void
295 type_error ();
296
297 void
298 range_error ();
299
300 /* Data:  Does this value represent "truth" to the current language?  */
301
302 extern int
303 value_true PARAMS ((struct value *));
304
305 /* Misc:  The string representing a particular enum language.  */
306
307 extern char *
308 language_str PARAMS ((enum language));
309
310 /* Add a language to the set known by GDB (at initialization time).  */
311
312 extern void
313 add_language PARAMS ((const struct language_defn *));
314
315 extern enum language
316 get_frame_language PARAMS ((void));             /* In stack.c */
317
318 #endif  /* defined (LANGUAGE_H) */
This page took 0.04332 seconds and 4 git commands to generate.