1 /* Print in infix form a struct expression.
3 Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
4 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
6 This file is part of GDB.
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
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 #include "expression.h"
29 #include "parser-defs.h"
30 #include "frame.h" /* For frame_map_regnum_to_name. */
32 #include "gdb_string.h"
39 /* Prototypes for local functions */
41 static void print_subexp (struct expression
*, int *, struct ui_file
*,
45 print_expression (struct expression
*exp
, struct ui_file
*stream
)
48 print_subexp (exp
, &pc
, stream
, PREC_NULL
);
51 /* Print the subexpression of EXP that starts in position POS, on STREAM.
52 PREC is the precedence of the surrounding operator;
53 if the precedence of the main operator of this subexpression is less,
54 parentheses are needed here. */
57 print_subexp (register struct expression
*exp
, register int *pos
,
58 struct ui_file
*stream
, enum precedence prec
)
60 register unsigned tem
;
61 register const struct op_print
*op_print_tab
;
64 register char *op_str
;
65 int assign_modify
= 0;
66 enum exp_opcode opcode
;
67 enum precedence myprec
= PREC_NULL
;
68 /* Set to 1 for a right-associative operator. */
73 op_print_tab
= exp
->language_defn
->la_op_print_tab
;
75 opcode
= exp
->elts
[pc
].opcode
;
83 fputs_filtered (type_name_no_tag (exp
->elts
[pc
+ 1].type
), stream
);
84 fputs_filtered ("::", stream
);
85 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
86 (*pos
) += 4 + BYTES_TO_EXP_ELEM (nargs
+ 1);
87 fputs_filtered (&exp
->elts
[pc
+ 3].string
, stream
);
92 value_print (value_from_longest (exp
->elts
[pc
+ 1].type
,
93 exp
->elts
[pc
+ 2].longconst
),
94 stream
, 0, Val_no_prettyprint
);
99 value_print (value_from_double (exp
->elts
[pc
+ 1].type
,
100 exp
->elts
[pc
+ 2].doubleconst
),
101 stream
, 0, Val_no_prettyprint
);
108 b
= exp
->elts
[pc
+ 1].block
;
110 && BLOCK_FUNCTION (b
) != NULL
111 && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)) != NULL
)
113 fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b
)), stream
);
114 fputs_filtered ("::", stream
);
116 fputs_filtered (SYMBOL_PRINT_NAME (exp
->elts
[pc
+ 2].symbol
), stream
);
122 fprintf_filtered (stream
, "$%d",
123 longest_to_int (exp
->elts
[pc
+ 1].longconst
));
128 int regnum
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
130 fprintf_filtered (stream
, "$%s", frame_map_regnum_to_name (regnum
));
136 fprintf_filtered (stream
, "%s",
137 longest_to_int (exp
->elts
[pc
+ 1].longconst
)
143 fprintf_filtered (stream
, "$%s",
144 internalvar_name (exp
->elts
[pc
+ 1].internalvar
));
149 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
150 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
151 fputs_filtered (" (", stream
);
152 for (tem
= 0; tem
< nargs
; tem
++)
155 fputs_filtered (", ", stream
);
156 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
158 fputs_filtered (")", stream
);
163 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
164 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
165 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
169 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
170 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
171 /* LA_PRINT_STRING will print using the current repeat count threshold.
172 If necessary, we can temporarily set it to zero, or pass it as an
173 additional parameter to LA_PRINT_STRING. -fnf */
174 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
178 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
180 += 3 + BYTES_TO_EXP_ELEM ((nargs
+ HOST_CHAR_BIT
- 1) / HOST_CHAR_BIT
);
181 fprintf_unfiltered (stream
, "B'<unimplemented>'");
184 case OP_OBJC_NSSTRING
: /* Objective-C Foundation Class NSString constant. */
185 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
186 (*pos
) += 3 + BYTES_TO_EXP_ELEM (nargs
+ 1);
187 fputs_filtered ("@\"", stream
);
188 LA_PRINT_STRING (stream
, &exp
->elts
[pc
+ 2].string
, nargs
, 1, 0);
189 fputs_filtered ("\"", stream
);
192 case OP_OBJC_MSGCALL
:
193 { /* Objective C message (method) call. */
196 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
197 fprintf_unfiltered (stream
, "[");
198 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
199 if (0 == target_read_string (exp
->elts
[pc
+ 1].longconst
,
200 &selector
, 1024, NULL
))
202 error ("bad selector");
208 s
= alloca (strlen (selector
) + 1);
209 strcpy (s
, selector
);
210 for (tem
= 0; tem
< nargs
; tem
++)
212 nextS
= strchr (s
, ':');
214 fprintf_unfiltered (stream
, " %s: ", s
);
216 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
221 fprintf_unfiltered (stream
, " %s", selector
);
223 fprintf_unfiltered (stream
, "]");
224 /* "selector" was malloc'd by target_read_string. Free it. */
231 nargs
= longest_to_int (exp
->elts
[pc
+ 2].longconst
);
232 nargs
-= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
235 if (exp
->elts
[pc
+ 4].opcode
== OP_LONG
236 && exp
->elts
[pc
+ 5].type
== builtin_type_char
237 && exp
->language_defn
->la_language
== language_c
)
239 /* Attempt to print C character arrays using string syntax.
240 Walk through the args, picking up one character from each
241 of the OP_LONG expression elements. If any array element
242 does not match our expection of what we should find for
243 a simple string, revert back to array printing. Note that
244 the last expression element is an explicit null terminator
245 byte, which doesn't get printed. */
246 tempstr
= alloca (nargs
);
250 if (exp
->elts
[pc
].opcode
!= OP_LONG
251 || exp
->elts
[pc
+ 1].type
!= builtin_type_char
)
253 /* Not a simple array of char, use regular array printing. */
260 longest_to_int (exp
->elts
[pc
+ 2].longconst
);
267 LA_PRINT_STRING (stream
, tempstr
, nargs
- 1, 1, 0);
272 fputs_filtered (" {", stream
);
273 for (tem
= 0; tem
< nargs
; tem
++)
277 fputs_filtered (", ", stream
);
279 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
281 fputs_filtered ("}", stream
);
286 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
287 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
288 /* Gcc support both these syntaxes. Unsure which is preferred. */
290 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
291 fputs_filtered (": ", stream
);
293 fputs_filtered (".", stream
);
294 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
295 fputs_filtered ("=", stream
);
297 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
301 if ((int) prec
> (int) PREC_COMMA
)
302 fputs_filtered ("(", stream
);
303 /* Print the subexpressions, forcing parentheses
304 around any binary operations within them.
305 This is more parentheses than are strictly necessary,
306 but it looks clearer. */
307 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
308 fputs_filtered (" ? ", stream
);
309 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
310 fputs_filtered (" : ", stream
);
311 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
312 if ((int) prec
> (int) PREC_COMMA
)
313 fputs_filtered (")", stream
);
317 case TERNOP_SLICE_COUNT
:
318 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
319 fputs_filtered ("(", stream
);
320 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
321 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
322 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
323 fputs_filtered (")", stream
);
326 case STRUCTOP_STRUCT
:
327 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
328 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
329 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
330 fputs_filtered (".", stream
);
331 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
334 /* Will not occur for Modula-2 */
336 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
337 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
338 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
339 fputs_filtered ("->", stream
);
340 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
343 case BINOP_SUBSCRIPT
:
344 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
345 fputs_filtered ("[", stream
);
346 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
347 fputs_filtered ("]", stream
);
350 case UNOP_POSTINCREMENT
:
351 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
352 fputs_filtered ("++", stream
);
355 case UNOP_POSTDECREMENT
:
356 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
357 fputs_filtered ("--", stream
);
362 if ((int) prec
> (int) PREC_PREFIX
)
363 fputs_filtered ("(", stream
);
364 fputs_filtered ("(", stream
);
365 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
366 fputs_filtered (") ", stream
);
367 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
368 if ((int) prec
> (int) PREC_PREFIX
)
369 fputs_filtered (")", stream
);
374 if ((int) prec
> (int) PREC_PREFIX
)
375 fputs_filtered ("(", stream
);
376 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
&&
377 exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
379 /* We have a minimal symbol fn, probably. It's encoded
380 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
381 Swallow the OP_LONG (including both its opcodes); ignore
382 its type; print the value in the type of the MEMVAL. */
384 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
385 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
,
387 value_print (val
, stream
, 0, Val_no_prettyprint
);
391 fputs_filtered ("{", stream
);
392 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
393 fputs_filtered ("} ", stream
);
394 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
396 if ((int) prec
> (int) PREC_PREFIX
)
397 fputs_filtered (")", stream
);
400 case BINOP_ASSIGN_MODIFY
:
401 opcode
= exp
->elts
[pc
+ 1].opcode
;
403 myprec
= PREC_ASSIGN
;
407 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
408 if (op_print_tab
[tem
].opcode
== opcode
)
410 op_str
= op_print_tab
[tem
].string
;
413 if (op_print_tab
[tem
].opcode
!= opcode
)
414 /* Not found; don't try to keep going because we don't know how
415 to interpret further elements. */
416 error ("Invalid expression");
423 fputs_filtered ("this", stream
);
426 /* Objective-C ops */
430 fputs_filtered ("self", stream
); /* The ObjC equivalent of "this". */
435 case MULTI_SUBSCRIPT
:
437 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
438 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
439 fprintf_unfiltered (stream
, " [");
440 for (tem
= 0; tem
< nargs
; tem
++)
443 fprintf_unfiltered (stream
, ", ");
444 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
446 fprintf_unfiltered (stream
, "]");
451 fprintf_unfiltered (stream
, "VAL(");
452 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
453 fprintf_unfiltered (stream
, ",");
454 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
455 fprintf_unfiltered (stream
, ")");
460 error ("print_subexp: Not implemented.");
466 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
467 if (op_print_tab
[tem
].opcode
== opcode
)
469 op_str
= op_print_tab
[tem
].string
;
470 myprec
= op_print_tab
[tem
].precedence
;
471 assoc
= op_print_tab
[tem
].right_assoc
;
474 if (op_print_tab
[tem
].opcode
!= opcode
)
475 /* Not found; don't try to keep going because we don't know how
476 to interpret further elements. For example, this happens
477 if opcode is OP_TYPE. */
478 error ("Invalid expression");
481 /* Note that PREC_BUILTIN will always emit parentheses. */
482 if ((int) myprec
< (int) prec
)
483 fputs_filtered ("(", stream
);
484 if ((int) opcode
> (int) BINOP_END
)
488 /* Unary postfix operator. */
489 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
490 fputs_filtered (op_str
, stream
);
494 /* Unary prefix operator. */
495 fputs_filtered (op_str
, stream
);
496 if (myprec
== PREC_BUILTIN_FUNCTION
)
497 fputs_filtered ("(", stream
);
498 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
499 if (myprec
== PREC_BUILTIN_FUNCTION
)
500 fputs_filtered (")", stream
);
505 /* Binary operator. */
506 /* Print left operand.
507 If operator is right-associative,
508 increment precedence for this operand. */
509 print_subexp (exp
, pos
, stream
,
510 (enum precedence
) ((int) myprec
+ assoc
));
511 /* Print the operator itself. */
513 fprintf_filtered (stream
, " %s= ", op_str
);
514 else if (op_str
[0] == ',')
515 fprintf_filtered (stream
, "%s ", op_str
);
517 fprintf_filtered (stream
, " %s ", op_str
);
518 /* Print right operand.
519 If operator is left-associative,
520 increment precedence for this operand. */
521 print_subexp (exp
, pos
, stream
,
522 (enum precedence
) ((int) myprec
+ !assoc
));
525 if ((int) myprec
< (int) prec
)
526 fputs_filtered (")", stream
);
529 /* Return the operator corresponding to opcode OP as
530 a string. NULL indicates that the opcode was not found in the
531 current language table. */
533 op_string (enum exp_opcode op
)
536 register const struct op_print
*op_print_tab
;
538 op_print_tab
= current_language
->la_op_print_tab
;
539 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
540 if (op_print_tab
[tem
].opcode
== op
)
541 return op_print_tab
[tem
].string
;
545 /* Support for dumping the raw data from expressions in a human readable
548 static char *op_name (int opcode
);
559 sprintf (buf
, "<unknown %d>", opcode
);
580 case BINOP_LOGICAL_AND
:
581 return "BINOP_LOGICAL_AND";
582 case BINOP_LOGICAL_OR
:
583 return "BINOP_LOGICAL_OR";
584 case BINOP_BITWISE_AND
:
585 return "BINOP_BITWISE_AND";
586 case BINOP_BITWISE_IOR
:
587 return "BINOP_BITWISE_IOR";
588 case BINOP_BITWISE_XOR
:
589 return "BINOP_BITWISE_XOR";
591 return "BINOP_EQUAL";
593 return "BINOP_NOTEQUAL";
603 return "BINOP_REPEAT";
605 return "BINOP_ASSIGN";
607 return "BINOP_COMMA";
608 case BINOP_SUBSCRIPT
:
609 return "BINOP_SUBSCRIPT";
610 case MULTI_SUBSCRIPT
:
611 return "MULTI_SUBSCRIPT";
618 case STRUCTOP_MEMBER
:
619 return "STRUCTOP_MEMBER";
621 return "STRUCTOP_MPTR";
623 return "BINOP_INTDIV";
624 case BINOP_ASSIGN_MODIFY
:
625 return "BINOP_ASSIGN_MODIFY";
633 return "BINOP_CONCAT";
635 return "BINOP_RANGE";
639 return "TERNOP_COND";
641 return "TERNOP_SLICE";
642 case TERNOP_SLICE_COUNT
:
643 return "TERNOP_SLICE_COUNT";
649 return "OP_VAR_VALUE";
653 return "OP_REGISTER";
655 return "OP_INTERNALVAR";
661 return "OP_BITSTRING";
667 return "UNOP_MEMVAL";
670 case UNOP_LOGICAL_NOT
:
671 return "UNOP_LOGICAL_NOT";
672 case UNOP_COMPLEMENT
:
673 return "UNOP_COMPLEMENT";
678 case UNOP_PREINCREMENT
:
679 return "UNOP_PREINCREMENT";
680 case UNOP_POSTINCREMENT
:
681 return "UNOP_POSTINCREMENT";
682 case UNOP_PREDECREMENT
:
683 return "UNOP_PREDECREMENT";
684 case UNOP_POSTDECREMENT
:
685 return "UNOP_POSTDECREMENT";
687 return "UNOP_SIZEOF";
693 return "UNOP_LENGTH";
719 return "OP_M2_STRING";
720 case STRUCTOP_STRUCT
:
721 return "STRUCTOP_STRUCT";
723 return "STRUCTOP_PTR";
727 return "OP_OBJC_SELF";
738 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
,
746 fprintf_filtered (stream
, "Dump of expression @ ");
747 gdb_print_host_address (exp
, stream
);
748 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
749 if (exp
->elts
[0].opcode
!= OP_TYPE
)
750 print_expression (exp
, stream
);
752 fprintf_filtered (stream
, "Type printing not yet supported....");
753 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
754 exp
->language_defn
->la_name
, exp
->nelts
,
755 (long) sizeof (union exp_element
));
756 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
757 "Hex Value", "String Value");
758 for (elt
= 0; elt
< exp
->nelts
; elt
++)
760 fprintf_filtered (stream
, "\t%5d ", elt
);
761 opcode_name
= op_name (exp
->elts
[elt
].opcode
);
763 fprintf_filtered (stream
, "%20s ", opcode_name
);
764 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
765 fprintf_filtered (stream
, " ");
767 for (eltscan
= (char *) &exp
->elts
[elt
],
768 eltsize
= sizeof (union exp_element
);
772 fprintf_filtered (stream
, "%c",
773 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
775 fprintf_filtered (stream
, "\n");
779 static int dump_subexp (struct expression
*exp
, struct ui_file
*stream
,
783 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
785 static int indent
= 0;
788 fprintf_filtered (stream
, "\n");
789 fprintf_filtered (stream
, "\t%5d ", elt
);
791 for (i
= 1; i
<= indent
; i
++)
792 fprintf_filtered (stream
, " ");
795 fprintf_filtered (stream
, "%-20s ", op_name (exp
->elts
[elt
].opcode
));
797 switch (exp
->elts
[elt
++].opcode
)
801 case TERNOP_SLICE_COUNT
:
802 elt
= dump_subexp (exp
, stream
, elt
);
811 case BINOP_LOGICAL_AND
:
812 case BINOP_LOGICAL_OR
:
813 case BINOP_BITWISE_AND
:
814 case BINOP_BITWISE_IOR
:
815 case BINOP_BITWISE_XOR
:
825 case BINOP_SUBSCRIPT
:
830 case BINOP_ASSIGN_MODIFY
:
838 elt
= dump_subexp (exp
, stream
, elt
);
840 case UNOP_LOGICAL_NOT
:
841 case UNOP_COMPLEMENT
:
844 case UNOP_PREINCREMENT
:
845 case UNOP_POSTINCREMENT
:
846 case UNOP_PREDECREMENT
:
847 case UNOP_POSTDECREMENT
:
866 elt
= dump_subexp (exp
, stream
, elt
);
869 fprintf_filtered (stream
, "Type @");
870 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
871 fprintf_filtered (stream
, " (");
872 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
873 fprintf_filtered (stream
, "), value %ld (0x%lx)",
874 (long) exp
->elts
[elt
+ 1].longconst
,
875 (long) exp
->elts
[elt
+ 1].longconst
);
879 fprintf_filtered (stream
, "Type @");
880 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
881 fprintf_filtered (stream
, " (");
882 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
883 fprintf_filtered (stream
, "), value %g",
884 (double) exp
->elts
[elt
+ 1].doubleconst
);
888 fprintf_filtered (stream
, "Block @");
889 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
890 fprintf_filtered (stream
, ", symbol @");
891 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
892 fprintf_filtered (stream
, " (%s)",
893 DEPRECATED_SYMBOL_NAME (exp
->elts
[elt
+ 1].symbol
));
897 fprintf_filtered (stream
, "History element %ld",
898 (long) exp
->elts
[elt
].longconst
);
902 fprintf_filtered (stream
, "Register %ld",
903 (long) exp
->elts
[elt
].longconst
);
907 fprintf_filtered (stream
, "Internal var @");
908 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
909 fprintf_filtered (stream
, " (%s)",
910 exp
->elts
[elt
].internalvar
->name
);
917 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
919 fprintf_filtered (stream
, "Number of args: %d", nargs
);
922 for (i
= 1; i
<= nargs
+ 1; i
++)
923 elt
= dump_subexp (exp
, stream
, elt
);
931 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
932 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
934 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
937 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
938 elt
= dump_subexp (exp
, stream
, elt
);
943 fprintf_filtered (stream
, "Type @");
944 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
945 fprintf_filtered (stream
, " (");
946 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
947 fprintf_filtered (stream
, ")");
948 elt
= dump_subexp (exp
, stream
, elt
+ 2);
951 fprintf_filtered (stream
, "Type @");
952 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
953 fprintf_filtered (stream
, " (");
954 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
955 fprintf_filtered (stream
, ")");
958 case STRUCTOP_STRUCT
:
964 len
= longest_to_int (exp
->elts
[elt
].longconst
);
965 elem_name
= &exp
->elts
[elt
+ 1].string
;
967 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
968 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
976 fprintf_filtered (stream
, "Type @");
977 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
978 fprintf_filtered (stream
, " (");
979 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
980 fprintf_filtered (stream
, ") ");
982 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
983 elem_name
= &exp
->elts
[elt
+ 2].string
;
985 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
986 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
991 case STRUCTOP_MEMBER
:
993 case MULTI_SUBSCRIPT
:
994 case OP_F77_UNDETERMINED_ARGLIST
:
1004 fprintf_filtered (stream
, "Unknown format");
1013 dump_postfix_expression (struct expression
*exp
, struct ui_file
*stream
,
1018 fprintf_filtered (stream
, "Dump of expression @ ");
1019 gdb_print_host_address (exp
, stream
);
1020 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
1021 if (exp
->elts
[0].opcode
!= OP_TYPE
)
1022 print_expression (exp
, stream
);
1024 fputs_filtered ("Type printing not yet supported....", stream
);
1025 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1026 exp
->language_defn
->la_name
, exp
->nelts
,
1027 (long) sizeof (union exp_element
));
1028 fputs_filtered ("\n", stream
);
1030 for (elt
= 0; elt
< exp
->nelts
;)
1031 elt
= dump_subexp (exp
, stream
, elt
);
1032 fputs_filtered ("\n", stream
);