Corrected spelling error in comment: swaped -> swapped.
[deliverable/binutils-gdb.git] / gdb / language.c
... / ...
CommitLineData
1/* Multiple source language support for GDB.
2 Copyright 1991, 1992, 2000 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., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
22
23/* This file contains functions that return things that are specific
24 to languages. Each function should examine current_language if necessary,
25 and return the appropriate result. */
26
27/* FIXME: Most of these would be better organized as macros which
28 return data out of a "language-specific" struct pointer that is set
29 whenever the working language changes. That would be a lot faster. */
30
31#include "defs.h"
32#include <ctype.h>
33#include "gdb_string.h"
34
35#include "symtab.h"
36#include "gdbtypes.h"
37#include "value.h"
38#include "gdbcmd.h"
39#include "frame.h"
40#include "expression.h"
41#include "language.h"
42#include "target.h"
43#include "parser-defs.h"
44#include "jv-lang.h"
45
46extern void _initialize_language (void);
47
48static void show_language_command (char *, int);
49
50static void set_language_command (char *, int);
51
52static void show_type_command (char *, int);
53
54static void set_type_command (char *, int);
55
56static void show_range_command (char *, int);
57
58static void set_range_command (char *, int);
59
60static void show_case_command (char *, int);
61
62static void set_case_command (char *, int);
63
64static void set_case_str (void);
65
66static void set_range_str (void);
67
68static void set_type_str (void);
69
70static void set_lang_str (void);
71
72static void unk_lang_error (char *);
73
74static int unk_lang_parser (void);
75
76static void show_check (char *, int);
77
78static void set_check (char *, int);
79
80static void set_type_range_case (void);
81
82static void unk_lang_emit_char (int c, struct ui_file *stream, int quoter);
83
84static void unk_lang_printchar (int c, struct ui_file *stream);
85
86static void unk_lang_printstr (struct ui_file * stream, char *string,
87 unsigned int length, int width,
88 int force_ellipses);
89
90static struct type *unk_lang_create_fundamental_type (struct objfile *, int);
91
92static void unk_lang_print_type (struct type *, char *, struct ui_file *,
93 int, int);
94
95static int unk_lang_val_print (struct type *, char *, int, CORE_ADDR,
96 struct ui_file *, int, int, int,
97 enum val_prettyprint);
98
99static int unk_lang_value_print (value_ptr, struct ui_file *, int, enum val_prettyprint);
100
101/* Forward declaration */
102extern const struct language_defn unknown_language_defn;
103extern char *warning_pre_print;
104
105/* The current (default at startup) state of type and range checking.
106 (If the modes are set to "auto", though, these are changed based
107 on the default language at startup, and then again based on the
108 language of the first source file. */
109
110enum range_mode range_mode = range_mode_auto;
111enum range_check range_check = range_check_off;
112enum type_mode type_mode = type_mode_auto;
113enum type_check type_check = type_check_off;
114enum case_mode case_mode = case_mode_auto;
115enum case_sensitivity case_sensitivity = case_sensitive_on;
116
117/* The current language and language_mode (see language.h) */
118
119const struct language_defn *current_language = &unknown_language_defn;
120enum language_mode language_mode = language_mode_auto;
121
122/* The language that the user expects to be typing in (the language
123 of main(), or the last language we notified them about, or C). */
124
125const struct language_defn *expected_language;
126
127/* The list of supported languages. The list itself is malloc'd. */
128
129static const struct language_defn **languages;
130static unsigned languages_size;
131static unsigned languages_allocsize;
132#define DEFAULT_ALLOCSIZE 4
133
134/* The "set language/type/range" commands all put stuff in these
135 buffers. This is to make them work as set/show commands. The
136 user's string is copied here, then the set_* commands look at
137 them and update them to something that looks nice when it is
138 printed out. */
139
140static char *language;
141static char *type;
142static char *range;
143static char *case_sensitive;
144
145/* Warning issued when current_language and the language of the current
146 frame do not match. */
147char lang_frame_mismatch_warn[] =
148"Warning: the current language does not match this frame.";
149\f
150
151/* This page contains the functions corresponding to GDB commands
152 and their helpers. */
153
154/* Show command. Display a warning if the language set
155 does not match the frame. */
156static void
157show_language_command (char *ignore, int from_tty)
158{
159 enum language flang; /* The language of the current frame */
160
161 flang = get_frame_language ();
162 if (flang != language_unknown &&
163 language_mode == language_mode_manual &&
164 current_language->la_language != flang)
165 printf_filtered ("%s\n", lang_frame_mismatch_warn);
166}
167
168/* Set command. Change the current working language. */
169static void
170set_language_command (char *ignore, int from_tty)
171{
172 int i;
173 enum language flang;
174 char *err_lang;
175
176 if (!language || !language[0])
177 {
178 printf_unfiltered ("The currently understood settings are:\n\n");
179 printf_unfiltered ("local or auto Automatic setting based on source file\n");
180
181 for (i = 0; i < languages_size; ++i)
182 {
183 /* Already dealt with these above. */
184 if (languages[i]->la_language == language_unknown
185 || languages[i]->la_language == language_auto)
186 continue;
187
188 /* FIXME for now assume that the human-readable name is just
189 a capitalization of the internal name. */
190 printf_unfiltered ("%-16s Use the %c%s language\n",
191 languages[i]->la_name,
192 /* Capitalize first letter of language
193 name. */
194 toupper (languages[i]->la_name[0]),
195 languages[i]->la_name + 1);
196 }
197 /* Restore the silly string. */
198 set_language (current_language->la_language);
199 return;
200 }
201
202 /* Search the list of languages for a match. */
203 for (i = 0; i < languages_size; i++)
204 {
205 if (STREQ (languages[i]->la_name, language))
206 {
207 /* Found it! Go into manual mode, and use this language. */
208 if (languages[i]->la_language == language_auto)
209 {
210 /* Enter auto mode. Set to the current frame's language, if known. */
211 language_mode = language_mode_auto;
212 flang = get_frame_language ();
213 if (flang != language_unknown)
214 set_language (flang);
215 expected_language = current_language;
216 return;
217 }
218 else
219 {
220 /* Enter manual mode. Set the specified language. */
221 language_mode = language_mode_manual;
222 current_language = languages[i];
223 set_type_range_case ();
224 set_lang_str ();
225 expected_language = current_language;
226 return;
227 }
228 }
229 }
230
231 /* Reset the language (esp. the global string "language") to the
232 correct values. */
233 err_lang = savestring (language, strlen (language));
234 make_cleanup (free, err_lang); /* Free it after error */
235 set_language (current_language->la_language);
236 error ("Unknown language `%s'.", err_lang);
237}
238
239/* Show command. Display a warning if the type setting does
240 not match the current language. */
241static void
242show_type_command (char *ignore, int from_tty)
243{
244 if (type_check != current_language->la_type_check)
245 printf_unfiltered (
246 "Warning: the current type check setting does not match the language.\n");
247}
248
249/* Set command. Change the setting for type checking. */
250static void
251set_type_command (char *ignore, int from_tty)
252{
253 if (STREQ (type, "on"))
254 {
255 type_check = type_check_on;
256 type_mode = type_mode_manual;
257 }
258 else if (STREQ (type, "warn"))
259 {
260 type_check = type_check_warn;
261 type_mode = type_mode_manual;
262 }
263 else if (STREQ (type, "off"))
264 {
265 type_check = type_check_off;
266 type_mode = type_mode_manual;
267 }
268 else if (STREQ (type, "auto"))
269 {
270 type_mode = type_mode_auto;
271 set_type_range_case ();
272 /* Avoid hitting the set_type_str call below. We
273 did it in set_type_range_case. */
274 return;
275 }
276 else
277 {
278 warning ("Unrecognized type check setting: \"%s\"", type);
279 }
280 set_type_str ();
281 show_type_command ((char *) NULL, from_tty);
282}
283
284/* Show command. Display a warning if the range setting does
285 not match the current language. */
286static void
287show_range_command (char *ignore, int from_tty)
288{
289
290 if (range_check != current_language->la_range_check)
291 printf_unfiltered (
292 "Warning: the current range check setting does not match the language.\n");
293}
294
295/* Set command. Change the setting for range checking. */
296static void
297set_range_command (char *ignore, int from_tty)
298{
299 if (STREQ (range, "on"))
300 {
301 range_check = range_check_on;
302 range_mode = range_mode_manual;
303 }
304 else if (STREQ (range, "warn"))
305 {
306 range_check = range_check_warn;
307 range_mode = range_mode_manual;
308 }
309 else if (STREQ (range, "off"))
310 {
311 range_check = range_check_off;
312 range_mode = range_mode_manual;
313 }
314 else if (STREQ (range, "auto"))
315 {
316 range_mode = range_mode_auto;
317 set_type_range_case ();
318 /* Avoid hitting the set_range_str call below. We
319 did it in set_type_range_case. */
320 return;
321 }
322 else
323 {
324 warning ("Unrecognized range check setting: \"%s\"", range);
325 }
326 set_range_str ();
327 show_range_command ((char *) 0, from_tty);
328}
329
330/* Show command. Display a warning if the case sensitivity setting does
331 not match the current language. */
332static void
333show_case_command(ignore, from_tty)
334 char *ignore;
335 int from_tty;
336{
337 if (case_sensitivity != current_language->la_case_sensitivity)
338 printf_unfiltered(
339"Warning: the current case sensitivity setting does not match the language.\n");
340}
341
342/* Set command. Change the setting for case sensitivity. */
343static void
344set_case_command(ignore, from_tty)
345 char *ignore;
346 int from_tty;
347{
348 if (STREQ (case_sensitive, "on"))
349 {
350 case_sensitivity = case_sensitive_on;
351 case_mode = case_mode_manual;
352 }
353 else if (STREQ (case_sensitive, "off"))
354 {
355 case_sensitivity = case_sensitive_off;
356 case_mode = case_mode_manual;
357 }
358 else if (STREQ (case_sensitive, "auto"))
359 {
360 case_mode = case_mode_auto;
361 set_type_range_case ();
362 /* Avoid hitting the set_case_str call below. We
363 did it in set_type_range_case. */
364 return;
365 }
366 else
367 {
368 warning ("Unrecognized case-sensitive setting: \"%s\"", case_sensitive);
369 }
370 set_case_str();
371 show_case_command ((char *) NULL, from_tty);
372}
373
374/* Set the status of range and type checking and case sensitivity based on
375 the current modes and the current language.
376 If SHOW is non-zero, then print out the current language,
377 type and range checking status. */
378static void
379set_type_range_case (void)
380{
381
382 if (range_mode == range_mode_auto)
383 range_check = current_language->la_range_check;
384
385 if (type_mode == type_mode_auto)
386 type_check = current_language->la_type_check;
387
388 if (case_mode == case_mode_auto)
389 case_sensitivity = current_language->la_case_sensitivity;
390
391 set_type_str ();
392 set_range_str ();
393 set_case_str ();
394}
395
396/* Set current language to (enum language) LANG. Returns previous language. */
397
398enum language
399set_language (enum language lang)
400{
401 int i;
402 enum language prev_language;
403
404 prev_language = current_language->la_language;
405
406 for (i = 0; i < languages_size; i++)
407 {
408 if (languages[i]->la_language == lang)
409 {
410 current_language = languages[i];
411 set_type_range_case ();
412 set_lang_str ();
413 break;
414 }
415 }
416
417 return prev_language;
418}
419\f
420/* This page contains functions that update the global vars
421 language, type and range. */
422static void
423set_lang_str (void)
424{
425 char *prefix = "";
426
427 if (language)
428 free (language);
429 if (language_mode == language_mode_auto)
430 prefix = "auto; currently ";
431
432 language = concat (prefix, current_language->la_name, NULL);
433}
434
435static void
436set_type_str (void)
437{
438 char *tmp = NULL, *prefix = "";
439
440 if (type)
441 free (type);
442 if (type_mode == type_mode_auto)
443 prefix = "auto; currently ";
444
445 switch (type_check)
446 {
447 case type_check_on:
448 tmp = "on";
449 break;
450 case type_check_off:
451 tmp = "off";
452 break;
453 case type_check_warn:
454 tmp = "warn";
455 break;
456 default:
457 error ("Unrecognized type check setting.");
458 }
459
460 type = concat (prefix, tmp, NULL);
461}
462
463static void
464set_range_str (void)
465{
466 char *tmp, *pref = "";
467
468 if (range_mode == range_mode_auto)
469 pref = "auto; currently ";
470
471 switch (range_check)
472 {
473 case range_check_on:
474 tmp = "on";
475 break;
476 case range_check_off:
477 tmp = "off";
478 break;
479 case range_check_warn:
480 tmp = "warn";
481 break;
482 default:
483 error ("Unrecognized range check setting.");
484 }
485
486 if (range)
487 free (range);
488 range = concat (pref, tmp, NULL);
489}
490
491static void
492set_case_str()
493{
494 char *tmp = NULL, *prefix = "";
495
496 if (case_mode==case_mode_auto)
497 prefix = "auto; currently ";
498
499 switch (case_sensitivity)
500 {
501 case case_sensitive_on:
502 tmp = "on";
503 break;
504 case case_sensitive_off:
505 tmp = "off";
506 break;
507 default:
508 error ("Unrecognized case-sensitive setting.");
509 }
510
511 free (case_sensitive);
512 case_sensitive = concat (prefix, tmp, NULL);
513}
514
515/* Print out the current language settings: language, range and
516 type checking. If QUIETLY, print only what has changed. */
517
518void
519language_info (int quietly)
520{
521 if (quietly && expected_language == current_language)
522 return;
523
524 expected_language = current_language;
525 printf_unfiltered ("Current language: %s\n", language);
526 show_language_command ((char *) 0, 1);
527
528 if (!quietly)
529 {
530 printf_unfiltered ("Type checking: %s\n", type);
531 show_type_command ((char *) 0, 1);
532 printf_unfiltered ("Range checking: %s\n", range);
533 show_range_command ((char *) 0, 1);
534 printf_unfiltered ("Case sensitivity: %s\n", case_sensitive);
535 show_case_command ((char *) 0, 1);
536 }
537}
538\f
539/* Return the result of a binary operation. */
540
541#if 0 /* Currently unused */
542
543struct type *
544binop_result_type (value_ptr v1, value_ptr v2)
545{
546 int size, uns;
547 struct type *t1 = check_typedef (VALUE_TYPE (v1));
548 struct type *t2 = check_typedef (VALUE_TYPE (v2));
549
550 int l1 = TYPE_LENGTH (t1);
551 int l2 = TYPE_LENGTH (t2);
552
553 switch (current_language->la_language)
554 {
555 case language_c:
556 case language_cplus:
557 if (TYPE_CODE (t1) == TYPE_CODE_FLT)
558 return TYPE_CODE (t2) == TYPE_CODE_FLT && l2 > l1 ?
559 VALUE_TYPE (v2) : VALUE_TYPE (v1);
560 else if (TYPE_CODE (t2) == TYPE_CODE_FLT)
561 return TYPE_CODE (t1) == TYPE_CODE_FLT && l1 > l2 ?
562 VALUE_TYPE (v1) : VALUE_TYPE (v2);
563 else if (TYPE_UNSIGNED (t1) && l1 > l2)
564 return VALUE_TYPE (v1);
565 else if (TYPE_UNSIGNED (t2) && l2 > l1)
566 return VALUE_TYPE (v2);
567 else /* Both are signed. Result is the longer type */
568 return l1 > l2 ? VALUE_TYPE (v1) : VALUE_TYPE (v2);
569 break;
570 case language_m2:
571 /* If we are doing type-checking, l1 should equal l2, so this is
572 not needed. */
573 return l1 > l2 ? VALUE_TYPE (v1) : VALUE_TYPE (v2);
574 break;
575 case language_chill:
576 error ("Missing Chill support in function binop_result_check."); /*FIXME */
577 }
578 abort ();
579 return (struct type *) 0; /* For lint */
580}
581
582#endif /* 0 */
583\f
584
585/* This page contains functions that return format strings for
586 printf for printing out numbers in different formats */
587
588/* Returns the appropriate printf format for hexadecimal
589 numbers. */
590char *
591local_hex_format_custom (char *pre)
592{
593 static char form[50];
594
595 strcpy (form, local_hex_format_prefix ());
596 strcat (form, "%");
597 strcat (form, pre);
598 strcat (form, local_hex_format_specifier ());
599 strcat (form, local_hex_format_suffix ());
600 return form;
601}
602
603#if 0
604/* FIXME: cagney/2000-03-04: This function does not appear to be used.
605 It can be deleted once 5.0 has been released. */
606/* FIXME: cagney/2000-03-04: This code assumes that the compiler
607 supports ``long long''. */
608/* Converts a number to hexadecimal (without leading "0x") and stores it in a
609 static string. Returns a pointer to this string. */
610
611char *
612longest_raw_hex_string (LONGEST num)
613{
614 static char res_longest_raw_hex_string[50];
615 long long ll = num; /* MERGEBUG ?? see below */
616 res_longest_raw_hex_string[0] = 0;
617 /* MERGEBUG ?? As a quick fix I am replacing this with sprintf
618 strcat_address_numeric (num, 0, res_longest_raw_hex_string, 50);
619 */
620
621 sprintf (res_longest_raw_hex_string, "%llx", ll);
622 return res_longest_raw_hex_string;
623}
624#endif
625
626/* Converts a number to hexadecimal and stores it in a static
627 string. Returns a pointer to this string. */
628char *
629local_hex_string (unsigned long num)
630{
631 static char res[50];
632
633 sprintf (res, local_hex_format (), num);
634 return res;
635}
636
637/* Converts a LONGEST number to hexadecimal and stores it in a static
638 string. Returns a pointer to this string. */
639char *
640longest_local_hex_string (LONGEST num)
641{
642 return longest_local_hex_string_custom (num, "l");
643}
644
645/* Converts a number to custom hexadecimal and stores it in a static
646 string. Returns a pointer to this string. */
647char *
648local_hex_string_custom (unsigned long num, char *pre)
649{
650 static char res[50];
651
652 sprintf (res, local_hex_format_custom (pre), num);
653 return res;
654}
655
656/* Converts a LONGEST number to custom hexadecimal and stores it in a static
657 string. Returns a pointer to this string. Note that the width parameter
658 should end with "l", e.g. "08l" as with calls to local_hex_string_custom */
659
660char *
661longest_local_hex_string_custom (LONGEST num, char *width)
662{
663#define RESULT_BUF_LEN 50
664 static char res2[RESULT_BUF_LEN];
665 char format[RESULT_BUF_LEN];
666#if !defined (PRINTF_HAS_LONG_LONG)
667 int field_width;
668 int num_len;
669 int num_pad_chars;
670 char *pad_char; /* string with one character */
671 int pad_on_left;
672 char *parse_ptr;
673 char temp_nbr_buf[RESULT_BUF_LEN];
674#endif
675
676#ifndef CC_HAS_LONG_LONG
677 /* If there is no long long, then LONGEST should be just long and we
678 can use local_hex_string_custom
679 */
680 return local_hex_string_custom ((unsigned long) num, width);
681#elif defined (PRINTF_HAS_LONG_LONG)
682 /* Just use printf. */
683 strcpy (format, local_hex_format_prefix ()); /* 0x */
684 strcat (format, "%");
685 strcat (format, width); /* e.g. "08l" */
686 strcat (format, "l"); /* need "ll" for long long */
687 strcat (format, local_hex_format_specifier ()); /* "x" */
688 strcat (format, local_hex_format_suffix ()); /* "" */
689 sprintf (res2, format, num);
690 return res2;
691#else /* !defined (PRINTF_HAS_LONG_LONG) */
692 /* Use strcat_address_numeric to print the number into a string, then
693 build the result string from local_hex_format_prefix, padding and
694 the hex representation as indicated by "width". */
695
696 temp_nbr_buf[0] = 0;
697 /* With use_local == 0, we don't get the leading "0x" prefix. */
698 /* MERGEBUG ?? As a quick fix I am replacing this call to
699 strcat_address_numeric with sprintf
700 strcat_address_numeric(num, 0, temp_nbr_buf, RESULT_BUF_LEN);
701 */
702
703 {
704 long long ll = num;
705 sprintf (temp_nbr_buf, "%llx", ll);
706 }
707 /* parse width */
708 parse_ptr = width;
709 pad_on_left = 1;
710 pad_char = " ";
711 if (*parse_ptr == '-')
712 {
713 parse_ptr++;
714 pad_on_left = 0;
715 }
716 if (*parse_ptr == '0')
717 {
718 parse_ptr++;
719 if (pad_on_left)
720 pad_char = "0"; /* If padding is on the right, it is blank */
721 }
722 field_width = atoi (parse_ptr);
723 num_len = strlen (temp_nbr_buf);
724 num_pad_chars = field_width - strlen (temp_nbr_buf); /* possibly negative */
725
726 if (strlen (local_hex_format_prefix ()) + num_len + num_pad_chars
727 < RESULT_BUF_LEN) /* paranoia */
728 internal_error ("longest_local_hex_string_custom: insufficient space to store result");
729
730 strcpy (res2, local_hex_format_prefix ());
731 if (pad_on_left)
732 {
733 while (num_pad_chars > 0)
734 {
735 strcat (res2, pad_char);
736 num_pad_chars--;
737 }
738 }
739 strcat (res2, temp_nbr_buf);
740 if (!pad_on_left)
741 {
742 while (num_pad_chars > 0)
743 {
744 strcat (res2, pad_char);
745 num_pad_chars--;
746 }
747 }
748 return res2;
749#endif
750
751} /* longest_local_hex_string_custom */
752
753/* Returns the appropriate printf format for octal
754 numbers. */
755char *
756local_octal_format_custom (char *pre)
757{
758 static char form[50];
759
760 strcpy (form, local_octal_format_prefix ());
761 strcat (form, "%");
762 strcat (form, pre);
763 strcat (form, local_octal_format_specifier ());
764 strcat (form, local_octal_format_suffix ());
765 return form;
766}
767
768/* Returns the appropriate printf format for decimal numbers. */
769char *
770local_decimal_format_custom (char *pre)
771{
772 static char form[50];
773
774 strcpy (form, local_decimal_format_prefix ());
775 strcat (form, "%");
776 strcat (form, pre);
777 strcat (form, local_decimal_format_specifier ());
778 strcat (form, local_decimal_format_suffix ());
779 return form;
780}
781\f
782#if 0
783/* This page contains functions that are used in type/range checking.
784 They all return zero if the type/range check fails.
785
786 It is hoped that these will make extending GDB to parse different
787 languages a little easier. These are primarily used in eval.c when
788 evaluating expressions and making sure that their types are correct.
789 Instead of having a mess of conjucted/disjuncted expressions in an "if",
790 the ideas of type can be wrapped up in the following functions.
791
792 Note that some of them are not currently dependent upon which language
793 is currently being parsed. For example, floats are the same in
794 C and Modula-2 (ie. the only floating point type has TYPE_CODE of
795 TYPE_CODE_FLT), while booleans are different. */
796
797/* Returns non-zero if its argument is a simple type. This is the same for
798 both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur,
799 and thus will never cause the failure of the test. */
800int
801simple_type (struct type *type)
802{
803 CHECK_TYPEDEF (type);
804 switch (TYPE_CODE (type))
805 {
806 case TYPE_CODE_INT:
807 case TYPE_CODE_CHAR:
808 case TYPE_CODE_ENUM:
809 case TYPE_CODE_FLT:
810 case TYPE_CODE_RANGE:
811 case TYPE_CODE_BOOL:
812 return 1;
813
814 default:
815 return 0;
816 }
817}
818
819/* Returns non-zero if its argument is of an ordered type.
820 An ordered type is one in which the elements can be tested for the
821 properties of "greater than", "less than", etc, or for which the
822 operations "increment" or "decrement" make sense. */
823int
824ordered_type (struct type *type)
825{
826 CHECK_TYPEDEF (type);
827 switch (TYPE_CODE (type))
828 {
829 case TYPE_CODE_INT:
830 case TYPE_CODE_CHAR:
831 case TYPE_CODE_ENUM:
832 case TYPE_CODE_FLT:
833 case TYPE_CODE_RANGE:
834 return 1;
835
836 default:
837 return 0;
838 }
839}
840
841/* Returns non-zero if the two types are the same */
842int
843same_type (struct type *arg1, struct type *arg2)
844{
845 CHECK_TYPEDEF (type);
846 if (structured_type (arg1) ? !structured_type (arg2) : structured_type (arg2))
847 /* One is structured and one isn't */
848 return 0;
849 else if (structured_type (arg1) && structured_type (arg2))
850 return arg1 == arg2;
851 else if (numeric_type (arg1) && numeric_type (arg2))
852 return (TYPE_CODE (arg2) == TYPE_CODE (arg1)) &&
853 (TYPE_UNSIGNED (arg1) == TYPE_UNSIGNED (arg2))
854 ? 1 : 0;
855 else
856 return arg1 == arg2;
857}
858
859/* Returns non-zero if the type is integral */
860int
861integral_type (struct type *type)
862{
863 CHECK_TYPEDEF (type);
864 switch (current_language->la_language)
865 {
866 case language_c:
867 case language_cplus:
868 return (TYPE_CODE (type) != TYPE_CODE_INT) &&
869 (TYPE_CODE (type) != TYPE_CODE_ENUM) ? 0 : 1;
870 case language_m2:
871 case language_pascal:
872 return TYPE_CODE (type) != TYPE_CODE_INT ? 0 : 1;
873 case language_chill:
874 error ("Missing Chill support in function integral_type."); /*FIXME */
875 default:
876 error ("Language not supported.");
877 }
878}
879
880/* Returns non-zero if the value is numeric */
881int
882numeric_type (struct type *type)
883{
884 CHECK_TYPEDEF (type);
885 switch (TYPE_CODE (type))
886 {
887 case TYPE_CODE_INT:
888 case TYPE_CODE_FLT:
889 return 1;
890
891 default:
892 return 0;
893 }
894}
895
896/* Returns non-zero if the value is a character type */
897int
898character_type (struct type *type)
899{
900 CHECK_TYPEDEF (type);
901 switch (current_language->la_language)
902 {
903 case language_chill:
904 case language_m2:
905 case language_pascal:
906 return TYPE_CODE (type) != TYPE_CODE_CHAR ? 0 : 1;
907
908 case language_c:
909 case language_cplus:
910 return (TYPE_CODE (type) == TYPE_CODE_INT) &&
911 TYPE_LENGTH (type) == sizeof (char)
912 ? 1 : 0;
913 default:
914 return (0);
915 }
916}
917
918/* Returns non-zero if the value is a string type */
919int
920string_type (struct type *type)
921{
922 CHECK_TYPEDEF (type);
923 switch (current_language->la_language)
924 {
925 case language_chill:
926 case language_m2:
927 case language_pascal:
928 return TYPE_CODE (type) != TYPE_CODE_STRING ? 0 : 1;
929
930 case language_c:
931 case language_cplus:
932 /* C does not have distinct string type. */
933 return (0);
934 default:
935 return (0);
936 }
937}
938
939/* Returns non-zero if the value is a boolean type */
940int
941boolean_type (struct type *type)
942{
943 CHECK_TYPEDEF (type);
944 if (TYPE_CODE (type) == TYPE_CODE_BOOL)
945 return 1;
946 switch (current_language->la_language)
947 {
948 case language_c:
949 case language_cplus:
950 /* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL
951 for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */
952 if (TYPE_CODE (type) == TYPE_CODE_INT)
953 return 1;
954 default:
955 break;
956 }
957 return 0;
958}
959
960/* Returns non-zero if the value is a floating-point type */
961int
962float_type (struct type *type)
963{
964 CHECK_TYPEDEF (type);
965 return TYPE_CODE (type) == TYPE_CODE_FLT;
966}
967
968/* Returns non-zero if the value is a pointer type */
969int
970pointer_type (struct type *type)
971{
972 return TYPE_CODE (type) == TYPE_CODE_PTR ||
973 TYPE_CODE (type) == TYPE_CODE_REF;
974}
975
976/* Returns non-zero if the value is a structured type */
977int
978structured_type (struct type *type)
979{
980 CHECK_TYPEDEF (type);
981 switch (current_language->la_language)
982 {
983 case language_c:
984 case language_cplus:
985 return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
986 (TYPE_CODE (type) == TYPE_CODE_UNION) ||
987 (TYPE_CODE (type) == TYPE_CODE_ARRAY);
988 case language_pascal:
989 return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
990 (TYPE_CODE(type) == TYPE_CODE_UNION) ||
991 (TYPE_CODE(type) == TYPE_CODE_SET) ||
992 (TYPE_CODE(type) == TYPE_CODE_ARRAY);
993 case language_m2:
994 return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
995 (TYPE_CODE (type) == TYPE_CODE_SET) ||
996 (TYPE_CODE (type) == TYPE_CODE_ARRAY);
997 case language_chill:
998 error ("Missing Chill support in function structured_type."); /*FIXME */
999 default:
1000 return (0);
1001 }
1002}
1003#endif
1004\f
1005struct type *
1006lang_bool_type (void)
1007{
1008 struct symbol *sym;
1009 struct type *type;
1010 switch (current_language->la_language)
1011 {
1012 case language_chill:
1013 return builtin_type_chill_bool;
1014 case language_fortran:
1015 sym = lookup_symbol ("logical", NULL, VAR_NAMESPACE, NULL, NULL);
1016 if (sym)
1017 {
1018 type = SYMBOL_TYPE (sym);
1019 if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
1020 return type;
1021 }
1022 return builtin_type_f_logical_s2;
1023 case language_cplus:
1024 case language_pascal:
1025 if (current_language->la_language==language_cplus)
1026 {sym = lookup_symbol ("bool", NULL, VAR_NAMESPACE, NULL, NULL);}
1027 else
1028 {sym = lookup_symbol ("boolean", NULL, VAR_NAMESPACE, NULL, NULL);}
1029 if (sym)
1030 {
1031 type = SYMBOL_TYPE (sym);
1032 if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
1033 return type;
1034 }
1035 return builtin_type_bool;
1036 case language_java:
1037 sym = lookup_symbol ("boolean", NULL, VAR_NAMESPACE, NULL, NULL);
1038 if (sym)
1039 {
1040 type = SYMBOL_TYPE (sym);
1041 if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
1042 return type;
1043 }
1044 return java_boolean_type;
1045 default:
1046 return builtin_type_int;
1047 }
1048}
1049\f
1050/* This page contains functions that return info about
1051 (struct value) values used in GDB. */
1052
1053/* Returns non-zero if the value VAL represents a true value. */
1054int
1055value_true (value_ptr val)
1056{
1057 /* It is possible that we should have some sort of error if a non-boolean
1058 value is used in this context. Possibly dependent on some kind of
1059 "boolean-checking" option like range checking. But it should probably
1060 not depend on the language except insofar as is necessary to identify
1061 a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
1062 should be an error, probably). */
1063 return !value_logical_not (val);
1064}
1065\f
1066/* Returns non-zero if the operator OP is defined on
1067 the values ARG1 and ARG2. */
1068
1069#if 0 /* Currently unused */
1070
1071void
1072binop_type_check (value_ptr arg1, value_ptr arg2, int op)
1073{
1074 struct type *t1, *t2;
1075
1076 /* If we're not checking types, always return success. */
1077 if (!STRICT_TYPE)
1078 return;
1079
1080 t1 = VALUE_TYPE (arg1);
1081 if (arg2 != NULL)
1082 t2 = VALUE_TYPE (arg2);
1083 else
1084 t2 = NULL;
1085
1086 switch (op)
1087 {
1088 case BINOP_ADD:
1089 case BINOP_SUB:
1090 if ((numeric_type (t1) && pointer_type (t2)) ||
1091 (pointer_type (t1) && numeric_type (t2)))
1092 {
1093 warning ("combining pointer and integer.\n");
1094 break;
1095 }
1096 case BINOP_MUL:
1097 case BINOP_LSH:
1098 case BINOP_RSH:
1099 if (!numeric_type (t1) || !numeric_type (t2))
1100 type_op_error ("Arguments to %s must be numbers.", op);
1101 else if (!same_type (t1, t2))
1102 type_op_error ("Arguments to %s must be of the same type.", op);
1103 break;
1104
1105 case BINOP_LOGICAL_AND:
1106 case BINOP_LOGICAL_OR:
1107 if (!boolean_type (t1) || !boolean_type (t2))
1108 type_op_error ("Arguments to %s must be of boolean type.", op);
1109 break;
1110
1111 case BINOP_EQUAL:
1112 if ((pointer_type (t1) && !(pointer_type (t2) || integral_type (t2))) ||
1113 (pointer_type (t2) && !(pointer_type (t1) || integral_type (t1))))
1114 type_op_error ("A pointer can only be compared to an integer or pointer.", op);
1115 else if ((pointer_type (t1) && integral_type (t2)) ||
1116 (integral_type (t1) && pointer_type (t2)))
1117 {
1118 warning ("combining integer and pointer.\n");
1119 break;
1120 }
1121 else if (!simple_type (t1) || !simple_type (t2))
1122 type_op_error ("Arguments to %s must be of simple type.", op);
1123 else if (!same_type (t1, t2))
1124 type_op_error ("Arguments to %s must be of the same type.", op);
1125 break;
1126
1127 case BINOP_REM:
1128 case BINOP_MOD:
1129 if (!integral_type (t1) || !integral_type (t2))
1130 type_op_error ("Arguments to %s must be of integral type.", op);
1131 break;
1132
1133 case BINOP_LESS:
1134 case BINOP_GTR:
1135 case BINOP_LEQ:
1136 case BINOP_GEQ:
1137 if (!ordered_type (t1) || !ordered_type (t2))
1138 type_op_error ("Arguments to %s must be of ordered type.", op);
1139 else if (!same_type (t1, t2))
1140 type_op_error ("Arguments to %s must be of the same type.", op);
1141 break;
1142
1143 case BINOP_ASSIGN:
1144 if (pointer_type (t1) && !integral_type (t2))
1145 type_op_error ("A pointer can only be assigned an integer.", op);
1146 else if (pointer_type (t1) && integral_type (t2))
1147 {
1148 warning ("combining integer and pointer.");
1149 break;
1150 }
1151 else if (!simple_type (t1) || !simple_type (t2))
1152 type_op_error ("Arguments to %s must be of simple type.", op);
1153 else if (!same_type (t1, t2))
1154 type_op_error ("Arguments to %s must be of the same type.", op);
1155 break;
1156
1157 case BINOP_CONCAT:
1158 /* FIXME: Needs to handle bitstrings as well. */
1159 if (!(string_type (t1) || character_type (t1) || integral_type (t1))
1160 || !(string_type (t2) || character_type (t2) || integral_type (t2)))
1161 type_op_error ("Arguments to %s must be strings or characters.", op);
1162 break;
1163
1164 /* Unary checks -- arg2 is null */
1165
1166 case UNOP_LOGICAL_NOT:
1167 if (!boolean_type (t1))
1168 type_op_error ("Argument to %s must be of boolean type.", op);
1169 break;
1170
1171 case UNOP_PLUS:
1172 case UNOP_NEG:
1173 if (!numeric_type (t1))
1174 type_op_error ("Argument to %s must be of numeric type.", op);
1175 break;
1176
1177 case UNOP_IND:
1178 if (integral_type (t1))
1179 {
1180 warning ("combining pointer and integer.\n");
1181 break;
1182 }
1183 else if (!pointer_type (t1))
1184 type_op_error ("Argument to %s must be a pointer.", op);
1185 break;
1186
1187 case UNOP_PREINCREMENT:
1188 case UNOP_POSTINCREMENT:
1189 case UNOP_PREDECREMENT:
1190 case UNOP_POSTDECREMENT:
1191 if (!ordered_type (t1))
1192 type_op_error ("Argument to %s must be of an ordered type.", op);
1193 break;
1194
1195 default:
1196 /* Ok. The following operators have different meanings in
1197 different languages. */
1198 switch (current_language->la_language)
1199 {
1200#ifdef _LANG_c
1201 case language_c:
1202 case language_cplus:
1203 switch (op)
1204 {
1205 case BINOP_DIV:
1206 if (!numeric_type (t1) || !numeric_type (t2))
1207 type_op_error ("Arguments to %s must be numbers.", op);
1208 break;
1209 }
1210 break;
1211#endif
1212
1213#ifdef _LANG_m2
1214 case language_m2:
1215 switch (op)
1216 {
1217 case BINOP_DIV:
1218 if (!float_type (t1) || !float_type (t2))
1219 type_op_error ("Arguments to %s must be floating point numbers.", op);
1220 break;
1221 case BINOP_INTDIV:
1222 if (!integral_type (t1) || !integral_type (t2))
1223 type_op_error ("Arguments to %s must be of integral type.", op);
1224 break;
1225 }
1226#endif
1227
1228#ifdef _LANG_pascal
1229 case language_pascal:
1230 switch(op)
1231 {
1232 case BINOP_DIV:
1233 if (!float_type(t1) && !float_type(t2))
1234 type_op_error ("Arguments to %s must be floating point numbers.",op);
1235 break;
1236 case BINOP_INTDIV:
1237 if (!integral_type(t1) || !integral_type(t2))
1238 type_op_error ("Arguments to %s must be of integral type.",op);
1239 break;
1240 }
1241#endif
1242
1243#ifdef _LANG_chill
1244 case language_chill:
1245 error ("Missing Chill support in function binop_type_check."); /*FIXME */
1246#endif
1247
1248 }
1249 }
1250}
1251
1252#endif /* 0 */
1253\f
1254
1255/* This page contains functions for the printing out of
1256 error messages that occur during type- and range-
1257 checking. */
1258
1259/* Prints the format string FMT with the operator as a string
1260 corresponding to the opcode OP. If FATAL is non-zero, then
1261 this is an error and error () is called. Otherwise, it is
1262 a warning and printf() is called. */
1263void
1264op_error (char *fmt, enum exp_opcode op, int fatal)
1265{
1266 if (fatal)
1267 error (fmt, op_string (op));
1268 else
1269 {
1270 warning (fmt, op_string (op));
1271 }
1272}
1273
1274/* These are called when a language fails a type- or range-check.
1275 The first argument should be a printf()-style format string, and
1276 the rest of the arguments should be its arguments. If
1277 [type|range]_check is [type|range]_check_on, then return_to_top_level()
1278 is called in the style of error (). Otherwise, the message is prefixed
1279 by the value of warning_pre_print and we do not return to the top level. */
1280
1281void
1282type_error (char *string,...)
1283{
1284 va_list args;
1285 va_start (args, string);
1286
1287 if (type_check == type_check_warn)
1288 fprintf_filtered (gdb_stderr, warning_pre_print);
1289 else
1290 error_begin ();
1291
1292 vfprintf_filtered (gdb_stderr, string, args);
1293 fprintf_filtered (gdb_stderr, "\n");
1294 va_end (args);
1295 if (type_check == type_check_on)
1296 return_to_top_level (RETURN_ERROR);
1297}
1298
1299void
1300range_error (char *string,...)
1301{
1302 va_list args;
1303 va_start (args, string);
1304
1305 if (range_check == range_check_warn)
1306 fprintf_filtered (gdb_stderr, warning_pre_print);
1307 else
1308 error_begin ();
1309
1310 vfprintf_filtered (gdb_stderr, string, args);
1311 fprintf_filtered (gdb_stderr, "\n");
1312 va_end (args);
1313 if (range_check == range_check_on)
1314 return_to_top_level (RETURN_ERROR);
1315}
1316\f
1317
1318/* This page contains miscellaneous functions */
1319
1320/* Return the language enum for a given language string. */
1321
1322enum language
1323language_enum (char *str)
1324{
1325 int i;
1326
1327 for (i = 0; i < languages_size; i++)
1328 if (STREQ (languages[i]->la_name, str))
1329 return languages[i]->la_language;
1330
1331 return language_unknown;
1332}
1333
1334/* Return the language struct for a given language enum. */
1335
1336const struct language_defn *
1337language_def (enum language lang)
1338{
1339 int i;
1340
1341 for (i = 0; i < languages_size; i++)
1342 {
1343 if (languages[i]->la_language == lang)
1344 {
1345 return languages[i];
1346 }
1347 }
1348 return NULL;
1349}
1350
1351/* Return the language as a string */
1352char *
1353language_str (enum language lang)
1354{
1355 int i;
1356
1357 for (i = 0; i < languages_size; i++)
1358 {
1359 if (languages[i]->la_language == lang)
1360 {
1361 return languages[i]->la_name;
1362 }
1363 }
1364 return "Unknown";
1365}
1366
1367static void
1368set_check (char *ignore, int from_tty)
1369{
1370 printf_unfiltered (
1371 "\"set check\" must be followed by the name of a check subcommand.\n");
1372 help_list (setchecklist, "set check ", -1, gdb_stdout);
1373}
1374
1375static void
1376show_check (char *ignore, int from_tty)
1377{
1378 cmd_show_list (showchecklist, from_tty, "");
1379}
1380\f
1381/* Add a language to the set of known languages. */
1382
1383void
1384add_language (const struct language_defn *lang)
1385{
1386 if (lang->la_magic != LANG_MAGIC)
1387 {
1388 fprintf_unfiltered (gdb_stderr, "Magic number of %s language struct wrong\n",
1389 lang->la_name);
1390 abort ();
1391 }
1392
1393 if (!languages)
1394 {
1395 languages_allocsize = DEFAULT_ALLOCSIZE;
1396 languages = (const struct language_defn **) xmalloc
1397 (languages_allocsize * sizeof (*languages));
1398 }
1399 if (languages_size >= languages_allocsize)
1400 {
1401 languages_allocsize *= 2;
1402 languages = (const struct language_defn **) xrealloc ((char *) languages,
1403 languages_allocsize * sizeof (*languages));
1404 }
1405 languages[languages_size++] = lang;
1406}
1407
1408/* Define the language that is no language. */
1409
1410static int
1411unk_lang_parser (void)
1412{
1413 return 1;
1414}
1415
1416static void
1417unk_lang_error (char *msg)
1418{
1419 error ("Attempted to parse an expression with unknown language");
1420}
1421
1422static void
1423unk_lang_emit_char (register int c, struct ui_file *stream, int quoter)
1424{
1425 error ("internal error - unimplemented function unk_lang_emit_char called.");
1426}
1427
1428static void
1429unk_lang_printchar (register int c, struct ui_file *stream)
1430{
1431 error ("internal error - unimplemented function unk_lang_printchar called.");
1432}
1433
1434static void
1435unk_lang_printstr (struct ui_file *stream, char *string, unsigned int length,
1436 int width, int force_ellipses)
1437{
1438 error ("internal error - unimplemented function unk_lang_printstr called.");
1439}
1440
1441static struct type *
1442unk_lang_create_fundamental_type (struct objfile *objfile, int typeid)
1443{
1444 error ("internal error - unimplemented function unk_lang_create_fundamental_type called.");
1445}
1446
1447static void
1448unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
1449 int show, int level)
1450{
1451 error ("internal error - unimplemented function unk_lang_print_type called.");
1452}
1453
1454static int
1455unk_lang_val_print (struct type *type, char *valaddr, int embedded_offset,
1456 CORE_ADDR address, struct ui_file *stream, int format,
1457 int deref_ref, int recurse, enum val_prettyprint pretty)
1458{
1459 error ("internal error - unimplemented function unk_lang_val_print called.");
1460}
1461
1462static int
1463unk_lang_value_print (value_ptr val, struct ui_file *stream, int format,
1464 enum val_prettyprint pretty)
1465{
1466 error ("internal error - unimplemented function unk_lang_value_print called.");
1467}
1468
1469static struct type **CONST_PTR (unknown_builtin_types[]) =
1470{
1471 0
1472};
1473static const struct op_print unk_op_print_tab[] =
1474{
1475 {NULL, OP_NULL, PREC_NULL, 0}
1476};
1477
1478const struct language_defn unknown_language_defn =
1479{
1480 "unknown",
1481 language_unknown,
1482 &unknown_builtin_types[0],
1483 range_check_off,
1484 type_check_off,
1485 case_sensitive_on,
1486 unk_lang_parser,
1487 unk_lang_error,
1488 evaluate_subexp_standard,
1489 unk_lang_printchar, /* Print character constant */
1490 unk_lang_printstr,
1491 unk_lang_emit_char,
1492 unk_lang_create_fundamental_type,
1493 unk_lang_print_type, /* Print a type using appropriate syntax */
1494 unk_lang_val_print, /* Print a value using appropriate syntax */
1495 unk_lang_value_print, /* Print a top-level value */
1496 {"", "", "", ""}, /* Binary format info */
1497 {"0%lo", "0", "o", ""}, /* Octal format info */
1498 {"%ld", "", "d", ""}, /* Decimal format info */
1499 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1500 unk_op_print_tab, /* expression operators for printing */
1501 1, /* c-style arrays */
1502 0, /* String lower bound */
1503 &builtin_type_char, /* Type of string elements */
1504 LANG_MAGIC
1505};
1506
1507/* These two structs define fake entries for the "local" and "auto" options. */
1508const struct language_defn auto_language_defn =
1509{
1510 "auto",
1511 language_auto,
1512 &unknown_builtin_types[0],
1513 range_check_off,
1514 type_check_off,
1515 case_sensitive_on,
1516 unk_lang_parser,
1517 unk_lang_error,
1518 evaluate_subexp_standard,
1519 unk_lang_printchar, /* Print character constant */
1520 unk_lang_printstr,
1521 unk_lang_emit_char,
1522 unk_lang_create_fundamental_type,
1523 unk_lang_print_type, /* Print a type using appropriate syntax */
1524 unk_lang_val_print, /* Print a value using appropriate syntax */
1525 unk_lang_value_print, /* Print a top-level value */
1526 {"", "", "", ""}, /* Binary format info */
1527 {"0%lo", "0", "o", ""}, /* Octal format info */
1528 {"%ld", "", "d", ""}, /* Decimal format info */
1529 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1530 unk_op_print_tab, /* expression operators for printing */
1531 1, /* c-style arrays */
1532 0, /* String lower bound */
1533 &builtin_type_char, /* Type of string elements */
1534 LANG_MAGIC
1535};
1536
1537const struct language_defn local_language_defn =
1538{
1539 "local",
1540 language_auto,
1541 &unknown_builtin_types[0],
1542 range_check_off,
1543 type_check_off,
1544 case_sensitive_on,
1545 unk_lang_parser,
1546 unk_lang_error,
1547 evaluate_subexp_standard,
1548 unk_lang_printchar, /* Print character constant */
1549 unk_lang_printstr,
1550 unk_lang_emit_char,
1551 unk_lang_create_fundamental_type,
1552 unk_lang_print_type, /* Print a type using appropriate syntax */
1553 unk_lang_val_print, /* Print a value using appropriate syntax */
1554 unk_lang_value_print, /* Print a top-level value */
1555 {"", "", "", ""}, /* Binary format info */
1556 {"0%lo", "0", "o", ""}, /* Octal format info */
1557 {"%ld", "", "d", ""}, /* Decimal format info */
1558 {"0x%lx", "0x", "x", ""}, /* Hex format info */
1559 unk_op_print_tab, /* expression operators for printing */
1560 1, /* c-style arrays */
1561 0, /* String lower bound */
1562 &builtin_type_char, /* Type of string elements */
1563 LANG_MAGIC
1564};
1565\f
1566/* Initialize the language routines */
1567
1568void
1569_initialize_language (void)
1570{
1571 struct cmd_list_element *set, *show;
1572
1573 /* GDB commands for language specific stuff */
1574
1575 set = add_set_cmd ("language", class_support, var_string_noescape,
1576 (char *) &language,
1577 "Set the current source language.",
1578 &setlist);
1579 show = add_show_from_set (set, &showlist);
1580 set->function.cfunc = set_language_command;
1581 show->function.cfunc = show_language_command;
1582
1583 add_prefix_cmd ("check", no_class, set_check,
1584 "Set the status of the type/range checker",
1585 &setchecklist, "set check ", 0, &setlist);
1586 add_alias_cmd ("c", "check", no_class, 1, &setlist);
1587 add_alias_cmd ("ch", "check", no_class, 1, &setlist);
1588
1589 add_prefix_cmd ("check", no_class, show_check,
1590 "Show the status of the type/range checker",
1591 &showchecklist, "show check ", 0, &showlist);
1592 add_alias_cmd ("c", "check", no_class, 1, &showlist);
1593 add_alias_cmd ("ch", "check", no_class, 1, &showlist);
1594
1595 set = add_set_cmd ("type", class_support, var_string_noescape,
1596 (char *) &type,
1597 "Set type checking. (on/warn/off/auto)",
1598 &setchecklist);
1599 show = add_show_from_set (set, &showchecklist);
1600 set->function.cfunc = set_type_command;
1601 show->function.cfunc = show_type_command;
1602
1603 set = add_set_cmd ("range", class_support, var_string_noescape,
1604 (char *) &range,
1605 "Set range checking. (on/warn/off/auto)",
1606 &setchecklist);
1607 show = add_show_from_set (set, &showchecklist);
1608 set->function.cfunc = set_range_command;
1609 show->function.cfunc = show_range_command;
1610
1611 set = add_set_cmd ("case-sensitive", class_support, var_string_noescape,
1612 (char *) &case_sensitive,
1613 "Set case sensitivity in name search. (on/off/auto)\n\
1614For Fortran the default is off; for other languages the default is on.",
1615 &setlist);
1616 show = add_show_from_set (set, &showlist);
1617 set->function.cfunc = set_case_command;
1618 show->function.cfunc = show_case_command;
1619
1620 add_language (&unknown_language_defn);
1621 add_language (&local_language_defn);
1622 add_language (&auto_language_defn);
1623
1624 language = savestring ("auto", strlen ("auto"));
1625 type = savestring ("auto", strlen ("auto"));
1626 range = savestring ("auto", strlen ("auto"));
1627 case_sensitive = savestring ("auto",strlen ("auto"));
1628
1629 /* Have the above take effect */
1630 set_language (language_auto);
1631}
This page took 0.033327 seconds and 4 git commands to generate.