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/>. */
23 struct type_print_options
;
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
,
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
56 : language_defn (language_m2
)
61 const char *name () const override
62 { return "modula-2"; }
66 const char *natural_name () const override
67 { return "Modula-2"; }
71 void language_arch_info (struct gdbarch
*gdbarch
,
72 struct language_arch_info
*lai
) const override
;
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
);
85 void value_print_inner (struct value
*val
, struct ui_file
*stream
,
87 const struct value_print_options
*options
) const override
;
91 int parser (struct parser_state
*ps
) const override
;
95 void emitchar (int ch
, struct type
*chtype
,
96 struct ui_file
*stream
, int quoter
) const override
;
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 () > 0
122 && type
->target_type ()->length () > 0)
124 struct type
*elttype
= check_typedef (type
->target_type ());
126 if (elttype
->length () == 1
127 && (elttype
->code () == TYPE_CODE_INT
128 || elttype
->code () == TYPE_CODE_CHAR
))
135 /* See language.h. */
137 bool c_style_arrays_p () const override
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
146 /* See language.h. */
148 bool range_checking_on_by_default () const override
152 #endif /* M2_LANG_H */