1 /* Print in infix form a struct expression.
3 Copyright (C) 1986-2021 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 #include "expression.h"
26 #include "parser-defs.h"
27 #include "user-regs.h" /* For user_reg_map_regnum_to_name. */
32 #include "cli/cli-style.h"
39 /* Default name for the standard operator OPCODE (i.e., one defined in
40 the definition of enum exp_opcode). */
43 op_name (enum exp_opcode opcode
)
51 xsnprintf (buf
, sizeof (buf
), "<unknown %d>", opcode
);
57 #include "std-operator.def"
63 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
)
65 exp
->op
->dump (stream
, 0);
72 dump_for_expression (struct ui_file
*stream
, int depth
, enum exp_opcode op
)
74 fprintf_filtered (stream
, _("%*sOperation: %s\n"), depth
, "", op_name (op
));
78 dump_for_expression (struct ui_file
*stream
, int depth
, const std::string
&str
)
80 fprintf_filtered (stream
, _("%*sString: %s\n"), depth
, "", str
.c_str ());
84 dump_for_expression (struct ui_file
*stream
, int depth
, struct type
*type
)
86 fprintf_filtered (stream
, _("%*sType: "), depth
, "");
87 type_print (type
, nullptr, stream
, 0);
88 fprintf_filtered (stream
, "\n");
92 dump_for_expression (struct ui_file
*stream
, int depth
, CORE_ADDR addr
)
94 fprintf_filtered (stream
, _("%*sConstant: %s\n"), depth
, "",
95 core_addr_to_string (addr
));
99 dump_for_expression (struct ui_file
*stream
, int depth
, internalvar
*ivar
)
101 fprintf_filtered (stream
, _("%*sInternalvar: $%s\n"), depth
, "",
102 internalvar_name (ivar
));
106 dump_for_expression (struct ui_file
*stream
, int depth
, symbol
*sym
)
108 fprintf_filtered (stream
, _("%*sSymbol: %s\n"), depth
, "",
113 dump_for_expression (struct ui_file
*stream
, int depth
,
114 bound_minimal_symbol msym
)
116 fprintf_filtered (stream
, _("%*sMinsym %s in objfile %s\n"), depth
, "",
117 msym
.minsym
->print_name (), objfile_name (msym
.objfile
));
121 dump_for_expression (struct ui_file
*stream
, int depth
, const block
*bl
)
123 fprintf_filtered (stream
, _("%*sBlock: %p\n"), depth
, "", bl
);
127 dump_for_expression (struct ui_file
*stream
, int depth
,
128 type_instance_flags flags
)
130 fprintf_filtered (stream
, _("%*sType flags: "), depth
, "");
131 if (flags
& TYPE_INSTANCE_FLAG_CONST
)
132 fputs_unfiltered ("const ", stream
);
133 if (flags
& TYPE_INSTANCE_FLAG_VOLATILE
)
134 fputs_unfiltered ("volatile", stream
);
135 fprintf_filtered (stream
, "\n");
139 dump_for_expression (struct ui_file
*stream
, int depth
,
140 enum c_string_type_values flags
)
142 fprintf_filtered (stream
, _("%*sC string flags: "), depth
, "");
143 switch (flags
& ~C_CHAR
)
146 fputs_unfiltered (_("wide "), stream
);
149 fputs_unfiltered (_("u16 "), stream
);
152 fputs_unfiltered (_("u32 "), stream
);
155 fputs_unfiltered (_("ordinary "), stream
);
159 if ((flags
& C_CHAR
) != 0)
160 fputs_unfiltered (_("char"), stream
);
162 fputs_unfiltered (_("string"), stream
);
163 fputs_unfiltered ("\n", stream
);
167 dump_for_expression (struct ui_file
*stream
, int depth
,
168 enum range_flag flags
)
170 fprintf_filtered (stream
, _("%*sRange:"), depth
, "");
171 if ((flags
& RANGE_LOW_BOUND_DEFAULT
) != 0)
172 fputs_unfiltered (_("low-default "), stream
);
173 if ((flags
& RANGE_HIGH_BOUND_DEFAULT
) != 0)
174 fputs_unfiltered (_("high-default "), stream
);
175 if ((flags
& RANGE_HIGH_BOUND_EXCLUSIVE
) != 0)
176 fputs_unfiltered (_("high-exclusive "), stream
);
177 if ((flags
& RANGE_HAS_STRIDE
) != 0)
178 fputs_unfiltered (_("has-stride"), stream
);
179 fprintf_filtered (stream
, "\n");
183 dump_for_expression (struct ui_file
*stream
, int depth
,
184 const std::unique_ptr
<ada_component
> &comp
)
186 comp
->dump (stream
, depth
);
190 float_const_operation::dump (struct ui_file
*stream
, int depth
) const
192 fprintf_filtered (stream
, _("%*sFloat: "), depth
, "");
193 print_floating (m_data
.data (), m_type
, stream
);
194 fprintf_filtered (stream
, "\n");
197 } /* namespace expr */