Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Print in infix form a struct expression. |
1bac305b | 2 | |
28e7fd62 | 3 | Copyright (C) 1986-2013 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" | |
21 | #include "symtab.h" | |
22 | #include "gdbtypes.h" | |
23 | #include "expression.h" | |
24 | #include "value.h" | |
25 | #include "language.h" | |
26 | #include "parser-defs.h" | |
eb8bc282 | 27 | #include "user-regs.h" /* For user_reg_map_regnum_to_name. */ |
82eeeb94 AF |
28 | #include "target.h" |
29 | #include "gdb_string.h" | |
fe898f56 | 30 | #include "block.h" |
9e35dae4 | 31 | #include "objfiles.h" |
fcd776e5 | 32 | #include "gdb_assert.h" |
79a45b7d | 33 | #include "valprint.h" |
c906108c | 34 | |
c906108c | 35 | #include <ctype.h> |
c906108c | 36 | |
c906108c | 37 | void |
fba45db2 | 38 | print_expression (struct expression *exp, struct ui_file *stream) |
c906108c SS |
39 | { |
40 | int pc = 0; | |
d7f9d729 | 41 | |
c906108c SS |
42 | print_subexp (exp, &pc, stream, PREC_NULL); |
43 | } | |
44 | ||
45 | /* Print the subexpression of EXP that starts in position POS, on STREAM. | |
46 | PREC is the precedence of the surrounding operator; | |
47 | if the precedence of the main operator of this subexpression is less, | |
48 | parentheses are needed here. */ | |
49 | ||
5f9769d1 | 50 | void |
f86f5ca3 | 51 | print_subexp (struct expression *exp, int *pos, |
fba45db2 | 52 | struct ui_file *stream, enum precedence prec) |
5f9769d1 PH |
53 | { |
54 | exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec); | |
55 | } | |
56 | ||
57 | /* Standard implementation of print_subexp for use in language_defn | |
58 | vectors. */ | |
59 | void | |
60 | print_subexp_standard (struct expression *exp, int *pos, | |
61 | struct ui_file *stream, enum precedence prec) | |
c906108c | 62 | { |
f86f5ca3 PH |
63 | unsigned tem; |
64 | const struct op_print *op_print_tab; | |
65 | int pc; | |
c906108c | 66 | unsigned nargs; |
f86f5ca3 | 67 | char *op_str; |
c906108c SS |
68 | int assign_modify = 0; |
69 | enum exp_opcode opcode; | |
70 | enum precedence myprec = PREC_NULL; | |
71 | /* Set to 1 for a right-associative operator. */ | |
72 | int assoc = 0; | |
3d6d86c6 | 73 | struct value *val; |
c906108c SS |
74 | char *tempstr = NULL; |
75 | ||
76 | op_print_tab = exp->language_defn->la_op_print_tab; | |
77 | pc = (*pos)++; | |
78 | opcode = exp->elts[pc].opcode; | |
79 | switch (opcode) | |
80 | { | |
c5aa993b | 81 | /* Common ops */ |
c906108c | 82 | |
4f485ebc DE |
83 | case OP_TYPE: |
84 | (*pos) += 2; | |
85 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
86 | return; | |
87 | ||
c906108c SS |
88 | case OP_SCOPE: |
89 | myprec = PREC_PREFIX; | |
90 | assoc = 0; | |
91 | fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream); | |
92 | fputs_filtered ("::", stream); | |
93 | nargs = longest_to_int (exp->elts[pc + 2].longconst); | |
94 | (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1); | |
95 | fputs_filtered (&exp->elts[pc + 3].string, stream); | |
96 | return; | |
97 | ||
98 | case OP_LONG: | |
79a45b7d TT |
99 | { |
100 | struct value_print_options opts; | |
d7f9d729 | 101 | |
79a45b7d TT |
102 | get_raw_print_options (&opts); |
103 | (*pos) += 3; | |
104 | value_print (value_from_longest (exp->elts[pc + 1].type, | |
105 | exp->elts[pc + 2].longconst), | |
106 | stream, &opts); | |
107 | } | |
c906108c SS |
108 | return; |
109 | ||
110 | case OP_DOUBLE: | |
79a45b7d TT |
111 | { |
112 | struct value_print_options opts; | |
d7f9d729 | 113 | |
79a45b7d TT |
114 | get_raw_print_options (&opts); |
115 | (*pos) += 3; | |
116 | value_print (value_from_double (exp->elts[pc + 1].type, | |
117 | exp->elts[pc + 2].doubleconst), | |
118 | stream, &opts); | |
119 | } | |
c906108c SS |
120 | return; |
121 | ||
122 | case OP_VAR_VALUE: | |
123 | { | |
270140bd | 124 | const struct block *b; |
d7f9d729 | 125 | |
c906108c SS |
126 | (*pos) += 3; |
127 | b = exp->elts[pc + 1].block; | |
128 | if (b != NULL | |
129 | && BLOCK_FUNCTION (b) != NULL | |
de5ad195 | 130 | && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL) |
c906108c | 131 | { |
de5ad195 | 132 | fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream); |
c906108c SS |
133 | fputs_filtered ("::", stream); |
134 | } | |
de5ad195 | 135 | fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream); |
c906108c SS |
136 | } |
137 | return; | |
138 | ||
36b11add JK |
139 | case OP_VAR_ENTRY_VALUE: |
140 | { | |
36b11add JK |
141 | (*pos) += 2; |
142 | fprintf_filtered (stream, "%s@entry", | |
143 | SYMBOL_PRINT_NAME (exp->elts[pc + 1].symbol)); | |
144 | } | |
145 | return; | |
146 | ||
c906108c SS |
147 | case OP_LAST: |
148 | (*pos) += 2; | |
149 | fprintf_filtered (stream, "$%d", | |
150 | longest_to_int (exp->elts[pc + 1].longconst)); | |
151 | return; | |
152 | ||
153 | case OP_REGISTER: | |
e36180d7 | 154 | { |
67f3407f | 155 | const char *name = &exp->elts[pc + 2].string; |
d7f9d729 | 156 | |
67f3407f | 157 | (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); |
eb8bc282 | 158 | fprintf_filtered (stream, "$%s", name); |
e36180d7 AC |
159 | return; |
160 | } | |
c906108c SS |
161 | |
162 | case OP_BOOL: | |
163 | (*pos) += 2; | |
164 | fprintf_filtered (stream, "%s", | |
165 | longest_to_int (exp->elts[pc + 1].longconst) | |
166 | ? "TRUE" : "FALSE"); | |
167 | return; | |
168 | ||
169 | case OP_INTERNALVAR: | |
170 | (*pos) += 2; | |
171 | fprintf_filtered (stream, "$%s", | |
c5aa993b | 172 | internalvar_name (exp->elts[pc + 1].internalvar)); |
c906108c SS |
173 | return; |
174 | ||
175 | case OP_FUNCALL: | |
176 | (*pos) += 2; | |
177 | nargs = longest_to_int (exp->elts[pc + 1].longconst); | |
178 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
179 | fputs_filtered (" (", stream); | |
180 | for (tem = 0; tem < nargs; tem++) | |
181 | { | |
182 | if (tem != 0) | |
183 | fputs_filtered (", ", stream); | |
184 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
185 | } | |
186 | fputs_filtered (")", stream); | |
187 | return; | |
188 | ||
189 | case OP_NAME: | |
c5aa993b | 190 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
c906108c SS |
191 | (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); |
192 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
193 | return; | |
194 | ||
195 | case OP_STRING: | |
79a45b7d TT |
196 | { |
197 | struct value_print_options opts; | |
d7f9d729 | 198 | |
79a45b7d TT |
199 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
200 | (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); | |
201 | /* LA_PRINT_STRING will print using the current repeat count threshold. | |
202 | If necessary, we can temporarily set it to zero, or pass it as an | |
203 | additional parameter to LA_PRINT_STRING. -fnf */ | |
204 | get_user_print_options (&opts); | |
6c7a06a3 | 205 | LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, |
be759fcf | 206 | &exp->elts[pc + 2].string, nargs, NULL, 0, &opts); |
79a45b7d | 207 | } |
c906108c SS |
208 | return; |
209 | ||
3e43a32a MS |
210 | case OP_OBJC_NSSTRING: /* Objective-C Foundation Class |
211 | NSString constant. */ | |
79a45b7d TT |
212 | { |
213 | struct value_print_options opts; | |
d7f9d729 | 214 | |
79a45b7d TT |
215 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
216 | (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); | |
217 | fputs_filtered ("@\"", stream); | |
218 | get_user_print_options (&opts); | |
6c7a06a3 | 219 | LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, |
be759fcf | 220 | &exp->elts[pc + 2].string, nargs, NULL, 0, &opts); |
79a45b7d TT |
221 | fputs_filtered ("\"", stream); |
222 | } | |
82eeeb94 AF |
223 | return; |
224 | ||
225 | case OP_OBJC_MSGCALL: | |
226 | { /* Objective C message (method) call. */ | |
227 | char *selector; | |
d7f9d729 | 228 | |
82eeeb94 AF |
229 | (*pos) += 3; |
230 | nargs = longest_to_int (exp->elts[pc + 2].longconst); | |
231 | fprintf_unfiltered (stream, "["); | |
232 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
233 | if (0 == target_read_string (exp->elts[pc + 1].longconst, | |
234 | &selector, 1024, NULL)) | |
235 | { | |
8a3fe4f8 | 236 | error (_("bad selector")); |
82eeeb94 AF |
237 | return; |
238 | } | |
239 | if (nargs) | |
240 | { | |
241 | char *s, *nextS; | |
d7f9d729 | 242 | |
82eeeb94 AF |
243 | s = alloca (strlen (selector) + 1); |
244 | strcpy (s, selector); | |
245 | for (tem = 0; tem < nargs; tem++) | |
246 | { | |
247 | nextS = strchr (s, ':'); | |
fcd776e5 | 248 | gdb_assert (nextS); /* Make sure we found ':'. */ |
82eeeb94 AF |
249 | *nextS = '\0'; |
250 | fprintf_unfiltered (stream, " %s: ", s); | |
251 | s = nextS + 1; | |
252 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
253 | } | |
254 | } | |
255 | else | |
256 | { | |
257 | fprintf_unfiltered (stream, " %s", selector); | |
258 | } | |
259 | fprintf_unfiltered (stream, "]"); | |
0963b4bd | 260 | /* "selector" was malloc'd by target_read_string. Free it. */ |
4ef3f3be | 261 | xfree (selector); |
82eeeb94 AF |
262 | return; |
263 | } | |
264 | ||
c906108c SS |
265 | case OP_ARRAY: |
266 | (*pos) += 3; | |
267 | nargs = longest_to_int (exp->elts[pc + 2].longconst); | |
268 | nargs -= longest_to_int (exp->elts[pc + 1].longconst); | |
269 | nargs++; | |
270 | tem = 0; | |
271 | if (exp->elts[pc + 4].opcode == OP_LONG | |
b806fb9a UW |
272 | && exp->elts[pc + 5].type |
273 | == builtin_type (exp->gdbarch)->builtin_char | |
c906108c SS |
274 | && exp->language_defn->la_language == language_c) |
275 | { | |
276 | /* Attempt to print C character arrays using string syntax. | |
277 | Walk through the args, picking up one character from each | |
278 | of the OP_LONG expression elements. If any array element | |
279 | does not match our expection of what we should find for | |
280 | a simple string, revert back to array printing. Note that | |
281 | the last expression element is an explicit null terminator | |
0963b4bd | 282 | byte, which doesn't get printed. */ |
c906108c SS |
283 | tempstr = alloca (nargs); |
284 | pc += 4; | |
285 | while (tem < nargs) | |
286 | { | |
287 | if (exp->elts[pc].opcode != OP_LONG | |
b806fb9a UW |
288 | || exp->elts[pc + 1].type |
289 | != builtin_type (exp->gdbarch)->builtin_char) | |
c906108c | 290 | { |
0963b4bd MS |
291 | /* Not a simple array of char, use regular array |
292 | printing. */ | |
c906108c SS |
293 | tem = 0; |
294 | break; | |
295 | } | |
296 | else | |
297 | { | |
298 | tempstr[tem++] = | |
299 | longest_to_int (exp->elts[pc + 2].longconst); | |
300 | pc += 4; | |
301 | } | |
302 | } | |
303 | } | |
304 | if (tem > 0) | |
305 | { | |
79a45b7d | 306 | struct value_print_options opts; |
d7f9d729 | 307 | |
79a45b7d | 308 | get_user_print_options (&opts); |
6c7a06a3 | 309 | LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, |
be759fcf | 310 | tempstr, nargs - 1, NULL, 0, &opts); |
c906108c SS |
311 | (*pos) = pc; |
312 | } | |
313 | else | |
314 | { | |
db034ac5 | 315 | fputs_filtered (" {", stream); |
c906108c SS |
316 | for (tem = 0; tem < nargs; tem++) |
317 | { | |
318 | if (tem != 0) | |
319 | { | |
320 | fputs_filtered (", ", stream); | |
321 | } | |
322 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
323 | } | |
db034ac5 | 324 | fputs_filtered ("}", stream); |
c906108c SS |
325 | } |
326 | return; | |
327 | ||
c906108c SS |
328 | case TERNOP_COND: |
329 | if ((int) prec > (int) PREC_COMMA) | |
330 | fputs_filtered ("(", stream); | |
331 | /* Print the subexpressions, forcing parentheses | |
c5aa993b JM |
332 | around any binary operations within them. |
333 | This is more parentheses than are strictly necessary, | |
334 | but it looks clearer. */ | |
c906108c SS |
335 | print_subexp (exp, pos, stream, PREC_HYPER); |
336 | fputs_filtered (" ? ", stream); | |
337 | print_subexp (exp, pos, stream, PREC_HYPER); | |
338 | fputs_filtered (" : ", stream); | |
339 | print_subexp (exp, pos, stream, PREC_HYPER); | |
340 | if ((int) prec > (int) PREC_COMMA) | |
341 | fputs_filtered (")", stream); | |
342 | return; | |
343 | ||
344 | case TERNOP_SLICE: | |
c906108c SS |
345 | print_subexp (exp, pos, stream, PREC_SUFFIX); |
346 | fputs_filtered ("(", stream); | |
347 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
348 | fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream); | |
349 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
350 | fputs_filtered (")", stream); | |
351 | return; | |
352 | ||
353 | case STRUCTOP_STRUCT: | |
354 | tem = longest_to_int (exp->elts[pc + 1].longconst); | |
355 | (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); | |
356 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
357 | fputs_filtered (".", stream); | |
358 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
359 | return; | |
360 | ||
0963b4bd | 361 | /* Will not occur for Modula-2. */ |
c906108c SS |
362 | case STRUCTOP_PTR: |
363 | tem = longest_to_int (exp->elts[pc + 1].longconst); | |
364 | (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); | |
365 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
366 | fputs_filtered ("->", stream); | |
367 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
368 | return; | |
369 | ||
0534816d DJ |
370 | case STRUCTOP_MEMBER: |
371 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
372 | fputs_filtered (".*", stream); | |
373 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
374 | return; | |
375 | ||
376 | case STRUCTOP_MPTR: | |
377 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
378 | fputs_filtered ("->*", stream); | |
379 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
380 | return; | |
381 | ||
c906108c SS |
382 | case BINOP_SUBSCRIPT: |
383 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
384 | fputs_filtered ("[", stream); | |
385 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
386 | fputs_filtered ("]", stream); | |
387 | return; | |
388 | ||
389 | case UNOP_POSTINCREMENT: | |
390 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
391 | fputs_filtered ("++", stream); | |
392 | return; | |
393 | ||
394 | case UNOP_POSTDECREMENT: | |
395 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
396 | fputs_filtered ("--", stream); | |
397 | return; | |
398 | ||
399 | case UNOP_CAST: | |
400 | (*pos) += 2; | |
401 | if ((int) prec > (int) PREC_PREFIX) | |
c5aa993b | 402 | fputs_filtered ("(", stream); |
c906108c SS |
403 | fputs_filtered ("(", stream); |
404 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
405 | fputs_filtered (") ", stream); | |
406 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
407 | if ((int) prec > (int) PREC_PREFIX) | |
c5aa993b | 408 | fputs_filtered (")", stream); |
c906108c SS |
409 | return; |
410 | ||
9eaf6705 | 411 | case UNOP_CAST_TYPE: |
9eaf6705 TT |
412 | if ((int) prec > (int) PREC_PREFIX) |
413 | fputs_filtered ("(", stream); | |
414 | fputs_filtered ("(", stream); | |
415 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
416 | fputs_filtered (") ", stream); | |
417 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
418 | if ((int) prec > (int) PREC_PREFIX) | |
419 | fputs_filtered (")", stream); | |
420 | return; | |
421 | ||
4e8f195d TT |
422 | case UNOP_DYNAMIC_CAST: |
423 | case UNOP_REINTERPRET_CAST: | |
424 | fputs_filtered (opcode == UNOP_DYNAMIC_CAST ? "dynamic_cast" | |
425 | : "reinterpret_cast", stream); | |
426 | fputs_filtered ("<", stream); | |
9eaf6705 | 427 | print_subexp (exp, pos, stream, PREC_PREFIX); |
4e8f195d TT |
428 | fputs_filtered ("> (", stream); |
429 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
430 | fputs_filtered (")", stream); | |
431 | return; | |
432 | ||
c906108c SS |
433 | case UNOP_MEMVAL: |
434 | (*pos) += 2; | |
435 | if ((int) prec > (int) PREC_PREFIX) | |
c5aa993b | 436 | fputs_filtered ("(", stream); |
905e0470 PM |
437 | if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC |
438 | && exp->elts[pc + 3].opcode == OP_LONG) | |
c5aa993b | 439 | { |
79a45b7d TT |
440 | struct value_print_options opts; |
441 | ||
c5aa993b JM |
442 | /* We have a minimal symbol fn, probably. It's encoded |
443 | as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address). | |
444 | Swallow the OP_LONG (including both its opcodes); ignore | |
445 | its type; print the value in the type of the MEMVAL. */ | |
446 | (*pos) += 4; | |
447 | val = value_at_lazy (exp->elts[pc + 1].type, | |
00a4c844 | 448 | (CORE_ADDR) exp->elts[pc + 5].longconst); |
79a45b7d TT |
449 | get_raw_print_options (&opts); |
450 | value_print (val, stream, &opts); | |
c5aa993b JM |
451 | } |
452 | else | |
453 | { | |
454 | fputs_filtered ("{", stream); | |
455 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
456 | fputs_filtered ("} ", stream); | |
457 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
458 | } | |
c906108c | 459 | if ((int) prec > (int) PREC_PREFIX) |
c5aa993b | 460 | fputs_filtered (")", stream); |
c906108c SS |
461 | return; |
462 | ||
9eaf6705 | 463 | case UNOP_MEMVAL_TYPE: |
9eaf6705 TT |
464 | if ((int) prec > (int) PREC_PREFIX) |
465 | fputs_filtered ("(", stream); | |
466 | fputs_filtered ("{", stream); | |
467 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
468 | fputs_filtered ("} ", stream); | |
469 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
470 | if ((int) prec > (int) PREC_PREFIX) | |
471 | fputs_filtered (")", stream); | |
472 | return; | |
473 | ||
9e35dae4 DJ |
474 | case UNOP_MEMVAL_TLS: |
475 | (*pos) += 3; | |
476 | if ((int) prec > (int) PREC_PREFIX) | |
477 | fputs_filtered ("(", stream); | |
478 | fputs_filtered ("{", stream); | |
479 | type_print (exp->elts[pc + 2].type, "", stream, 0); | |
480 | fputs_filtered ("} ", stream); | |
481 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
482 | if ((int) prec > (int) PREC_PREFIX) | |
483 | fputs_filtered (")", stream); | |
484 | return; | |
485 | ||
c906108c SS |
486 | case BINOP_ASSIGN_MODIFY: |
487 | opcode = exp->elts[pc + 1].opcode; | |
488 | (*pos) += 2; | |
489 | myprec = PREC_ASSIGN; | |
490 | assoc = 1; | |
491 | assign_modify = 1; | |
492 | op_str = "???"; | |
493 | for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++) | |
494 | if (op_print_tab[tem].opcode == opcode) | |
495 | { | |
496 | op_str = op_print_tab[tem].string; | |
497 | break; | |
498 | } | |
499 | if (op_print_tab[tem].opcode != opcode) | |
500 | /* Not found; don't try to keep going because we don't know how | |
501 | to interpret further elements. */ | |
8a3fe4f8 | 502 | error (_("Invalid expression")); |
c906108c SS |
503 | break; |
504 | ||
c5aa993b | 505 | /* C++ ops */ |
c906108c SS |
506 | |
507 | case OP_THIS: | |
508 | ++(*pos); | |
aee28ec6 TT |
509 | if (exp->language_defn->la_name_of_this) |
510 | fputs_filtered (exp->language_defn->la_name_of_this, stream); | |
511 | else | |
512 | fprintf_filtered (stream, _("<language %s has no 'this'>"), | |
513 | exp->language_defn->la_name); | |
82eeeb94 AF |
514 | return; |
515 | ||
c5aa993b | 516 | /* Modula-2 ops */ |
c906108c SS |
517 | |
518 | case MULTI_SUBSCRIPT: | |
519 | (*pos) += 2; | |
520 | nargs = longest_to_int (exp->elts[pc + 1].longconst); | |
521 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
522 | fprintf_unfiltered (stream, " ["); | |
523 | for (tem = 0; tem < nargs; tem++) | |
524 | { | |
525 | if (tem != 0) | |
526 | fprintf_unfiltered (stream, ", "); | |
527 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
528 | } | |
529 | fprintf_unfiltered (stream, "]"); | |
530 | return; | |
531 | ||
532 | case BINOP_VAL: | |
c5aa993b JM |
533 | (*pos) += 2; |
534 | fprintf_unfiltered (stream, "VAL("); | |
535 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
536 | fprintf_unfiltered (stream, ","); | |
537 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
538 | fprintf_unfiltered (stream, ")"); | |
c906108c | 539 | return; |
c5aa993b | 540 | |
600ea1be JK |
541 | case TYPE_INSTANCE: |
542 | { | |
543 | LONGEST count = exp->elts[pc + 1].longconst; | |
544 | ||
545 | /* The COUNT. */ | |
546 | (*pos)++; | |
547 | fputs_unfiltered ("TypesInstance(", stream); | |
548 | while (count-- > 0) | |
549 | { | |
550 | type_print (exp->elts[(*pos)++].type, "", stream, 0); | |
551 | if (count > 0) | |
552 | fputs_unfiltered (",", stream); | |
553 | } | |
554 | fputs_unfiltered (",", stream); | |
555 | /* Ending COUNT and ending TYPE_INSTANCE. */ | |
556 | (*pos) += 2; | |
557 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
558 | fputs_unfiltered (")", stream); | |
559 | return; | |
560 | } | |
561 | ||
c5aa993b | 562 | /* Default ops */ |
c906108c SS |
563 | |
564 | default: | |
565 | op_str = "???"; | |
566 | for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++) | |
567 | if (op_print_tab[tem].opcode == opcode) | |
568 | { | |
569 | op_str = op_print_tab[tem].string; | |
570 | myprec = op_print_tab[tem].precedence; | |
571 | assoc = op_print_tab[tem].right_assoc; | |
572 | break; | |
573 | } | |
574 | if (op_print_tab[tem].opcode != opcode) | |
575 | /* Not found; don't try to keep going because we don't know how | |
576 | to interpret further elements. For example, this happens | |
577 | if opcode is OP_TYPE. */ | |
8a3fe4f8 | 578 | error (_("Invalid expression")); |
c5aa993b | 579 | } |
c906108c | 580 | |
0963b4bd | 581 | /* Note that PREC_BUILTIN will always emit parentheses. */ |
c906108c SS |
582 | if ((int) myprec < (int) prec) |
583 | fputs_filtered ("(", stream); | |
584 | if ((int) opcode > (int) BINOP_END) | |
585 | { | |
586 | if (assoc) | |
587 | { | |
588 | /* Unary postfix operator. */ | |
589 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
590 | fputs_filtered (op_str, stream); | |
591 | } | |
592 | else | |
593 | { | |
594 | /* Unary prefix operator. */ | |
595 | fputs_filtered (op_str, stream); | |
596 | if (myprec == PREC_BUILTIN_FUNCTION) | |
597 | fputs_filtered ("(", stream); | |
598 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
599 | if (myprec == PREC_BUILTIN_FUNCTION) | |
600 | fputs_filtered (")", stream); | |
601 | } | |
602 | } | |
603 | else | |
604 | { | |
605 | /* Binary operator. */ | |
606 | /* Print left operand. | |
c5aa993b JM |
607 | If operator is right-associative, |
608 | increment precedence for this operand. */ | |
c906108c SS |
609 | print_subexp (exp, pos, stream, |
610 | (enum precedence) ((int) myprec + assoc)); | |
611 | /* Print the operator itself. */ | |
612 | if (assign_modify) | |
613 | fprintf_filtered (stream, " %s= ", op_str); | |
614 | else if (op_str[0] == ',') | |
615 | fprintf_filtered (stream, "%s ", op_str); | |
616 | else | |
617 | fprintf_filtered (stream, " %s ", op_str); | |
618 | /* Print right operand. | |
c5aa993b JM |
619 | If operator is left-associative, |
620 | increment precedence for this operand. */ | |
c906108c SS |
621 | print_subexp (exp, pos, stream, |
622 | (enum precedence) ((int) myprec + !assoc)); | |
623 | } | |
624 | ||
625 | if ((int) myprec < (int) prec) | |
626 | fputs_filtered (")", stream); | |
627 | } | |
628 | ||
629 | /* Return the operator corresponding to opcode OP as | |
630 | a string. NULL indicates that the opcode was not found in the | |
631 | current language table. */ | |
632 | char * | |
fba45db2 | 633 | op_string (enum exp_opcode op) |
c906108c SS |
634 | { |
635 | int tem; | |
f86f5ca3 | 636 | const struct op_print *op_print_tab; |
c906108c SS |
637 | |
638 | op_print_tab = current_language->la_op_print_tab; | |
639 | for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++) | |
640 | if (op_print_tab[tem].opcode == op) | |
641 | return op_print_tab[tem].string; | |
642 | return NULL; | |
643 | } | |
644 | ||
c906108c SS |
645 | /* Support for dumping the raw data from expressions in a human readable |
646 | form. */ | |
647 | ||
24daaebc | 648 | static int dump_subexp_body (struct expression *exp, struct ui_file *, int); |
c906108c | 649 | |
0963b4bd | 650 | /* Name for OPCODE, when it appears in expression EXP. */ |
5f9769d1 | 651 | |
bd0b9f9e | 652 | char * |
5f9769d1 PH |
653 | op_name (struct expression *exp, enum exp_opcode opcode) |
654 | { | |
655 | return exp->language_defn->la_exp_desc->op_name (opcode); | |
656 | } | |
657 | ||
658 | /* Default name for the standard operator OPCODE (i.e., one defined in | |
659 | the definition of enum exp_opcode). */ | |
660 | ||
661 | char * | |
662 | op_name_standard (enum exp_opcode opcode) | |
c906108c SS |
663 | { |
664 | switch (opcode) | |
665 | { | |
666 | default: | |
667 | { | |
668 | static char buf[30]; | |
669 | ||
08850b56 | 670 | xsnprintf (buf, sizeof (buf), "<unknown %d>", opcode); |
c906108c SS |
671 | return buf; |
672 | } | |
56c12414 JK |
673 | #define OP(name) \ |
674 | case name: \ | |
675 | return #name ; | |
676 | #include "std-operator.def" | |
677 | #undef OP | |
c906108c SS |
678 | } |
679 | } | |
680 | ||
a411cd0e DE |
681 | /* Print a raw dump of expression EXP to STREAM. |
682 | NOTE, if non-NULL, is printed as extra explanatory text. */ | |
683 | ||
c906108c | 684 | void |
24daaebc PH |
685 | dump_raw_expression (struct expression *exp, struct ui_file *stream, |
686 | char *note) | |
c906108c SS |
687 | { |
688 | int elt; | |
689 | char *opcode_name; | |
690 | char *eltscan; | |
691 | int eltsize; | |
692 | ||
693 | fprintf_filtered (stream, "Dump of expression @ "); | |
d4f3574e | 694 | gdb_print_host_address (exp, stream); |
a411cd0e DE |
695 | if (note) |
696 | fprintf_filtered (stream, ", %s:", note); | |
697 | fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n", | |
c5aa993b | 698 | exp->language_defn->la_name, exp->nelts, |
9d271fd8 | 699 | (long) sizeof (union exp_element)); |
c906108c SS |
700 | fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode", |
701 | "Hex Value", "String Value"); | |
c5aa993b | 702 | for (elt = 0; elt < exp->nelts; elt++) |
c906108c SS |
703 | { |
704 | fprintf_filtered (stream, "\t%5d ", elt); | |
5f9769d1 | 705 | opcode_name = op_name (exp, exp->elts[elt].opcode); |
c906108c SS |
706 | |
707 | fprintf_filtered (stream, "%20s ", opcode_name); | |
c5aa993b | 708 | print_longest (stream, 'd', 0, exp->elts[elt].longconst); |
c906108c SS |
709 | fprintf_filtered (stream, " "); |
710 | ||
711 | for (eltscan = (char *) &exp->elts[elt], | |
c5aa993b | 712 | eltsize = sizeof (union exp_element); |
c906108c SS |
713 | eltsize-- > 0; |
714 | eltscan++) | |
715 | { | |
716 | fprintf_filtered (stream, "%c", | |
717 | isprint (*eltscan) ? (*eltscan & 0xFF) : '.'); | |
718 | } | |
719 | fprintf_filtered (stream, "\n"); | |
720 | } | |
721 | } | |
722 | ||
24daaebc PH |
723 | /* Dump the subexpression of prefix expression EXP whose operator is at |
724 | position ELT onto STREAM. Returns the position of the next | |
725 | subexpression in EXP. */ | |
c906108c | 726 | |
24daaebc | 727 | int |
fba45db2 | 728 | dump_subexp (struct expression *exp, struct ui_file *stream, int elt) |
c906108c SS |
729 | { |
730 | static int indent = 0; | |
731 | int i; | |
732 | ||
733 | fprintf_filtered (stream, "\n"); | |
734 | fprintf_filtered (stream, "\t%5d ", elt); | |
735 | ||
736 | for (i = 1; i <= indent; i++) | |
737 | fprintf_filtered (stream, " "); | |
738 | indent += 2; | |
739 | ||
5f9769d1 | 740 | fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode)); |
c906108c | 741 | |
24daaebc PH |
742 | elt = dump_subexp_body (exp, stream, elt); |
743 | ||
744 | indent -= 2; | |
745 | ||
746 | return elt; | |
747 | } | |
748 | ||
749 | /* Dump the operands of prefix expression EXP whose opcode is at | |
750 | position ELT onto STREAM. Returns the position of the next | |
751 | subexpression in EXP. */ | |
752 | ||
753 | static int | |
754 | dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt) | |
5f9769d1 PH |
755 | { |
756 | return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt); | |
757 | } | |
758 | ||
759 | /* Default value for subexp_body in exp_descriptor vector. */ | |
760 | ||
761 | int | |
762 | dump_subexp_body_standard (struct expression *exp, | |
763 | struct ui_file *stream, int elt) | |
24daaebc PH |
764 | { |
765 | int opcode = exp->elts[elt++].opcode; | |
766 | ||
767 | switch (opcode) | |
c906108c SS |
768 | { |
769 | case TERNOP_COND: | |
770 | case TERNOP_SLICE: | |
c906108c | 771 | elt = dump_subexp (exp, stream, elt); |
cb969d61 | 772 | /* FALL THROUGH */ |
c906108c SS |
773 | case BINOP_ADD: |
774 | case BINOP_SUB: | |
775 | case BINOP_MUL: | |
776 | case BINOP_DIV: | |
777 | case BINOP_REM: | |
778 | case BINOP_MOD: | |
779 | case BINOP_LSH: | |
780 | case BINOP_RSH: | |
781 | case BINOP_LOGICAL_AND: | |
782 | case BINOP_LOGICAL_OR: | |
783 | case BINOP_BITWISE_AND: | |
784 | case BINOP_BITWISE_IOR: | |
785 | case BINOP_BITWISE_XOR: | |
786 | case BINOP_EQUAL: | |
787 | case BINOP_NOTEQUAL: | |
788 | case BINOP_LESS: | |
789 | case BINOP_GTR: | |
790 | case BINOP_LEQ: | |
791 | case BINOP_GEQ: | |
792 | case BINOP_REPEAT: | |
793 | case BINOP_ASSIGN: | |
794 | case BINOP_COMMA: | |
795 | case BINOP_SUBSCRIPT: | |
796 | case BINOP_EXP: | |
797 | case BINOP_MIN: | |
798 | case BINOP_MAX: | |
c906108c SS |
799 | case BINOP_INTDIV: |
800 | case BINOP_ASSIGN_MODIFY: | |
801 | case BINOP_VAL: | |
c906108c SS |
802 | case BINOP_CONCAT: |
803 | case BINOP_IN: | |
804 | case BINOP_RANGE: | |
805 | case BINOP_END: | |
0534816d DJ |
806 | case STRUCTOP_MEMBER: |
807 | case STRUCTOP_MPTR: | |
c906108c | 808 | elt = dump_subexp (exp, stream, elt); |
cb969d61 | 809 | /* FALL THROUGH */ |
c906108c SS |
810 | case UNOP_NEG: |
811 | case UNOP_LOGICAL_NOT: | |
812 | case UNOP_COMPLEMENT: | |
813 | case UNOP_IND: | |
814 | case UNOP_ADDR: | |
815 | case UNOP_PREINCREMENT: | |
816 | case UNOP_POSTINCREMENT: | |
817 | case UNOP_PREDECREMENT: | |
818 | case UNOP_POSTDECREMENT: | |
819 | case UNOP_SIZEOF: | |
820 | case UNOP_PLUS: | |
821 | case UNOP_CAP: | |
822 | case UNOP_CHR: | |
823 | case UNOP_ORD: | |
824 | case UNOP_ABS: | |
825 | case UNOP_FLOAT: | |
826 | case UNOP_HIGH: | |
827 | case UNOP_MAX: | |
828 | case UNOP_MIN: | |
829 | case UNOP_ODD: | |
830 | case UNOP_TRUNC: | |
c906108c SS |
831 | elt = dump_subexp (exp, stream, elt); |
832 | break; | |
833 | case OP_LONG: | |
d4f3574e SS |
834 | fprintf_filtered (stream, "Type @"); |
835 | gdb_print_host_address (exp->elts[elt].type, stream); | |
836 | fprintf_filtered (stream, " ("); | |
c906108c SS |
837 | type_print (exp->elts[elt].type, NULL, stream, 0); |
838 | fprintf_filtered (stream, "), value %ld (0x%lx)", | |
c5aa993b JM |
839 | (long) exp->elts[elt + 1].longconst, |
840 | (long) exp->elts[elt + 1].longconst); | |
c906108c SS |
841 | elt += 3; |
842 | break; | |
843 | case OP_DOUBLE: | |
d4f3574e SS |
844 | fprintf_filtered (stream, "Type @"); |
845 | gdb_print_host_address (exp->elts[elt].type, stream); | |
846 | fprintf_filtered (stream, " ("); | |
c906108c SS |
847 | type_print (exp->elts[elt].type, NULL, stream, 0); |
848 | fprintf_filtered (stream, "), value %g", | |
c5aa993b | 849 | (double) exp->elts[elt + 1].doubleconst); |
c906108c SS |
850 | elt += 3; |
851 | break; | |
852 | case OP_VAR_VALUE: | |
d4f3574e SS |
853 | fprintf_filtered (stream, "Block @"); |
854 | gdb_print_host_address (exp->elts[elt].block, stream); | |
855 | fprintf_filtered (stream, ", symbol @"); | |
856 | gdb_print_host_address (exp->elts[elt + 1].symbol, stream); | |
857 | fprintf_filtered (stream, " (%s)", | |
3567439c | 858 | SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol)); |
c906108c SS |
859 | elt += 3; |
860 | break; | |
36b11add JK |
861 | case OP_VAR_ENTRY_VALUE: |
862 | fprintf_filtered (stream, "Entry value of symbol @"); | |
863 | gdb_print_host_address (exp->elts[elt].symbol, stream); | |
864 | fprintf_filtered (stream, " (%s)", | |
865 | SYMBOL_PRINT_NAME (exp->elts[elt].symbol)); | |
866 | elt += 2; | |
867 | break; | |
c906108c SS |
868 | case OP_LAST: |
869 | fprintf_filtered (stream, "History element %ld", | |
c5aa993b | 870 | (long) exp->elts[elt].longconst); |
c906108c SS |
871 | elt += 2; |
872 | break; | |
873 | case OP_REGISTER: | |
67f3407f DJ |
874 | fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string); |
875 | elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1); | |
c906108c SS |
876 | break; |
877 | case OP_INTERNALVAR: | |
d4f3574e SS |
878 | fprintf_filtered (stream, "Internal var @"); |
879 | gdb_print_host_address (exp->elts[elt].internalvar, stream); | |
880 | fprintf_filtered (stream, " (%s)", | |
4fa62494 | 881 | internalvar_name (exp->elts[elt].internalvar)); |
c906108c SS |
882 | elt += 2; |
883 | break; | |
884 | case OP_FUNCALL: | |
885 | { | |
24daaebc | 886 | int i, nargs; |
c906108c SS |
887 | |
888 | nargs = longest_to_int (exp->elts[elt].longconst); | |
889 | ||
890 | fprintf_filtered (stream, "Number of args: %d", nargs); | |
891 | elt += 2; | |
892 | ||
893 | for (i = 1; i <= nargs + 1; i++) | |
894 | elt = dump_subexp (exp, stream, elt); | |
895 | } | |
896 | break; | |
897 | case OP_ARRAY: | |
898 | { | |
899 | int lower, upper; | |
900 | int i; | |
901 | ||
902 | lower = longest_to_int (exp->elts[elt].longconst); | |
903 | upper = longest_to_int (exp->elts[elt + 1].longconst); | |
904 | ||
905 | fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper); | |
906 | elt += 3; | |
907 | ||
908 | for (i = 1; i <= upper - lower + 1; i++) | |
909 | elt = dump_subexp (exp, stream, elt); | |
910 | } | |
911 | break; | |
4e8f195d TT |
912 | case UNOP_DYNAMIC_CAST: |
913 | case UNOP_REINTERPRET_CAST: | |
9eaf6705 TT |
914 | case UNOP_CAST_TYPE: |
915 | case UNOP_MEMVAL_TYPE: | |
9eaf6705 TT |
916 | fprintf_filtered (stream, " ("); |
917 | elt = dump_subexp (exp, stream, elt); | |
918 | fprintf_filtered (stream, ")"); | |
919 | elt = dump_subexp (exp, stream, elt); | |
920 | break; | |
921 | case UNOP_MEMVAL: | |
922 | case UNOP_CAST: | |
d4f3574e SS |
923 | fprintf_filtered (stream, "Type @"); |
924 | gdb_print_host_address (exp->elts[elt].type, stream); | |
925 | fprintf_filtered (stream, " ("); | |
c906108c SS |
926 | type_print (exp->elts[elt].type, NULL, stream, 0); |
927 | fprintf_filtered (stream, ")"); | |
928 | elt = dump_subexp (exp, stream, elt + 2); | |
929 | break; | |
9e35dae4 DJ |
930 | case UNOP_MEMVAL_TLS: |
931 | fprintf_filtered (stream, "TLS type @"); | |
932 | gdb_print_host_address (exp->elts[elt + 1].type, stream); | |
933 | fprintf_filtered (stream, " (__thread /* \"%s\" */ ", | |
934 | (exp->elts[elt].objfile == NULL ? "(null)" | |
935 | : exp->elts[elt].objfile->name)); | |
936 | type_print (exp->elts[elt + 1].type, NULL, stream, 0); | |
937 | fprintf_filtered (stream, ")"); | |
938 | elt = dump_subexp (exp, stream, elt + 3); | |
939 | break; | |
c906108c | 940 | case OP_TYPE: |
d4f3574e SS |
941 | fprintf_filtered (stream, "Type @"); |
942 | gdb_print_host_address (exp->elts[elt].type, stream); | |
943 | fprintf_filtered (stream, " ("); | |
c906108c SS |
944 | type_print (exp->elts[elt].type, NULL, stream, 0); |
945 | fprintf_filtered (stream, ")"); | |
946 | elt += 2; | |
947 | break; | |
608b4967 TT |
948 | case OP_TYPEOF: |
949 | case OP_DECLTYPE: | |
950 | fprintf_filtered (stream, "Typeof ("); | |
951 | elt = dump_subexp (exp, stream, elt); | |
952 | fprintf_filtered (stream, ")"); | |
953 | break; | |
c906108c SS |
954 | case STRUCTOP_STRUCT: |
955 | case STRUCTOP_PTR: | |
956 | { | |
957 | char *elem_name; | |
958 | int len; | |
959 | ||
960 | len = longest_to_int (exp->elts[elt].longconst); | |
961 | elem_name = &exp->elts[elt + 1].string; | |
962 | ||
963 | fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name); | |
964 | elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1)); | |
965 | } | |
966 | break; | |
967 | case OP_SCOPE: | |
968 | { | |
969 | char *elem_name; | |
970 | int len; | |
971 | ||
d4f3574e SS |
972 | fprintf_filtered (stream, "Type @"); |
973 | gdb_print_host_address (exp->elts[elt].type, stream); | |
974 | fprintf_filtered (stream, " ("); | |
c906108c SS |
975 | type_print (exp->elts[elt].type, NULL, stream, 0); |
976 | fprintf_filtered (stream, ") "); | |
977 | ||
978 | len = longest_to_int (exp->elts[elt + 1].longconst); | |
979 | elem_name = &exp->elts[elt + 2].string; | |
980 | ||
981 | fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name); | |
982 | elt += 4 + BYTES_TO_EXP_ELEM (len + 1); | |
983 | } | |
984 | break; | |
600ea1be JK |
985 | case TYPE_INSTANCE: |
986 | { | |
600ea1be JK |
987 | LONGEST len; |
988 | ||
989 | len = exp->elts[elt++].longconst; | |
990 | fprintf_filtered (stream, "%s TypeInstance: ", plongest (len)); | |
991 | while (len-- > 0) | |
992 | { | |
993 | fprintf_filtered (stream, "Type @"); | |
994 | gdb_print_host_address (exp->elts[elt].type, stream); | |
995 | fprintf_filtered (stream, " ("); | |
996 | type_print (exp->elts[elt].type, NULL, stream, 0); | |
997 | fprintf_filtered (stream, ")"); | |
998 | elt++; | |
999 | if (len > 0) | |
1000 | fputs_filtered (", ", stream); | |
1001 | } | |
1002 | /* Ending LEN and ending TYPE_INSTANCE. */ | |
1003 | elt += 2; | |
1004 | elt = dump_subexp (exp, stream, elt); | |
1005 | } | |
1006 | break; | |
c906108c SS |
1007 | default: |
1008 | case OP_NULL: | |
c906108c SS |
1009 | case MULTI_SUBSCRIPT: |
1010 | case OP_F77_UNDETERMINED_ARGLIST: | |
1011 | case OP_COMPLEX: | |
1012 | case OP_STRING: | |
c906108c SS |
1013 | case OP_BOOL: |
1014 | case OP_M2_STRING: | |
1015 | case OP_THIS: | |
c906108c | 1016 | case OP_NAME: |
c906108c SS |
1017 | fprintf_filtered (stream, "Unknown format"); |
1018 | } | |
1019 | ||
c906108c SS |
1020 | return elt; |
1021 | } | |
1022 | ||
1023 | void | |
24daaebc | 1024 | dump_prefix_expression (struct expression *exp, struct ui_file *stream) |
c906108c SS |
1025 | { |
1026 | int elt; | |
1027 | ||
1028 | fprintf_filtered (stream, "Dump of expression @ "); | |
d4f3574e | 1029 | gdb_print_host_address (exp, stream); |
24daaebc | 1030 | fputs_filtered (", after conversion to prefix form:\nExpression: `", stream); |
4f485ebc | 1031 | print_expression (exp, stream); |
9d271fd8 | 1032 | fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n", |
c5aa993b | 1033 | exp->language_defn->la_name, exp->nelts, |
9d271fd8 | 1034 | (long) sizeof (union exp_element)); |
c906108c SS |
1035 | fputs_filtered ("\n", stream); |
1036 | ||
c5aa993b | 1037 | for (elt = 0; elt < exp->nelts;) |
c906108c SS |
1038 | elt = dump_subexp (exp, stream, elt); |
1039 | fputs_filtered ("\n", stream); | |
1040 | } |