Automatic date update in version.in
[binutils-gdb.git] / gdb / m2-lang.h
blob775312f3cb41e8d518e11dd41e6e5e1b6f5c06f3
1 /* Modula 2 language support definitions for GDB, the GNU debugger.
3 Copyright (C) 1992-2022 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef M2_LANG_H
21 #define M2_LANG_H
23 struct type_print_options;
24 struct parser_state;
26 /* Defined in m2-typeprint.c */
27 extern void m2_print_type (struct type *, const char *, struct ui_file *, int,
28 int, const struct type_print_options *);
30 extern int m2_is_long_set (struct type *type);
31 extern int m2_is_unbounded_array (struct type *type);
33 extern int get_long_set_bounds (struct type *type, LONGEST *low,
34 LONGEST *high);
36 /* Modula-2 types */
38 struct builtin_m2_type
40 struct type *builtin_char = nullptr;
41 struct type *builtin_int = nullptr;
42 struct type *builtin_card = nullptr;
43 struct type *builtin_real = nullptr;
44 struct type *builtin_bool = nullptr;
47 /* Return the Modula-2 type table for the specified architecture. */
48 extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
50 /* Class representing the M2 language. */
52 class m2_language : public language_defn
54 public:
55 m2_language ()
56 : language_defn (language_m2)
57 { /* Nothing. */ }
59 /* See language.h. */
61 const char *name () const override
62 { return "modula-2"; }
64 /* See language.h. */
66 const char *natural_name () const override
67 { return "Modula-2"; }
69 /* See language.h. */
71 void language_arch_info (struct gdbarch *gdbarch,
72 struct language_arch_info *lai) const override;
74 /* See language.h. */
76 void print_type (struct type *type, const char *varstring,
77 struct ui_file *stream, int show, int level,
78 const struct type_print_options *flags) const override
80 m2_print_type (type, varstring, stream, show, level, flags);
83 /* See language.h. */
85 void value_print_inner (struct value *val, struct ui_file *stream,
86 int recurse,
87 const struct value_print_options *options) const override;
89 /* See language.h. */
91 int parser (struct parser_state *ps) const override;
93 /* See language.h. */
95 void emitchar (int ch, struct type *chtype,
96 struct ui_file *stream, int quoter) const override;
98 /* See language.h. */
100 void printchar (int ch, struct type *chtype,
101 struct ui_file *stream) const override;
103 /* See language.h. */
105 void printstr (struct ui_file *stream, struct type *elttype,
106 const gdb_byte *string, unsigned int length,
107 const char *encoding, int force_ellipses,
108 const struct value_print_options *options) const override;
110 /* See language.h. */
112 void print_typedef (struct type *type, struct symbol *new_symbol,
113 struct ui_file *stream) const override;
115 /* See language.h. */
117 bool is_string_type_p (struct type *type) const override
119 type = check_typedef (type);
120 if (type->code () == TYPE_CODE_ARRAY
121 && TYPE_LENGTH (type) > 0
122 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
124 struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
126 if (TYPE_LENGTH (elttype) == 1
127 && (elttype->code () == TYPE_CODE_INT
128 || elttype->code () == TYPE_CODE_CHAR))
129 return true;
132 return false;
135 /* See language.h. */
137 bool c_style_arrays_p () const override
138 { return false; }
140 /* See language.h. Despite not having C-style arrays, Modula-2 uses 0
141 for its string lower bounds. */
143 char string_lower_bound () const override
144 { return 0; }
146 /* See language.h. */
148 bool range_checking_on_by_default () const override
149 { return true; }
152 #endif /* M2_LANG_H */