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