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 SS |
85 | |
86 | case OP_SCOPE: | |
87 | myprec = PREC_PREFIX; | |
88 | assoc = 0; | |
89 | fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream); | |
90 | fputs_filtered ("::", stream); | |
91 | nargs = longest_to_int (exp->elts[pc + 2].longconst); | |
92 | (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1); | |
93 | fputs_filtered (&exp->elts[pc + 3].string, stream); | |
94 | return; | |
95 | ||
96 | case OP_LONG: | |
79a45b7d TT |
97 | { |
98 | struct value_print_options opts; | |
d7f9d729 | 99 | |
79a45b7d TT |
100 | get_raw_print_options (&opts); |
101 | (*pos) += 3; | |
102 | value_print (value_from_longest (exp->elts[pc + 1].type, | |
103 | exp->elts[pc + 2].longconst), | |
104 | stream, &opts); | |
105 | } | |
c906108c SS |
106 | return; |
107 | ||
108 | case OP_DOUBLE: | |
79a45b7d TT |
109 | { |
110 | struct value_print_options opts; | |
d7f9d729 | 111 | |
79a45b7d TT |
112 | get_raw_print_options (&opts); |
113 | (*pos) += 3; | |
114 | value_print (value_from_double (exp->elts[pc + 1].type, | |
115 | exp->elts[pc + 2].doubleconst), | |
116 | stream, &opts); | |
117 | } | |
c906108c SS |
118 | return; |
119 | ||
120 | case OP_VAR_VALUE: | |
121 | { | |
122 | struct block *b; | |
d7f9d729 | 123 | |
c906108c SS |
124 | (*pos) += 3; |
125 | b = exp->elts[pc + 1].block; | |
126 | if (b != NULL | |
127 | && BLOCK_FUNCTION (b) != NULL | |
de5ad195 | 128 | && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL) |
c906108c | 129 | { |
de5ad195 | 130 | fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream); |
c906108c SS |
131 | fputs_filtered ("::", stream); |
132 | } | |
de5ad195 | 133 | fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream); |
c906108c SS |
134 | } |
135 | return; | |
136 | ||
36b11add JK |
137 | case OP_VAR_ENTRY_VALUE: |
138 | { | |
36b11add JK |
139 | (*pos) += 2; |
140 | fprintf_filtered (stream, "%s@entry", | |
141 | SYMBOL_PRINT_NAME (exp->elts[pc + 1].symbol)); | |
142 | } | |
143 | return; | |
144 | ||
c906108c SS |
145 | case OP_LAST: |
146 | (*pos) += 2; | |
147 | fprintf_filtered (stream, "$%d", | |
148 | longest_to_int (exp->elts[pc + 1].longconst)); | |
149 | return; | |
150 | ||
151 | case OP_REGISTER: | |
e36180d7 | 152 | { |
67f3407f | 153 | const char *name = &exp->elts[pc + 2].string; |
d7f9d729 | 154 | |
67f3407f | 155 | (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); |
eb8bc282 | 156 | fprintf_filtered (stream, "$%s", name); |
e36180d7 AC |
157 | return; |
158 | } | |
c906108c SS |
159 | |
160 | case OP_BOOL: | |
161 | (*pos) += 2; | |
162 | fprintf_filtered (stream, "%s", | |
163 | longest_to_int (exp->elts[pc + 1].longconst) | |
164 | ? "TRUE" : "FALSE"); | |
165 | return; | |
166 | ||
167 | case OP_INTERNALVAR: | |
168 | (*pos) += 2; | |
169 | fprintf_filtered (stream, "$%s", | |
c5aa993b | 170 | internalvar_name (exp->elts[pc + 1].internalvar)); |
c906108c SS |
171 | return; |
172 | ||
173 | case OP_FUNCALL: | |
174 | (*pos) += 2; | |
175 | nargs = longest_to_int (exp->elts[pc + 1].longconst); | |
176 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
177 | fputs_filtered (" (", stream); | |
178 | for (tem = 0; tem < nargs; tem++) | |
179 | { | |
180 | if (tem != 0) | |
181 | fputs_filtered (", ", stream); | |
182 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
183 | } | |
184 | fputs_filtered (")", stream); | |
185 | return; | |
186 | ||
187 | case OP_NAME: | |
c5aa993b | 188 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
c906108c SS |
189 | (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); |
190 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
191 | return; | |
192 | ||
193 | case OP_STRING: | |
79a45b7d TT |
194 | { |
195 | struct value_print_options opts; | |
d7f9d729 | 196 | |
79a45b7d TT |
197 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
198 | (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); | |
199 | /* LA_PRINT_STRING will print using the current repeat count threshold. | |
200 | If necessary, we can temporarily set it to zero, or pass it as an | |
201 | additional parameter to LA_PRINT_STRING. -fnf */ | |
202 | get_user_print_options (&opts); | |
6c7a06a3 | 203 | LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, |
be759fcf | 204 | &exp->elts[pc + 2].string, nargs, NULL, 0, &opts); |
79a45b7d | 205 | } |
c906108c SS |
206 | return; |
207 | ||
208 | case OP_BITSTRING: | |
c5aa993b | 209 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
c906108c SS |
210 | (*pos) |
211 | += 3 + BYTES_TO_EXP_ELEM ((nargs + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT); | |
212 | fprintf_unfiltered (stream, "B'<unimplemented>'"); | |
213 | return; | |
214 | ||
3e43a32a MS |
215 | case OP_OBJC_NSSTRING: /* Objective-C Foundation Class |
216 | NSString constant. */ | |
79a45b7d TT |
217 | { |
218 | struct value_print_options opts; | |
d7f9d729 | 219 | |
79a45b7d TT |
220 | nargs = longest_to_int (exp->elts[pc + 1].longconst); |
221 | (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); | |
222 | fputs_filtered ("@\"", stream); | |
223 | get_user_print_options (&opts); | |
6c7a06a3 | 224 | LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, |
be759fcf | 225 | &exp->elts[pc + 2].string, nargs, NULL, 0, &opts); |
79a45b7d TT |
226 | fputs_filtered ("\"", stream); |
227 | } | |
82eeeb94 AF |
228 | return; |
229 | ||
230 | case OP_OBJC_MSGCALL: | |
231 | { /* Objective C message (method) call. */ | |
232 | char *selector; | |
d7f9d729 | 233 | |
82eeeb94 AF |
234 | (*pos) += 3; |
235 | nargs = longest_to_int (exp->elts[pc + 2].longconst); | |
236 | fprintf_unfiltered (stream, "["); | |
237 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
238 | if (0 == target_read_string (exp->elts[pc + 1].longconst, | |
239 | &selector, 1024, NULL)) | |
240 | { | |
8a3fe4f8 | 241 | error (_("bad selector")); |
82eeeb94 AF |
242 | return; |
243 | } | |
244 | if (nargs) | |
245 | { | |
246 | char *s, *nextS; | |
d7f9d729 | 247 | |
82eeeb94 AF |
248 | s = alloca (strlen (selector) + 1); |
249 | strcpy (s, selector); | |
250 | for (tem = 0; tem < nargs; tem++) | |
251 | { | |
252 | nextS = strchr (s, ':'); | |
fcd776e5 | 253 | gdb_assert (nextS); /* Make sure we found ':'. */ |
82eeeb94 AF |
254 | *nextS = '\0'; |
255 | fprintf_unfiltered (stream, " %s: ", s); | |
256 | s = nextS + 1; | |
257 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
258 | } | |
259 | } | |
260 | else | |
261 | { | |
262 | fprintf_unfiltered (stream, " %s", selector); | |
263 | } | |
264 | fprintf_unfiltered (stream, "]"); | |
0963b4bd | 265 | /* "selector" was malloc'd by target_read_string. Free it. */ |
4ef3f3be | 266 | xfree (selector); |
82eeeb94 AF |
267 | return; |
268 | } | |
269 | ||
c906108c SS |
270 | case OP_ARRAY: |
271 | (*pos) += 3; | |
272 | nargs = longest_to_int (exp->elts[pc + 2].longconst); | |
273 | nargs -= longest_to_int (exp->elts[pc + 1].longconst); | |
274 | nargs++; | |
275 | tem = 0; | |
276 | if (exp->elts[pc + 4].opcode == OP_LONG | |
b806fb9a UW |
277 | && exp->elts[pc + 5].type |
278 | == builtin_type (exp->gdbarch)->builtin_char | |
c906108c SS |
279 | && exp->language_defn->la_language == language_c) |
280 | { | |
281 | /* Attempt to print C character arrays using string syntax. | |
282 | Walk through the args, picking up one character from each | |
283 | of the OP_LONG expression elements. If any array element | |
284 | does not match our expection of what we should find for | |
285 | a simple string, revert back to array printing. Note that | |
286 | the last expression element is an explicit null terminator | |
0963b4bd | 287 | byte, which doesn't get printed. */ |
c906108c SS |
288 | tempstr = alloca (nargs); |
289 | pc += 4; | |
290 | while (tem < nargs) | |
291 | { | |
292 | if (exp->elts[pc].opcode != OP_LONG | |
b806fb9a UW |
293 | || exp->elts[pc + 1].type |
294 | != builtin_type (exp->gdbarch)->builtin_char) | |
c906108c | 295 | { |
0963b4bd MS |
296 | /* Not a simple array of char, use regular array |
297 | printing. */ | |
c906108c SS |
298 | tem = 0; |
299 | break; | |
300 | } | |
301 | else | |
302 | { | |
303 | tempstr[tem++] = | |
304 | longest_to_int (exp->elts[pc + 2].longconst); | |
305 | pc += 4; | |
306 | } | |
307 | } | |
308 | } | |
309 | if (tem > 0) | |
310 | { | |
79a45b7d | 311 | struct value_print_options opts; |
d7f9d729 | 312 | |
79a45b7d | 313 | get_user_print_options (&opts); |
6c7a06a3 | 314 | LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, |
be759fcf | 315 | tempstr, nargs - 1, NULL, 0, &opts); |
c906108c SS |
316 | (*pos) = pc; |
317 | } | |
318 | else | |
319 | { | |
db034ac5 | 320 | fputs_filtered (" {", stream); |
c906108c SS |
321 | for (tem = 0; tem < nargs; tem++) |
322 | { | |
323 | if (tem != 0) | |
324 | { | |
325 | fputs_filtered (", ", stream); | |
326 | } | |
327 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
328 | } | |
db034ac5 | 329 | fputs_filtered ("}", stream); |
c906108c SS |
330 | } |
331 | return; | |
332 | ||
333 | case OP_LABELED: | |
334 | tem = longest_to_int (exp->elts[pc + 1].longconst); | |
335 | (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); | |
1b831c93 | 336 | /* Gcc support both these syntaxes. Unsure which is preferred. */ |
c906108c | 337 | #if 1 |
1b831c93 AC |
338 | fputs_filtered (&exp->elts[pc + 2].string, stream); |
339 | fputs_filtered (": ", stream); | |
c906108c | 340 | #else |
1b831c93 AC |
341 | fputs_filtered (".", stream); |
342 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
343 | fputs_filtered ("=", stream); | |
c906108c | 344 | #endif |
c906108c SS |
345 | print_subexp (exp, pos, stream, PREC_SUFFIX); |
346 | return; | |
347 | ||
348 | case TERNOP_COND: | |
349 | if ((int) prec > (int) PREC_COMMA) | |
350 | fputs_filtered ("(", stream); | |
351 | /* Print the subexpressions, forcing parentheses | |
c5aa993b JM |
352 | around any binary operations within them. |
353 | This is more parentheses than are strictly necessary, | |
354 | but it looks clearer. */ | |
c906108c SS |
355 | print_subexp (exp, pos, stream, PREC_HYPER); |
356 | fputs_filtered (" ? ", stream); | |
357 | print_subexp (exp, pos, stream, PREC_HYPER); | |
358 | fputs_filtered (" : ", stream); | |
359 | print_subexp (exp, pos, stream, PREC_HYPER); | |
360 | if ((int) prec > (int) PREC_COMMA) | |
361 | fputs_filtered (")", stream); | |
362 | return; | |
363 | ||
364 | case TERNOP_SLICE: | |
365 | case TERNOP_SLICE_COUNT: | |
366 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
367 | fputs_filtered ("(", stream); | |
368 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
369 | fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream); | |
370 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
371 | fputs_filtered (")", stream); | |
372 | return; | |
373 | ||
374 | case STRUCTOP_STRUCT: | |
375 | tem = longest_to_int (exp->elts[pc + 1].longconst); | |
376 | (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); | |
377 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
378 | fputs_filtered (".", stream); | |
379 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
380 | return; | |
381 | ||
0963b4bd | 382 | /* Will not occur for Modula-2. */ |
c906108c SS |
383 | case STRUCTOP_PTR: |
384 | tem = longest_to_int (exp->elts[pc + 1].longconst); | |
385 | (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); | |
386 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
387 | fputs_filtered ("->", stream); | |
388 | fputs_filtered (&exp->elts[pc + 2].string, stream); | |
389 | return; | |
390 | ||
0534816d DJ |
391 | case STRUCTOP_MEMBER: |
392 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
393 | fputs_filtered (".*", stream); | |
394 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
395 | return; | |
396 | ||
397 | case STRUCTOP_MPTR: | |
398 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
399 | fputs_filtered ("->*", stream); | |
400 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
401 | return; | |
402 | ||
c906108c SS |
403 | case BINOP_SUBSCRIPT: |
404 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
405 | fputs_filtered ("[", stream); | |
406 | print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); | |
407 | fputs_filtered ("]", stream); | |
408 | return; | |
409 | ||
410 | case UNOP_POSTINCREMENT: | |
411 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
412 | fputs_filtered ("++", stream); | |
413 | return; | |
414 | ||
415 | case UNOP_POSTDECREMENT: | |
416 | print_subexp (exp, pos, stream, PREC_SUFFIX); | |
417 | fputs_filtered ("--", stream); | |
418 | return; | |
419 | ||
420 | case UNOP_CAST: | |
421 | (*pos) += 2; | |
422 | if ((int) prec > (int) PREC_PREFIX) | |
c5aa993b | 423 | fputs_filtered ("(", stream); |
c906108c SS |
424 | fputs_filtered ("(", stream); |
425 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
426 | fputs_filtered (") ", stream); | |
427 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
428 | if ((int) prec > (int) PREC_PREFIX) | |
c5aa993b | 429 | fputs_filtered (")", stream); |
c906108c SS |
430 | return; |
431 | ||
4e8f195d TT |
432 | case UNOP_DYNAMIC_CAST: |
433 | case UNOP_REINTERPRET_CAST: | |
434 | fputs_filtered (opcode == UNOP_DYNAMIC_CAST ? "dynamic_cast" | |
435 | : "reinterpret_cast", stream); | |
436 | fputs_filtered ("<", stream); | |
437 | (*pos) += 2; | |
438 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
439 | fputs_filtered ("> (", stream); | |
440 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
441 | fputs_filtered (")", stream); | |
442 | return; | |
443 | ||
c906108c SS |
444 | case UNOP_MEMVAL: |
445 | (*pos) += 2; | |
446 | if ((int) prec > (int) PREC_PREFIX) | |
c5aa993b | 447 | fputs_filtered ("(", stream); |
905e0470 PM |
448 | if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC |
449 | && exp->elts[pc + 3].opcode == OP_LONG) | |
c5aa993b | 450 | { |
79a45b7d TT |
451 | struct value_print_options opts; |
452 | ||
c5aa993b JM |
453 | /* We have a minimal symbol fn, probably. It's encoded |
454 | as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address). | |
455 | Swallow the OP_LONG (including both its opcodes); ignore | |
456 | its type; print the value in the type of the MEMVAL. */ | |
457 | (*pos) += 4; | |
458 | val = value_at_lazy (exp->elts[pc + 1].type, | |
00a4c844 | 459 | (CORE_ADDR) exp->elts[pc + 5].longconst); |
79a45b7d TT |
460 | get_raw_print_options (&opts); |
461 | value_print (val, stream, &opts); | |
c5aa993b JM |
462 | } |
463 | else | |
464 | { | |
465 | fputs_filtered ("{", stream); | |
466 | type_print (exp->elts[pc + 1].type, "", stream, 0); | |
467 | fputs_filtered ("} ", stream); | |
468 | print_subexp (exp, pos, stream, PREC_PREFIX); | |
469 | } | |
c906108c | 470 | if ((int) prec > (int) PREC_PREFIX) |
c5aa993b | 471 | fputs_filtered (")", stream); |
c906108c SS |
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 | ||
670 | sprintf (buf, "<unknown %d>", opcode); | |
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: | |
771 | case TERNOP_SLICE_COUNT: | |
772 | elt = dump_subexp (exp, stream, elt); | |
cb969d61 | 773 | /* FALL THROUGH */ |
c906108c SS |
774 | case BINOP_ADD: |
775 | case BINOP_SUB: | |
776 | case BINOP_MUL: | |
777 | case BINOP_DIV: | |
778 | case BINOP_REM: | |
779 | case BINOP_MOD: | |
780 | case BINOP_LSH: | |
781 | case BINOP_RSH: | |
782 | case BINOP_LOGICAL_AND: | |
783 | case BINOP_LOGICAL_OR: | |
784 | case BINOP_BITWISE_AND: | |
785 | case BINOP_BITWISE_IOR: | |
786 | case BINOP_BITWISE_XOR: | |
787 | case BINOP_EQUAL: | |
788 | case BINOP_NOTEQUAL: | |
789 | case BINOP_LESS: | |
790 | case BINOP_GTR: | |
791 | case BINOP_LEQ: | |
792 | case BINOP_GEQ: | |
793 | case BINOP_REPEAT: | |
794 | case BINOP_ASSIGN: | |
795 | case BINOP_COMMA: | |
796 | case BINOP_SUBSCRIPT: | |
797 | case BINOP_EXP: | |
798 | case BINOP_MIN: | |
799 | case BINOP_MAX: | |
c906108c SS |
800 | case BINOP_INTDIV: |
801 | case BINOP_ASSIGN_MODIFY: | |
802 | case BINOP_VAL: | |
c906108c SS |
803 | case BINOP_CONCAT: |
804 | case BINOP_IN: | |
805 | case BINOP_RANGE: | |
806 | case BINOP_END: | |
0534816d DJ |
807 | case STRUCTOP_MEMBER: |
808 | case STRUCTOP_MPTR: | |
c906108c | 809 | elt = dump_subexp (exp, stream, elt); |
cb969d61 | 810 | /* FALL THROUGH */ |
c906108c SS |
811 | case UNOP_NEG: |
812 | case UNOP_LOGICAL_NOT: | |
813 | case UNOP_COMPLEMENT: | |
814 | case UNOP_IND: | |
815 | case UNOP_ADDR: | |
816 | case UNOP_PREINCREMENT: | |
817 | case UNOP_POSTINCREMENT: | |
818 | case UNOP_PREDECREMENT: | |
819 | case UNOP_POSTDECREMENT: | |
820 | case UNOP_SIZEOF: | |
821 | case UNOP_PLUS: | |
822 | case UNOP_CAP: | |
823 | case UNOP_CHR: | |
824 | case UNOP_ORD: | |
825 | case UNOP_ABS: | |
826 | case UNOP_FLOAT: | |
827 | case UNOP_HIGH: | |
828 | case UNOP_MAX: | |
829 | case UNOP_MIN: | |
830 | case UNOP_ODD: | |
831 | case UNOP_TRUNC: | |
c906108c SS |
832 | elt = dump_subexp (exp, stream, elt); |
833 | break; | |
834 | case OP_LONG: | |
d4f3574e SS |
835 | fprintf_filtered (stream, "Type @"); |
836 | gdb_print_host_address (exp->elts[elt].type, stream); | |
837 | fprintf_filtered (stream, " ("); | |
c906108c SS |
838 | type_print (exp->elts[elt].type, NULL, stream, 0); |
839 | fprintf_filtered (stream, "), value %ld (0x%lx)", | |
c5aa993b JM |
840 | (long) exp->elts[elt + 1].longconst, |
841 | (long) exp->elts[elt + 1].longconst); | |
c906108c SS |
842 | elt += 3; |
843 | break; | |
844 | case OP_DOUBLE: | |
d4f3574e SS |
845 | fprintf_filtered (stream, "Type @"); |
846 | gdb_print_host_address (exp->elts[elt].type, stream); | |
847 | fprintf_filtered (stream, " ("); | |
c906108c SS |
848 | type_print (exp->elts[elt].type, NULL, stream, 0); |
849 | fprintf_filtered (stream, "), value %g", | |
c5aa993b | 850 | (double) exp->elts[elt + 1].doubleconst); |
c906108c SS |
851 | elt += 3; |
852 | break; | |
853 | case OP_VAR_VALUE: | |
d4f3574e SS |
854 | fprintf_filtered (stream, "Block @"); |
855 | gdb_print_host_address (exp->elts[elt].block, stream); | |
856 | fprintf_filtered (stream, ", symbol @"); | |
857 | gdb_print_host_address (exp->elts[elt + 1].symbol, stream); | |
858 | fprintf_filtered (stream, " (%s)", | |
3567439c | 859 | SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol)); |
c906108c SS |
860 | elt += 3; |
861 | break; | |
36b11add JK |
862 | case OP_VAR_ENTRY_VALUE: |
863 | fprintf_filtered (stream, "Entry value of symbol @"); | |
864 | gdb_print_host_address (exp->elts[elt].symbol, stream); | |
865 | fprintf_filtered (stream, " (%s)", | |
866 | SYMBOL_PRINT_NAME (exp->elts[elt].symbol)); | |
867 | elt += 2; | |
868 | break; | |
c906108c SS |
869 | case OP_LAST: |
870 | fprintf_filtered (stream, "History element %ld", | |
c5aa993b | 871 | (long) exp->elts[elt].longconst); |
c906108c SS |
872 | elt += 2; |
873 | break; | |
874 | case OP_REGISTER: | |
67f3407f DJ |
875 | fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string); |
876 | elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1); | |
c906108c SS |
877 | break; |
878 | case OP_INTERNALVAR: | |
d4f3574e SS |
879 | fprintf_filtered (stream, "Internal var @"); |
880 | gdb_print_host_address (exp->elts[elt].internalvar, stream); | |
881 | fprintf_filtered (stream, " (%s)", | |
4fa62494 | 882 | internalvar_name (exp->elts[elt].internalvar)); |
c906108c SS |
883 | elt += 2; |
884 | break; | |
885 | case OP_FUNCALL: | |
886 | { | |
24daaebc | 887 | int i, nargs; |
c906108c SS |
888 | |
889 | nargs = longest_to_int (exp->elts[elt].longconst); | |
890 | ||
891 | fprintf_filtered (stream, "Number of args: %d", nargs); | |
892 | elt += 2; | |
893 | ||
894 | for (i = 1; i <= nargs + 1; i++) | |
895 | elt = dump_subexp (exp, stream, elt); | |
896 | } | |
897 | break; | |
898 | case OP_ARRAY: | |
899 | { | |
900 | int lower, upper; | |
901 | int i; | |
902 | ||
903 | lower = longest_to_int (exp->elts[elt].longconst); | |
904 | upper = longest_to_int (exp->elts[elt + 1].longconst); | |
905 | ||
906 | fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper); | |
907 | elt += 3; | |
908 | ||
909 | for (i = 1; i <= upper - lower + 1; i++) | |
910 | elt = dump_subexp (exp, stream, elt); | |
911 | } | |
912 | break; | |
913 | case UNOP_MEMVAL: | |
914 | case UNOP_CAST: | |
4e8f195d TT |
915 | case UNOP_DYNAMIC_CAST: |
916 | case UNOP_REINTERPRET_CAST: | |
d4f3574e SS |
917 | fprintf_filtered (stream, "Type @"); |
918 | gdb_print_host_address (exp->elts[elt].type, stream); | |
919 | fprintf_filtered (stream, " ("); | |
c906108c SS |
920 | type_print (exp->elts[elt].type, NULL, stream, 0); |
921 | fprintf_filtered (stream, ")"); | |
922 | elt = dump_subexp (exp, stream, elt + 2); | |
923 | break; | |
9e35dae4 DJ |
924 | case UNOP_MEMVAL_TLS: |
925 | fprintf_filtered (stream, "TLS type @"); | |
926 | gdb_print_host_address (exp->elts[elt + 1].type, stream); | |
927 | fprintf_filtered (stream, " (__thread /* \"%s\" */ ", | |
928 | (exp->elts[elt].objfile == NULL ? "(null)" | |
929 | : exp->elts[elt].objfile->name)); | |
930 | type_print (exp->elts[elt + 1].type, NULL, stream, 0); | |
931 | fprintf_filtered (stream, ")"); | |
932 | elt = dump_subexp (exp, stream, elt + 3); | |
933 | break; | |
c906108c | 934 | case OP_TYPE: |
d4f3574e SS |
935 | fprintf_filtered (stream, "Type @"); |
936 | gdb_print_host_address (exp->elts[elt].type, stream); | |
937 | fprintf_filtered (stream, " ("); | |
c906108c SS |
938 | type_print (exp->elts[elt].type, NULL, stream, 0); |
939 | fprintf_filtered (stream, ")"); | |
940 | elt += 2; | |
941 | break; | |
942 | case STRUCTOP_STRUCT: | |
943 | case STRUCTOP_PTR: | |
944 | { | |
945 | char *elem_name; | |
946 | int len; | |
947 | ||
948 | len = longest_to_int (exp->elts[elt].longconst); | |
949 | elem_name = &exp->elts[elt + 1].string; | |
950 | ||
951 | fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name); | |
952 | elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1)); | |
953 | } | |
954 | break; | |
955 | case OP_SCOPE: | |
956 | { | |
957 | char *elem_name; | |
958 | int len; | |
959 | ||
d4f3574e SS |
960 | fprintf_filtered (stream, "Type @"); |
961 | gdb_print_host_address (exp->elts[elt].type, stream); | |
962 | fprintf_filtered (stream, " ("); | |
c906108c SS |
963 | type_print (exp->elts[elt].type, NULL, stream, 0); |
964 | fprintf_filtered (stream, ") "); | |
965 | ||
966 | len = longest_to_int (exp->elts[elt + 1].longconst); | |
967 | elem_name = &exp->elts[elt + 2].string; | |
968 | ||
969 | fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name); | |
970 | elt += 4 + BYTES_TO_EXP_ELEM (len + 1); | |
971 | } | |
972 | break; | |
600ea1be JK |
973 | case TYPE_INSTANCE: |
974 | { | |
600ea1be JK |
975 | LONGEST len; |
976 | ||
977 | len = exp->elts[elt++].longconst; | |
978 | fprintf_filtered (stream, "%s TypeInstance: ", plongest (len)); | |
979 | while (len-- > 0) | |
980 | { | |
981 | fprintf_filtered (stream, "Type @"); | |
982 | gdb_print_host_address (exp->elts[elt].type, stream); | |
983 | fprintf_filtered (stream, " ("); | |
984 | type_print (exp->elts[elt].type, NULL, stream, 0); | |
985 | fprintf_filtered (stream, ")"); | |
986 | elt++; | |
987 | if (len > 0) | |
988 | fputs_filtered (", ", stream); | |
989 | } | |
990 | /* Ending LEN and ending TYPE_INSTANCE. */ | |
991 | elt += 2; | |
992 | elt = dump_subexp (exp, stream, elt); | |
993 | } | |
994 | break; | |
c906108c SS |
995 | default: |
996 | case OP_NULL: | |
c906108c SS |
997 | case MULTI_SUBSCRIPT: |
998 | case OP_F77_UNDETERMINED_ARGLIST: | |
999 | case OP_COMPLEX: | |
1000 | case OP_STRING: | |
1001 | case OP_BITSTRING: | |
1002 | case OP_BOOL: | |
1003 | case OP_M2_STRING: | |
1004 | case OP_THIS: | |
1005 | case OP_LABELED: | |
1006 | case OP_NAME: | |
c906108c SS |
1007 | fprintf_filtered (stream, "Unknown format"); |
1008 | } | |
1009 | ||
c906108c SS |
1010 | return elt; |
1011 | } | |
1012 | ||
1013 | void | |
24daaebc | 1014 | dump_prefix_expression (struct expression *exp, struct ui_file *stream) |
c906108c SS |
1015 | { |
1016 | int elt; | |
1017 | ||
1018 | fprintf_filtered (stream, "Dump of expression @ "); | |
d4f3574e | 1019 | gdb_print_host_address (exp, stream); |
24daaebc | 1020 | fputs_filtered (", after conversion to prefix form:\nExpression: `", stream); |
c906108c SS |
1021 | if (exp->elts[0].opcode != OP_TYPE) |
1022 | print_expression (exp, stream); | |
1023 | else | |
1024 | fputs_filtered ("Type printing not yet supported....", stream); | |
9d271fd8 | 1025 | fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n", |
c5aa993b | 1026 | exp->language_defn->la_name, exp->nelts, |
9d271fd8 | 1027 | (long) sizeof (union exp_element)); |
c906108c SS |
1028 | fputs_filtered ("\n", stream); |
1029 | ||
c5aa993b | 1030 | for (elt = 0; elt < exp->nelts;) |
c906108c SS |
1031 | elt = dump_subexp (exp, stream, elt); |
1032 | fputs_filtered ("\n", stream); | |
1033 | } |