1 /* Print in infix form a struct expression.
2 Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #include "expression.h"
28 #include "parser-defs.h"
29 #include "frame.h" /* For frame_map_regnum_to_name. */
31 #include "gdb_string.h"
37 /* Prototypes for local functions */
39 static void print_subexp (struct expression
*, int *, struct ui_file
*,
43 print_expression (struct expression
*exp
, struct ui_file
*stream
)
46 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
49 /* Print the subexpression of EXP that starts in position POS, on STREAM.
50 PREC is the precedence of the surrounding operator;
51 if the precedence of the main operator of this subexpression is less,
52 parentheses are needed here. */
55 print_subexp (register struct expression
*exp
, register int *pos
,
56 struct ui_file
*stream
, enum precedence prec
)
58 register unsigned tem
;
59 register const struct op_print
*op_print_tab
;
62 register char *op_str
;
63 int assign_modify
= 0;
64 enum exp_opcode opcode
;
65 enum precedence myprec
= PREC_NULL
;
66 /* Set to 1 for a right-associative operator. */
71 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
73 opcode
= exp
->elts
[pc
].opcode
;
81 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
82 fputs_filtered ("::", stream
);
83 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
84 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
85 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
90 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
91 exp
->elts
[pc
+ 2].longconst
),
92 stream
, 0, Val_no_prettyprint
);
97 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
98 exp
->elts
[pc
+ 2].doubleconst
),
99 stream
, 0, Val_no_prettyprint
);
106 b
= exp
->elts
[pc
+ 1].block
;
108 && BLOCK_FUNCTION (b
) != NULL
109 && SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b
)) != NULL
)
111 fputs_filtered (SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b
)), stream
);
112 fputs_filtered ("::", stream
);
114 fputs_filtered (SYMBOL_SOURCE_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
120 fprintf_filtered (stream
, "$%d",
121 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
126 int regnum
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
128 fprintf_filtered (stream
, "$%s", frame_map_regnum_to_name (regnum
));
134 fprintf_filtered (stream
, "%s",
135 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
141 fprintf_filtered (stream
, "$%s",
142 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
147 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
148 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
149 fputs_filtered (" (", stream
);
150 for (tem
= 0; tem
< nargs
; tem
++)
153 fputs_filtered (", ", stream
);
154 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
156 fputs_filtered (")", stream
);
161 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
162 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
163 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
167 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
168 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
169 /* LA_PRINT_STRING will print using the current repeat count threshold.
170 If necessary, we can temporarily set it to zero, or pass it as an
171 additional parameter to LA_PRINT_STRING. -fnf */
172 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
176 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
178 += 3 + BYTES_TO_EXP_ELEM ((nargs
+ HOST_CHAR_BIT
- 1) / HOST_CHAR_BIT
);
179 fprintf_unfiltered (stream
, "B'<unimplemented>'");
182 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class NSString constant. */
183 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
184 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
185 fputs_filtered ("@\"", stream
);
186 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
187 fputs_filtered ("\"", stream
);
190 case OP_OBJC_MSGCALL
:
191 { /* Objective C message (method) call. */
194 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
195 fprintf_unfiltered (stream
, "[");
196 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
197 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
198 &selector
, 1024, NULL
))
200 error ("bad selector");
206 s
= alloca (strlen (selector
) + 1);
207 strcpy (s
, selector
);
208 for (tem
= 0; tem
< nargs
; tem
++)
210 nextS
= strchr (s
, ':');
212 fprintf_unfiltered (stream
, " %s: ", s
);
214 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
219 fprintf_unfiltered (stream
, " %s", selector
);
221 fprintf_unfiltered (stream
, "]");
222 /* "selector" was malloc'd by target_read_string. Free it. */
229 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
230 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
233 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
234 && exp
->elts
[pc
+ 5].type
== builtin_type_char
235 && exp
->language_defn
->la_language
== language_c
)
237 /* Attempt to print C character arrays using string syntax.
238 Walk through the args, picking up one character from each
239 of the OP_LONG expression elements. If any array element
240 does not match our expection of what we should find for
241 a simple string, revert back to array printing. Note that
242 the last expression element is an explicit null terminator
243 byte, which doesn't get printed. */
244 tempstr
= alloca (nargs
);
248 if (exp
->elts
[pc
].opcode
!= OP_LONG
249 || exp
->elts
[pc
+ 1].type
!= builtin_type_char
)
251 /* Not a simple array of char, use regular array printing. */
258 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
265 LA_PRINT_STRING (stream
, tempstr
, nargs
- 1, 1, 0);
270 fputs_filtered (" {", stream
);
271 for (tem
= 0; tem
< nargs
; tem
++)
275 fputs_filtered (", ", stream
);
277 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
279 fputs_filtered ("}", stream
);
284 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
285 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
286 /* Gcc support both these syntaxes. Unsure which is preferred. */
288 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
289 fputs_filtered (": ", stream
);
291 fputs_filtered (".", stream
);
292 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
293 fputs_filtered ("=", stream
);
295 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
299 if ((int) prec
> (int) PREC_COMMA
)
300 fputs_filtered ("(", stream
);
301 /* Print the subexpressions, forcing parentheses
302 around any binary operations within them.
303 This is more parentheses than are strictly necessary,
304 but it looks clearer. */
305 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
306 fputs_filtered (" ? ", stream
);
307 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
308 fputs_filtered (" : ", stream
);
309 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
310 if ((int) prec
> (int) PREC_COMMA
)
311 fputs_filtered (")", stream
);
315 case TERNOP_SLICE_COUNT
:
316 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
317 fputs_filtered ("(", stream
);
318 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
319 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
320 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
321 fputs_filtered (")", stream
);
324 case STRUCTOP_STRUCT
:
325 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
326 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
327 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
328 fputs_filtered (".", stream
);
329 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
332 /* Will not occur for Modula-2 */
334 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
335 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
336 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
337 fputs_filtered ("->", stream
);
338 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
341 case BINOP_SUBSCRIPT
:
342 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
343 fputs_filtered ("[", stream
);
344 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
345 fputs_filtered ("]", stream
);
348 case UNOP_POSTINCREMENT
:
349 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
350 fputs_filtered ("++", stream
);
353 case UNOP_POSTDECREMENT
:
354 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
355 fputs_filtered ("--", stream
);
360 if ((int) prec
> (int) PREC_PREFIX
)
361 fputs_filtered ("(", stream
);
362 fputs_filtered ("(", stream
);
363 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
364 fputs_filtered (") ", stream
);
365 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
366 if ((int) prec
> (int) PREC_PREFIX
)
367 fputs_filtered (")", stream
);
372 if ((int) prec
> (int) PREC_PREFIX
)
373 fputs_filtered ("(", stream
);
374 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
&&
375 exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
377 /* We have a minimal symbol fn, probably. It's encoded
378 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
379 Swallow the OP_LONG (including both its opcodes); ignore
380 its type; print the value in the type of the MEMVAL. */
382 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
383 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
,
385 value_print (val
, stream
, 0, Val_no_prettyprint
);
389 fputs_filtered ("{", stream
);
390 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
391 fputs_filtered ("} ", stream
);
392 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
394 if ((int) prec
> (int) PREC_PREFIX
)
395 fputs_filtered (")", stream
);
398 case BINOP_ASSIGN_MODIFY
:
399 opcode
= exp
->elts
[pc
+ 1].opcode
;
401 myprec
= PREC_ASSIGN
;
405 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
406 if (op_print_tab
[tem
].opcode
== opcode
)
408 op_str
= op_print_tab
[tem
].string
;
411 if (op_print_tab
[tem
].opcode
!= opcode
)
412 /* Not found; don't try to keep going because we don't know how
413 to interpret further elements. */
414 error ("Invalid expression");
421 fputs_filtered ("this", stream
);
424 /* Objective-C ops */
428 fputs_filtered ("self", stream
); /* The ObjC equivalent of "this". */
433 case MULTI_SUBSCRIPT
:
435 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
436 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
437 fprintf_unfiltered (stream
, " [");
438 for (tem
= 0; tem
< nargs
; tem
++)
441 fprintf_unfiltered (stream
, ", ");
442 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
444 fprintf_unfiltered (stream
, "]");
449 fprintf_unfiltered (stream
, "VAL(");
450 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
451 fprintf_unfiltered (stream
, ",");
452 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
453 fprintf_unfiltered (stream
, ")");
458 error ("print_subexp: Not implemented.");
464 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
465 if (op_print_tab
[tem
].opcode
== opcode
)
467 op_str
= op_print_tab
[tem
].string
;
468 myprec
= op_print_tab
[tem
].precedence
;
469 assoc
= op_print_tab
[tem
].right_assoc
;
472 if (op_print_tab
[tem
].opcode
!= opcode
)
473 /* Not found; don't try to keep going because we don't know how
474 to interpret further elements. For example, this happens
475 if opcode is OP_TYPE. */
476 error ("Invalid expression");
479 /* Note that PREC_BUILTIN will always emit parentheses. */
480 if ((int) myprec
< (int) prec
)
481 fputs_filtered ("(", stream
);
482 if ((int) opcode
> (int) BINOP_END
)
486 /* Unary postfix operator. */
487 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
488 fputs_filtered (op_str
, stream
);
492 /* Unary prefix operator. */
493 fputs_filtered (op_str
, stream
);
494 if (myprec
== PREC_BUILTIN_FUNCTION
)
495 fputs_filtered ("(", stream
);
496 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
497 if (myprec
== PREC_BUILTIN_FUNCTION
)
498 fputs_filtered (")", stream
);
503 /* Binary operator. */
504 /* Print left operand.
505 If operator is right-associative,
506 increment precedence for this operand. */
507 print_subexp (exp
, pos
, stream
,
508 (enum precedence
) ((int) myprec
+ assoc
));
509 /* Print the operator itself. */
511 fprintf_filtered (stream
, " %s= ", op_str
);
512 else if (op_str
[0] == ',')
513 fprintf_filtered (stream
, "%s ", op_str
);
515 fprintf_filtered (stream
, " %s ", op_str
);
516 /* Print right operand.
517 If operator is left-associative,
518 increment precedence for this operand. */
519 print_subexp (exp
, pos
, stream
,
520 (enum precedence
) ((int) myprec
+ !assoc
));
523 if ((int) myprec
< (int) prec
)
524 fputs_filtered (")", stream
);
527 /* Return the operator corresponding to opcode OP as
528 a string. NULL indicates that the opcode was not found in the
529 current language table. */
531 op_string (enum exp_opcode op
)
534 register const struct op_print
*op_print_tab
;
536 op_print_tab
= current_language
->la_op_print_tab
;
537 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
538 if (op_print_tab
[tem
].opcode
== op
)
539 return op_print_tab
[tem
].string
;
543 /* Support for dumping the raw data from expressions in a human readable
546 static char *op_name (int opcode
);
557 sprintf (buf
, "<unknown %d>", opcode
);
578 case BINOP_LOGICAL_AND
:
579 return "BINOP_LOGICAL_AND";
580 case BINOP_LOGICAL_OR
:
581 return "BINOP_LOGICAL_OR";
582 case BINOP_BITWISE_AND
:
583 return "BINOP_BITWISE_AND";
584 case BINOP_BITWISE_IOR
:
585 return "BINOP_BITWISE_IOR";
586 case BINOP_BITWISE_XOR
:
587 return "BINOP_BITWISE_XOR";
589 return "BINOP_EQUAL";
591 return "BINOP_NOTEQUAL";
601 return "BINOP_REPEAT";
603 return "BINOP_ASSIGN";
605 return "BINOP_COMMA";
606 case BINOP_SUBSCRIPT
:
607 return "BINOP_SUBSCRIPT";
608 case MULTI_SUBSCRIPT
:
609 return "MULTI_SUBSCRIPT";
616 case STRUCTOP_MEMBER
:
617 return "STRUCTOP_MEMBER";
619 return "STRUCTOP_MPTR";
621 return "BINOP_INTDIV";
622 case BINOP_ASSIGN_MODIFY
:
623 return "BINOP_ASSIGN_MODIFY";
631 return "BINOP_CONCAT";
633 return "BINOP_RANGE";
637 return "TERNOP_COND";
639 return "TERNOP_SLICE";
640 case TERNOP_SLICE_COUNT
:
641 return "TERNOP_SLICE_COUNT";
647 return "OP_VAR_VALUE";
651 return "OP_REGISTER";
653 return "OP_INTERNALVAR";
659 return "OP_BITSTRING";
665 return "UNOP_MEMVAL";
668 case UNOP_LOGICAL_NOT
:
669 return "UNOP_LOGICAL_NOT";
670 case UNOP_COMPLEMENT
:
671 return "UNOP_COMPLEMENT";
676 case UNOP_PREINCREMENT
:
677 return "UNOP_PREINCREMENT";
678 case UNOP_POSTINCREMENT
:
679 return "UNOP_POSTINCREMENT";
680 case UNOP_PREDECREMENT
:
681 return "UNOP_PREDECREMENT";
682 case UNOP_POSTDECREMENT
:
683 return "UNOP_POSTDECREMENT";
685 return "UNOP_SIZEOF";
691 return "UNOP_LENGTH";
717 return "OP_M2_STRING";
718 case STRUCTOP_STRUCT
:
719 return "STRUCTOP_STRUCT";
721 return "STRUCTOP_PTR";
725 return "OP_OBJC_SELF";
736 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
,
744 fprintf_filtered (stream
, "Dump of expression @ ");
745 gdb_print_host_address (exp
, stream
);
746 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
747 if (exp
->elts
[0].opcode
!= OP_TYPE
)
748 print_expression (exp
, stream
);
750 fprintf_filtered (stream
, "Type printing not yet supported....");
751 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
752 exp
->language_defn
->la_name
, exp
->nelts
,
753 (long) sizeof (union exp_element
));
754 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
755 "Hex Value", "String Value");
756 for (elt
= 0; elt
< exp
->nelts
; elt
++)
758 fprintf_filtered (stream
, "\t%5d ", elt
);
759 opcode_name
= op_name (exp
->elts
[elt
].opcode
);
761 fprintf_filtered (stream
, "%20s ", opcode_name
);
762 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
763 fprintf_filtered (stream
, " ");
765 for (eltscan
= (char *) &exp
->elts
[elt
],
766 eltsize
= sizeof (union exp_element
);
770 fprintf_filtered (stream
, "%c",
771 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
773 fprintf_filtered (stream
, "\n");
777 static int dump_subexp (struct expression
*exp
, struct ui_file
*stream
,
781 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
783 static int indent
= 0;
786 fprintf_filtered (stream
, "\n");
787 fprintf_filtered (stream
, "\t%5d ", elt
);
789 for (i
= 1; i
<= indent
; i
++)
790 fprintf_filtered (stream
, " ");
793 fprintf_filtered (stream
, "%-20s ", op_name (exp
->elts
[elt
].opcode
));
795 switch (exp
->elts
[elt
++].opcode
)
799 case TERNOP_SLICE_COUNT
:
800 elt
= dump_subexp (exp
, stream
, elt
);
809 case BINOP_LOGICAL_AND
:
810 case BINOP_LOGICAL_OR
:
811 case BINOP_BITWISE_AND
:
812 case BINOP_BITWISE_IOR
:
813 case BINOP_BITWISE_XOR
:
823 case BINOP_SUBSCRIPT
:
828 case BINOP_ASSIGN_MODIFY
:
836 elt
= dump_subexp (exp
, stream
, elt
);
838 case UNOP_LOGICAL_NOT
:
839 case UNOP_COMPLEMENT
:
842 case UNOP_PREINCREMENT
:
843 case UNOP_POSTINCREMENT
:
844 case UNOP_PREDECREMENT
:
845 case UNOP_POSTDECREMENT
:
864 elt
= dump_subexp (exp
, stream
, elt
);
867 fprintf_filtered (stream
, "Type @");
868 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
869 fprintf_filtered (stream
, " (");
870 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
871 fprintf_filtered (stream
, "), value %ld (0x%lx)",
872 (long) exp
->elts
[elt
+ 1].longconst
,
873 (long) exp
->elts
[elt
+ 1].longconst
);
877 fprintf_filtered (stream
, "Type @");
878 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
879 fprintf_filtered (stream
, " (");
880 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
881 fprintf_filtered (stream
, "), value %g",
882 (double) exp
->elts
[elt
+ 1].doubleconst
);
886 fprintf_filtered (stream
, "Block @");
887 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
888 fprintf_filtered (stream
, ", symbol @");
889 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
890 fprintf_filtered (stream
, " (%s)",
891 SYMBOL_NAME (exp
->elts
[elt
+ 1].symbol
));
895 fprintf_filtered (stream
, "History element %ld",
896 (long) exp
->elts
[elt
].longconst
);
900 fprintf_filtered (stream
, "Register %ld",
901 (long) exp
->elts
[elt
].longconst
);
905 fprintf_filtered (stream
, "Internal var @");
906 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
907 fprintf_filtered (stream
, " (%s)",
908 exp
->elts
[elt
].internalvar
->name
);
915 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
917 fprintf_filtered (stream
, "Number of args: %d", nargs
);
920 for (i
= 1; i
<= nargs
+ 1; i
++)
921 elt
= dump_subexp (exp
, stream
, elt
);
929 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
930 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
932 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
935 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
936 elt
= dump_subexp (exp
, stream
, elt
);
941 fprintf_filtered (stream
, "Type @");
942 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
943 fprintf_filtered (stream
, " (");
944 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
945 fprintf_filtered (stream
, ")");
946 elt
= dump_subexp (exp
, stream
, elt
+ 2);
949 fprintf_filtered (stream
, "Type @");
950 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
951 fprintf_filtered (stream
, " (");
952 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
953 fprintf_filtered (stream
, ")");
956 case STRUCTOP_STRUCT
:
962 len
= longest_to_int (exp
->elts
[elt
].longconst
);
963 elem_name
= &exp
->elts
[elt
+ 1].string
;
965 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
966 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
974 fprintf_filtered (stream
, "Type @");
975 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
976 fprintf_filtered (stream
, " (");
977 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
978 fprintf_filtered (stream
, ") ");
980 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
981 elem_name
= &exp
->elts
[elt
+ 2].string
;
983 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
984 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
989 case STRUCTOP_MEMBER
:
991 case MULTI_SUBSCRIPT
:
992 case OP_F77_UNDETERMINED_ARGLIST
:
1002 fprintf_filtered (stream
, "Unknown format");
1011 dump_postfix_expression (struct expression
*exp
, struct ui_file
*stream
,
1016 fprintf_filtered (stream
, "Dump of expression @ ");
1017 gdb_print_host_address (exp
, stream
);
1018 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
1019 if (exp
->elts
[0].opcode
!= OP_TYPE
)
1020 print_expression (exp
, stream
);
1022 fputs_filtered ("Type printing not yet supported....", stream
);
1023 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1024 exp
->language_defn
->la_name
, exp
->nelts
,
1025 (long) sizeof (union exp_element
));
1026 fputs_filtered ("\n", stream
);
1028 for (elt
= 0; elt
< exp
->nelts
;)
1029 elt
= dump_subexp (exp
, stream
, elt
);
1030 fputs_filtered ("\n", stream
);