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