]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/m2-lang.h
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / m2-lang.h
CommitLineData
c906108c 1/* Modula 2 language support definitions for GDB, the GNU debugger.
a2bd3dcd 2
1d506c26 3 Copyright (C) 1992-2024 Free Software Foundation, Inc.
c906108c 4
c5aa993b
JM
5 This file is part of GDB.
6
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b
JM
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 19
1a5c2598
TT
20#ifndef M2_LANG_H
21#define M2_LANG_H
22
79d43c61 23struct type_print_options;
410a0ff2 24struct parser_state;
79d43c61 25
d9fcf2fb 26/* Defined in m2-typeprint.c */
25b524e8 27extern void m2_print_type (struct type *, const char *, struct ui_file *, int,
79d43c61 28 int, const struct type_print_options *);
c906108c 29
72019c9c 30extern int m2_is_long_set (struct type *type);
844781a1 31extern int m2_is_unbounded_array (struct type *type);
72019c9c 32
72019c9c
GM
33extern int get_long_set_bounds (struct type *type, LONGEST *low,
34 LONGEST *high);
4cca3ac9
UW
35
36/* Modula-2 types */
37
38struct builtin_m2_type
39{
cb275538
TT
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;
4cca3ac9
UW
45};
46
47/* Return the Modula-2 type table for the specified architecture. */
48extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
49
790e2a12
AB
50/* Class representing the M2 language. */
51
52class m2_language : public language_defn
53{
54public:
55 m2_language ()
56 : language_defn (language_m2)
57 { /* Nothing. */ }
58
59 /* See language.h. */
60
61 const char *name () const override
62 { return "modula-2"; }
63
64 /* See language.h. */
65
66 const char *natural_name () const override
67 { return "Modula-2"; }
68
69 /* See language.h. */
70
71 void language_arch_info (struct gdbarch *gdbarch,
72 struct language_arch_info *lai) const override;
73
74 /* See language.h. */
75
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
79 {
80 m2_print_type (type, varstring, stream, show, level, flags);
81 }
82
83 /* See language.h. */
84
85 void value_print_inner (struct value *val, struct ui_file *stream,
86 int recurse,
87 const struct value_print_options *options) const override;
88
89 /* See language.h. */
90
91 int parser (struct parser_state *ps) const override;
92
93 /* See language.h. */
94
95 void emitchar (int ch, struct type *chtype,
96 struct ui_file *stream, int quoter) const override;
97
98 /* See language.h. */
99
100 void printchar (int ch, struct type *chtype,
101 struct ui_file *stream) const override;
102
103 /* See language.h. */
104
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;
109
110 /* See language.h. */
111
112 void print_typedef (struct type *type, struct symbol *new_symbol,
113 struct ui_file *stream) const override;
114
115 /* See language.h. */
116
117 bool is_string_type_p (struct type *type) const override
118 {
119 type = check_typedef (type);
120 if (type->code () == TYPE_CODE_ARRAY
df86565b
SM
121 && type->length () > 0
122 && type->target_type ()->length () > 0)
790e2a12 123 {
27710edb 124 struct type *elttype = check_typedef (type->target_type ());
790e2a12 125
df86565b 126 if (elttype->length () == 1
790e2a12
AB
127 && (elttype->code () == TYPE_CODE_INT
128 || elttype->code () == TYPE_CODE_CHAR))
129 return true;
130 }
131
132 return false;
133 }
134
135 /* See language.h. */
136
137 bool c_style_arrays_p () const override
138 { return false; }
139
140 /* See language.h. Despite not having C-style arrays, Modula-2 uses 0
141 for its string lower bounds. */
142
143 char string_lower_bound () const override
144 { return 0; }
145
146 /* See language.h. */
147
148 bool range_checking_on_by_default () const override
149 { return true; }
790e2a12
AB
150};
151
1a5c2598 152#endif /* M2_LANG_H */