Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Print in infix form a struct expression. |
1bac305b | 2 | |
3666a048 | 3 | Copyright (C) 1986-2021 Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
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 | 10 | (at your option) any later version. |
c906108c | 11 | |
c5aa993b JM |
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. | |
c906108c | 16 | |
c5aa993b | 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 SS |
19 | |
20 | #include "defs.h" | |
4de283e4 | 21 | #include "symtab.h" |
d55e5aa6 | 22 | #include "gdbtypes.h" |
4de283e4 TT |
23 | #include "expression.h" |
24 | #include "value.h" | |
c906108c SS |
25 | #include "language.h" |
26 | #include "parser-defs.h" | |
4de283e4 | 27 | #include "user-regs.h" /* For user_reg_map_regnum_to_name. */ |
82eeeb94 | 28 | #include "target.h" |
4de283e4 TT |
29 | #include "block.h" |
30 | #include "objfiles.h" | |
79a45b7d | 31 | #include "valprint.h" |
7f6aba03 | 32 | #include "cli/cli-style.h" |
de401988 TT |
33 | #include "c-lang.h" |
34 | #include "expop.h" | |
a88c4354 | 35 | #include "ada-exp.h" |
4de283e4 TT |
36 | |
37 | #include <ctype.h> | |
c906108c | 38 | |
5f9769d1 PH |
39 | /* Default name for the standard operator OPCODE (i.e., one defined in |
40 | the definition of enum exp_opcode). */ | |
41 | ||
a121b7c1 | 42 | const char * |
88b91969 | 43 | op_name (enum exp_opcode opcode) |
c906108c SS |
44 | { |
45 | switch (opcode) | |
46 | { | |
47 | default: | |
48 | { | |
49 | static char buf[30]; | |
50 | ||
08850b56 | 51 | xsnprintf (buf, sizeof (buf), "<unknown %d>", opcode); |
c906108c SS |
52 | return buf; |
53 | } | |
56c12414 JK |
54 | #define OP(name) \ |
55 | case name: \ | |
56 | return #name ; | |
57 | #include "std-operator.def" | |
58 | #undef OP | |
c906108c SS |
59 | } |
60 | } | |
61 | ||
c906108c | 62 | void |
24daaebc | 63 | dump_prefix_expression (struct expression *exp, struct ui_file *stream) |
c906108c | 64 | { |
1eaebe02 | 65 | exp->op->dump (stream, 0); |
c906108c | 66 | } |
de401988 TT |
67 | |
68 | namespace expr | |
69 | { | |
70 | ||
71 | void | |
72 | dump_for_expression (struct ui_file *stream, int depth, enum exp_opcode op) | |
73 | { | |
74 | fprintf_filtered (stream, _("%*sOperation: %s\n"), depth, "", op_name (op)); | |
75 | } | |
76 | ||
77 | void | |
78 | dump_for_expression (struct ui_file *stream, int depth, const std::string &str) | |
79 | { | |
80 | fprintf_filtered (stream, _("%*sString: %s\n"), depth, "", str.c_str ()); | |
81 | } | |
82 | ||
83 | void | |
84 | dump_for_expression (struct ui_file *stream, int depth, struct type *type) | |
85 | { | |
86 | fprintf_filtered (stream, _("%*sType: "), depth, ""); | |
87 | type_print (type, nullptr, stream, 0); | |
88 | fprintf_filtered (stream, "\n"); | |
89 | } | |
90 | ||
91 | void | |
92 | dump_for_expression (struct ui_file *stream, int depth, CORE_ADDR addr) | |
93 | { | |
94 | fprintf_filtered (stream, _("%*sConstant: %s\n"), depth, "", | |
95 | core_addr_to_string (addr)); | |
96 | } | |
97 | ||
98 | void | |
99 | dump_for_expression (struct ui_file *stream, int depth, internalvar *ivar) | |
100 | { | |
101 | fprintf_filtered (stream, _("%*sInternalvar: $%s\n"), depth, "", | |
102 | internalvar_name (ivar)); | |
103 | } | |
104 | ||
105 | void | |
106 | dump_for_expression (struct ui_file *stream, int depth, symbol *sym) | |
107 | { | |
108 | fprintf_filtered (stream, _("%*sSymbol: %s\n"), depth, "", | |
109 | sym->print_name ()); | |
110 | } | |
111 | ||
112 | void | |
9c79936b TT |
113 | dump_for_expression (struct ui_file *stream, int depth, |
114 | bound_minimal_symbol msym) | |
de401988 | 115 | { |
9c79936b TT |
116 | fprintf_filtered (stream, _("%*sMinsym %s in objfile %s\n"), depth, "", |
117 | msym.minsym->print_name (), objfile_name (msym.objfile)); | |
de401988 TT |
118 | } |
119 | ||
120 | void | |
121 | dump_for_expression (struct ui_file *stream, int depth, const block *bl) | |
122 | { | |
123 | fprintf_filtered (stream, _("%*sBlock: %p\n"), depth, "", bl); | |
124 | } | |
125 | ||
9e5e03df TT |
126 | void |
127 | dump_for_expression (struct ui_file *stream, int depth, | |
128 | const block_symbol &sym) | |
129 | { | |
130 | fprintf_filtered (stream, _("%*sBlock symbol:\n"), depth, ""); | |
131 | dump_for_expression (stream, depth + 1, sym.symbol); | |
132 | dump_for_expression (stream, depth + 1, sym.block); | |
133 | } | |
134 | ||
de401988 TT |
135 | void |
136 | dump_for_expression (struct ui_file *stream, int depth, | |
137 | type_instance_flags flags) | |
138 | { | |
139 | fprintf_filtered (stream, _("%*sType flags: "), depth, ""); | |
140 | if (flags & TYPE_INSTANCE_FLAG_CONST) | |
141 | fputs_unfiltered ("const ", stream); | |
142 | if (flags & TYPE_INSTANCE_FLAG_VOLATILE) | |
143 | fputs_unfiltered ("volatile", stream); | |
144 | fprintf_filtered (stream, "\n"); | |
145 | } | |
146 | ||
147 | void | |
148 | dump_for_expression (struct ui_file *stream, int depth, | |
149 | enum c_string_type_values flags) | |
150 | { | |
151 | fprintf_filtered (stream, _("%*sC string flags: "), depth, ""); | |
152 | switch (flags & ~C_CHAR) | |
153 | { | |
154 | case C_WIDE_STRING: | |
155 | fputs_unfiltered (_("wide "), stream); | |
156 | break; | |
157 | case C_STRING_16: | |
158 | fputs_unfiltered (_("u16 "), stream); | |
159 | break; | |
160 | case C_STRING_32: | |
161 | fputs_unfiltered (_("u32 "), stream); | |
162 | break; | |
163 | default: | |
164 | fputs_unfiltered (_("ordinary "), stream); | |
165 | break; | |
166 | } | |
167 | ||
168 | if ((flags & C_CHAR) != 0) | |
169 | fputs_unfiltered (_("char"), stream); | |
170 | else | |
171 | fputs_unfiltered (_("string"), stream); | |
172 | fputs_unfiltered ("\n", stream); | |
173 | } | |
174 | ||
de401988 TT |
175 | void |
176 | dump_for_expression (struct ui_file *stream, int depth, | |
177 | enum range_flag flags) | |
178 | { | |
179 | fprintf_filtered (stream, _("%*sRange:"), depth, ""); | |
180 | if ((flags & RANGE_LOW_BOUND_DEFAULT) != 0) | |
181 | fputs_unfiltered (_("low-default "), stream); | |
182 | if ((flags & RANGE_HIGH_BOUND_DEFAULT) != 0) | |
183 | fputs_unfiltered (_("high-default "), stream); | |
184 | if ((flags & RANGE_HIGH_BOUND_EXCLUSIVE) != 0) | |
185 | fputs_unfiltered (_("high-exclusive "), stream); | |
186 | if ((flags & RANGE_HAS_STRIDE) != 0) | |
187 | fputs_unfiltered (_("has-stride"), stream); | |
188 | fprintf_filtered (stream, "\n"); | |
189 | } | |
190 | ||
a88c4354 TT |
191 | void |
192 | dump_for_expression (struct ui_file *stream, int depth, | |
193 | const std::unique_ptr<ada_component> &comp) | |
194 | { | |
195 | comp->dump (stream, depth); | |
196 | } | |
197 | ||
cae26a0c TT |
198 | void |
199 | float_const_operation::dump (struct ui_file *stream, int depth) const | |
200 | { | |
201 | fprintf_filtered (stream, _("%*sFloat: "), depth, ""); | |
202 | print_floating (m_data.data (), m_type, stream); | |
203 | fprintf_filtered (stream, "\n"); | |
204 | } | |
205 | ||
de401988 | 206 | } /* namespace expr */ |