GDB (xrefs)
Loading...
Searching...
No Matches
m2-lang.h
Go to the documentation of this file.
1/* Modula 2 language support definitions for GDB, the GNU debugger.
2
3 Copyright (C) 1992-2023 Free Software Foundation, Inc.
4
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
9 the Free Software Foundation; either version 3 of the License, or
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
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef M2_LANG_H
21#define M2_LANG_H
22
24struct parser_state;
25
26/* Defined in m2-typeprint.c */
27extern void m2_print_type (struct type *, const char *, struct ui_file *, int,
28 int, const struct type_print_options *);
29
30extern int m2_is_long_set (struct type *type);
31extern int m2_is_unbounded_array (struct type *type);
32
33extern int get_long_set_bounds (struct type *type, LONGEST *low,
34 LONGEST *high);
35
36/* Modula-2 types */
37
39{
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;
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
50/* Class representing the M2 language. */
51
53{
54public:
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
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 {
120 if (type->code () == TYPE_CODE_ARRAY
121 && type->length () > 0
122 && type->target_type ()->length () > 0)
123 {
124 struct type *elttype = check_typedef (type->target_type ());
125
126 if (elttype->length () == 1
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; }
150};
151
152#endif /* M2_LANG_H */
const char * natural_name() const override
Definition m2-lang.h:66
bool c_style_arrays_p() const override
Definition m2-lang.h:137
void emitchar(int ch, struct type *chtype, struct ui_file *stream, int quoter) const override
Definition m2-lang.c:233
char string_lower_bound() const override
Definition m2-lang.h:143
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
Definition m2-lang.c:121
int parser(struct parser_state *ps) const override
Definition m2-exp.c:2735
void printchar(int ch, struct type *chtype, struct ui_file *stream) const override
Definition m2-lang.c:145
bool is_string_type_p(struct type *type) const override
Definition m2-lang.h:117
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
Definition m2-lang.h:76
void print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream) const override
const char * name() const override
Definition m2-lang.h:61
m2_language()
Definition m2-lang.h:55
void value_print_inner(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const override
bool range_checking_on_by_default() const override
Definition m2-lang.h:148
void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const override
Definition m2-lang.c:156
@ language_m2
Definition defs.h:220
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition gnu-nat.c:1861
int get_long_set_bounds(struct type *type, LONGEST *low, LONGEST *high)
Definition m2-valprint.c:48
void m2_print_type(struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *)
int m2_is_unbounded_array(struct type *type)
const struct builtin_m2_type * builtin_m2_type(struct gdbarch *gdbarch)
Definition m2-lang.c:305
int m2_is_long_set(struct type *type)
static struct symbol * new_symbol(struct die_info *, struct type *, struct dwarf2_cu *, struct symbol *=NULL)
Definition read.c:18978
struct type * builtin_real
Definition m2-lang.h:43
struct type * builtin_char
Definition m2-lang.h:40
struct type * builtin_bool
Definition m2-lang.h:44
struct type * builtin_card
Definition m2-lang.h:42
struct type * builtin_int
Definition m2-lang.h:41
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
Definition value.h:130