]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | ||
75af490b JG |
22 | #if !defined (LANGUAGE_H) |
23 | #define LANGUAGE_H 1 | |
24 | ||
f9e3b3cc | 25 | #ifdef __STDC__ /* Forward decls for prototypes */ |
75af490b | 26 | struct 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 | ||
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 | /* Structure tying together assorted information about a language. */ | |
68 | ||
69 | struct language_defn { | |
70 | char * la_name; /* Name of the language */ | |
71 | enum language la_language; /* its symtab language-enum (defs.h) */ | |
72 | struct type ** const | |
73 | *la_builtin_type_vector; /* Its builtin types */ | |
74 | enum range_check la_range_check; /* Default range checking */ | |
75 | enum type_check la_type_check; /* Default type checking */ | |
75af490b JG |
76 | int (*la_parser) PARAMS((void)); /* Parser function */ |
77 | void (*la_error) PARAMS ((char *)); /* Parser error function */ | |
c8023e66 JG |
78 | struct type **la_longest_int; /* Longest signed integral type */ |
79 | struct type **la_longest_unsigned_int; /* Longest uns integral type */ | |
80 | struct type **la_longest_float; /* Longest floating point type */ | |
81 | char *la_hex_format; /* Hexadecimal printf format str */ | |
82 | char *la_hex_format_pre; /* Prefix for custom format string */ | |
83 | char *la_hex_format_suf; /* Suffix for custom format string */ | |
84 | char *la_octal_format; /* Octal printf format str */ | |
85 | char *la_octal_format_pre; /* Prefix for custom format string */ | |
86 | char *la_octal_format_suf; /* Suffix for custom format string */ | |
87 | const struct op_print | |
88 | *la_op_print_tab; /* Table for printing expressions */ | |
89 | /* Add fields above this point, so the magic number is always last. */ | |
90 | long la_magic; /* Magic number for compat checking */ | |
91 | }; | |
92 | ||
93 | #define LANG_MAGIC 910823L | |
94 | ||
95 | /* Pointer to the language_defn for our current language. This pointer | |
96 | always points to *some* valid struct; it can be used without checking | |
97 | it for validity. */ | |
98 | ||
0c6efbcc | 99 | extern const struct language_defn *current_language; |
c8023e66 | 100 | |
b5af69c3 JG |
101 | /* Pointer to the language_defn expected by the user, e.g. the language |
102 | of main(), or the language we last mentioned in a message, or C. */ | |
103 | ||
104 | extern const struct language_defn *expected_language; | |
105 | ||
c8023e66 JG |
106 | /* language_mode == |
107 | language_mode_auto: current_language automatically set upon selection | |
108 | of scope (e.g. stack frame) | |
109 | language_mode_manual: current_language set only by user. */ | |
110 | ||
111 | extern enum language_mode | |
112 | {language_mode_auto, language_mode_manual} language_mode; | |
113 | \f | |
114 | /* These macros define the behaviour of the expression | |
115 | evaluator. */ | |
116 | ||
117 | /* Should we strictly type check expressions? */ | |
1a5a8f2a | 118 | #define STRICT_TYPE (type_check != type_check_off) |
c8023e66 JG |
119 | |
120 | /* Should we range check values against the domain of their type? */ | |
1a5a8f2a | 121 | #define RANGE_CHECK (range_check != range_check_off) |
c8023e66 JG |
122 | |
123 | /* "cast" really means conversion */ | |
124 | /* FIXME -- should be a setting in language_defn */ | |
125 | #define CAST_IS_CONVERSION (current_language->la_language == language_c) | |
126 | ||
75af490b JG |
127 | extern void |
128 | language_info PARAMS ((int)); | |
129 | ||
130 | extern void | |
131 | set_language PARAMS ((enum language)); | |
132 | ||
c8023e66 JG |
133 | \f |
134 | /* This page contains functions that return things that are | |
135 | specific to languages. Each of these functions is based on | |
136 | the current setting of working_lang, which the user sets | |
137 | with the "set language" command. */ | |
138 | ||
139 | /* Returns some built-in types */ | |
140 | #define longest_int() (*current_language->la_longest_int) | |
141 | #define longest_unsigned_int() (*current_language->la_longest_unsigned_int) | |
142 | #define longest_float() (*current_language->la_longest_float) | |
c8023e66 JG |
143 | |
144 | /* Hexadecimal number formatting is in defs.h because it is so common | |
145 | throughout GDB. */ | |
146 | ||
147 | /* Return a format string for printf that will print a number in the local | |
148 | (language-specific) octal format. Result is static and is | |
149 | overwritten by the next call. local_octal_format_custom takes printf | |
150 | options like "08" or "l" (to produce e.g. %08x or %lx). */ | |
151 | ||
152 | #define local_octal_format() (current_language->la_octal_format) | |
75af490b JG |
153 | |
154 | extern char * | |
155 | local_octal_format_custom PARAMS ((char *)); | |
c8023e66 JG |
156 | |
157 | /* Type predicates */ | |
75af490b JG |
158 | |
159 | extern int | |
160 | simple_type PARAMS ((struct type *)); | |
161 | ||
162 | extern int | |
163 | ordered_type PARAMS ((struct type *)); | |
164 | ||
165 | extern int | |
166 | same_type PARAMS ((struct type *, struct type *)); | |
167 | ||
168 | extern int | |
169 | integral_type PARAMS ((struct type *)); | |
170 | ||
171 | extern int | |
172 | numeric_type PARAMS ((struct type *)); | |
173 | ||
174 | extern int | |
175 | character_type PARAMS ((struct type *)); | |
176 | ||
177 | extern int | |
178 | boolean_type PARAMS ((struct type *)); | |
179 | ||
180 | extern int | |
181 | float_type PARAMS ((struct type *)); | |
182 | ||
183 | extern int | |
184 | pointer_type PARAMS ((struct type *)); | |
185 | ||
186 | extern int | |
187 | structured_type PARAMS ((struct type *)); | |
c8023e66 JG |
188 | |
189 | /* Checks Binary and Unary operations for semantic type correctness */ | |
75af490b | 190 | /* FIXME: Does not appear to be used */ |
c8023e66 JG |
191 | #define unop_type_check(v,o) binop_type_check((v),NULL,(o)) |
192 | ||
75af490b JG |
193 | extern void |
194 | binop_type_check PARAMS ((struct value *, struct value *, int)); | |
195 | ||
c8023e66 | 196 | /* Error messages */ |
75af490b JG |
197 | |
198 | extern void | |
199 | op_error PARAMS ((char *fmt, enum exp_opcode, int)); | |
200 | ||
c8023e66 JG |
201 | #define type_op_error(f,o) \ |
202 | op_error((f),(o),type_check==type_check_on ? 1 : 0) | |
203 | #define range_op_error(f,o) \ | |
204 | op_error((f),(o),range_check==range_check_on ? 1 : 0) | |
75af490b JG |
205 | |
206 | extern void | |
207 | type_error (); | |
208 | ||
209 | void | |
210 | range_error (); | |
c8023e66 JG |
211 | |
212 | /* Data: Does this value represent "truth" to the current language? */ | |
75af490b JG |
213 | |
214 | extern int | |
215 | value_true PARAMS ((struct value *)); | |
c8023e66 JG |
216 | |
217 | /* Misc: The string representing a particular enum language. */ | |
75af490b JG |
218 | |
219 | extern char * | |
220 | language_str PARAMS ((enum language)); | |
c8023e66 JG |
221 | |
222 | /* Add a language to the set known by GDB (at initialization time). */ | |
d8ce1326 | 223 | |
75af490b JG |
224 | extern void |
225 | add_language PARAMS ((const struct language_defn *)); | |
226 | ||
227 | extern enum language | |
228 | get_frame_language PARAMS ((void)); /* In stack.c */ | |
229 | ||
230 | #endif /* defined (LANGUAGE_H) */ |