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