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 /* OBSOLETE int is_chill = exp->language_defn->la_language == language_chill; */
271 /* OBSOLETE fputs_filtered (is_chill ? " [" : " {", stream); */
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 /* OBSOLETE fputs_filtered (is_chill ? "]" : "}", stream); */
282 fputs_filtered ("}", stream
);
287 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
288 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
291 if (0 /* OBSOLETE exp->language_defn->la_language == language_chill */)
293 fputs_filtered (".", stream
); /* OBSOLETE */
294 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
); /* OBSOLETE */
295 fputs_filtered (exp
->elts
[*pos
].opcode
== OP_LABELED
? ", " /* OBSOLETE */
296 : ": ", /* OBSOLETE */
297 stream
); /* OBSOLETE */
302 /* Gcc support both these syntaxes. Unsure which is preferred. */
304 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
305 fputs_filtered (": ", stream
);
307 fputs_filtered (".", stream
);
308 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
309 fputs_filtered ("=", stream
);
312 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
316 if ((int) prec
> (int) PREC_COMMA
)
317 fputs_filtered ("(", stream
);
318 /* Print the subexpressions, forcing parentheses
319 around any binary operations within them.
320 This is more parentheses than are strictly necessary,
321 but it looks clearer. */
322 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
323 fputs_filtered (" ? ", stream
);
324 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
325 fputs_filtered (" : ", stream
);
326 print_subexp (exp
, pos
, stream
, PREC_HYPER
);
327 if ((int) prec
> (int) PREC_COMMA
)
328 fputs_filtered (")", stream
);
332 case TERNOP_SLICE_COUNT
:
333 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
334 fputs_filtered ("(", stream
);
335 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
336 fputs_filtered (opcode
== TERNOP_SLICE
? " : " : " UP ", stream
);
337 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
338 fputs_filtered (")", stream
);
341 case STRUCTOP_STRUCT
:
342 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
343 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
344 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
345 fputs_filtered (".", stream
);
346 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
349 /* Will not occur for Modula-2 */
351 tem
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
352 (*pos
) += 3 + BYTES_TO_EXP_ELEM (tem
+ 1);
353 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
354 fputs_filtered ("->", stream
);
355 fputs_filtered (&exp
->elts
[pc
+ 2].string
, stream
);
358 case BINOP_SUBSCRIPT
:
359 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
360 fputs_filtered ("[", stream
);
361 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
362 fputs_filtered ("]", stream
);
365 case UNOP_POSTINCREMENT
:
366 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
367 fputs_filtered ("++", stream
);
370 case UNOP_POSTDECREMENT
:
371 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
372 fputs_filtered ("--", stream
);
377 if ((int) prec
> (int) PREC_PREFIX
)
378 fputs_filtered ("(", stream
);
379 fputs_filtered ("(", stream
);
380 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
381 fputs_filtered (") ", stream
);
382 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
383 if ((int) prec
> (int) PREC_PREFIX
)
384 fputs_filtered (")", stream
);
389 if ((int) prec
> (int) PREC_PREFIX
)
390 fputs_filtered ("(", stream
);
391 if (TYPE_CODE (exp
->elts
[pc
+ 1].type
) == TYPE_CODE_FUNC
&&
392 exp
->elts
[pc
+ 3].opcode
== OP_LONG
)
394 /* We have a minimal symbol fn, probably. It's encoded
395 as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
396 Swallow the OP_LONG (including both its opcodes); ignore
397 its type; print the value in the type of the MEMVAL. */
399 val
= value_at_lazy (exp
->elts
[pc
+ 1].type
,
400 (CORE_ADDR
) exp
->elts
[pc
+ 5].longconst
,
402 value_print (val
, stream
, 0, Val_no_prettyprint
);
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
);
411 if ((int) prec
> (int) PREC_PREFIX
)
412 fputs_filtered (")", stream
);
415 case BINOP_ASSIGN_MODIFY
:
416 opcode
= exp
->elts
[pc
+ 1].opcode
;
418 myprec
= PREC_ASSIGN
;
422 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
423 if (op_print_tab
[tem
].opcode
== opcode
)
425 op_str
= op_print_tab
[tem
].string
;
428 if (op_print_tab
[tem
].opcode
!= opcode
)
429 /* Not found; don't try to keep going because we don't know how
430 to interpret further elements. */
431 error ("Invalid expression");
438 fputs_filtered ("this", stream
);
441 /* Objective-C ops */
445 fputs_filtered ("self", stream
); /* The ObjC equivalent of "this". */
450 case MULTI_SUBSCRIPT
:
452 nargs
= longest_to_int (exp
->elts
[pc
+ 1].longconst
);
453 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
454 fprintf_unfiltered (stream
, " [");
455 for (tem
= 0; tem
< nargs
; tem
++)
458 fprintf_unfiltered (stream
, ", ");
459 print_subexp (exp
, pos
, stream
, PREC_ABOVE_COMMA
);
461 fprintf_unfiltered (stream
, "]");
466 fprintf_unfiltered (stream
, "VAL(");
467 type_print (exp
->elts
[pc
+ 1].type
, "", stream
, 0);
468 fprintf_unfiltered (stream
, ",");
469 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
470 fprintf_unfiltered (stream
, ")");
475 error ("print_subexp: Not implemented.");
481 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
482 if (op_print_tab
[tem
].opcode
== opcode
)
484 op_str
= op_print_tab
[tem
].string
;
485 myprec
= op_print_tab
[tem
].precedence
;
486 assoc
= op_print_tab
[tem
].right_assoc
;
489 if (op_print_tab
[tem
].opcode
!= opcode
)
490 /* Not found; don't try to keep going because we don't know how
491 to interpret further elements. For example, this happens
492 if opcode is OP_TYPE. */
493 error ("Invalid expression");
496 /* Note that PREC_BUILTIN will always emit parentheses. */
497 if ((int) myprec
< (int) prec
)
498 fputs_filtered ("(", stream
);
499 if ((int) opcode
> (int) BINOP_END
)
503 /* Unary postfix operator. */
504 print_subexp (exp
, pos
, stream
, PREC_SUFFIX
);
505 fputs_filtered (op_str
, stream
);
509 /* Unary prefix operator. */
510 fputs_filtered (op_str
, stream
);
511 if (myprec
== PREC_BUILTIN_FUNCTION
)
512 fputs_filtered ("(", stream
);
513 print_subexp (exp
, pos
, stream
, PREC_PREFIX
);
514 if (myprec
== PREC_BUILTIN_FUNCTION
)
515 fputs_filtered (")", stream
);
520 /* Binary operator. */
521 /* Print left operand.
522 If operator is right-associative,
523 increment precedence for this operand. */
524 print_subexp (exp
, pos
, stream
,
525 (enum precedence
) ((int) myprec
+ assoc
));
526 /* Print the operator itself. */
528 fprintf_filtered (stream
, " %s= ", op_str
);
529 else if (op_str
[0] == ',')
530 fprintf_filtered (stream
, "%s ", op_str
);
532 fprintf_filtered (stream
, " %s ", op_str
);
533 /* Print right operand.
534 If operator is left-associative,
535 increment precedence for this operand. */
536 print_subexp (exp
, pos
, stream
,
537 (enum precedence
) ((int) myprec
+ !assoc
));
540 if ((int) myprec
< (int) prec
)
541 fputs_filtered (")", stream
);
544 /* Return the operator corresponding to opcode OP as
545 a string. NULL indicates that the opcode was not found in the
546 current language table. */
548 op_string (enum exp_opcode op
)
551 register const struct op_print
*op_print_tab
;
553 op_print_tab
= current_language
->la_op_print_tab
;
554 for (tem
= 0; op_print_tab
[tem
].opcode
!= OP_NULL
; tem
++)
555 if (op_print_tab
[tem
].opcode
== op
)
556 return op_print_tab
[tem
].string
;
560 /* Support for dumping the raw data from expressions in a human readable
563 static char *op_name (int opcode
);
574 sprintf (buf
, "<unknown %d>", opcode
);
595 case BINOP_LOGICAL_AND
:
596 return "BINOP_LOGICAL_AND";
597 case BINOP_LOGICAL_OR
:
598 return "BINOP_LOGICAL_OR";
599 case BINOP_BITWISE_AND
:
600 return "BINOP_BITWISE_AND";
601 case BINOP_BITWISE_IOR
:
602 return "BINOP_BITWISE_IOR";
603 case BINOP_BITWISE_XOR
:
604 return "BINOP_BITWISE_XOR";
606 return "BINOP_EQUAL";
608 return "BINOP_NOTEQUAL";
618 return "BINOP_REPEAT";
620 return "BINOP_ASSIGN";
622 return "BINOP_COMMA";
623 case BINOP_SUBSCRIPT
:
624 return "BINOP_SUBSCRIPT";
625 case MULTI_SUBSCRIPT
:
626 return "MULTI_SUBSCRIPT";
633 case STRUCTOP_MEMBER
:
634 return "STRUCTOP_MEMBER";
636 return "STRUCTOP_MPTR";
638 return "BINOP_INTDIV";
639 case BINOP_ASSIGN_MODIFY
:
640 return "BINOP_ASSIGN_MODIFY";
648 return "BINOP_CONCAT";
650 return "BINOP_RANGE";
654 return "TERNOP_COND";
656 return "TERNOP_SLICE";
657 case TERNOP_SLICE_COUNT
:
658 return "TERNOP_SLICE_COUNT";
664 return "OP_VAR_VALUE";
668 return "OP_REGISTER";
670 return "OP_INTERNALVAR";
676 return "OP_BITSTRING";
682 return "UNOP_MEMVAL";
685 case UNOP_LOGICAL_NOT
:
686 return "UNOP_LOGICAL_NOT";
687 case UNOP_COMPLEMENT
:
688 return "UNOP_COMPLEMENT";
693 case UNOP_PREINCREMENT
:
694 return "UNOP_PREINCREMENT";
695 case UNOP_POSTINCREMENT
:
696 return "UNOP_POSTINCREMENT";
697 case UNOP_PREDECREMENT
:
698 return "UNOP_PREDECREMENT";
699 case UNOP_POSTDECREMENT
:
700 return "UNOP_POSTDECREMENT";
702 return "UNOP_SIZEOF";
708 return "UNOP_LENGTH";
734 return "OP_M2_STRING";
735 case STRUCTOP_STRUCT
:
736 return "STRUCTOP_STRUCT";
738 return "STRUCTOP_PTR";
742 return "OP_OBJC_SELF";
753 dump_prefix_expression (struct expression
*exp
, struct ui_file
*stream
,
761 fprintf_filtered (stream
, "Dump of expression @ ");
762 gdb_print_host_address (exp
, stream
);
763 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
764 if (exp
->elts
[0].opcode
!= OP_TYPE
)
765 print_expression (exp
, stream
);
767 fprintf_filtered (stream
, "Type printing not yet supported....");
768 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
769 exp
->language_defn
->la_name
, exp
->nelts
,
770 (long) sizeof (union exp_element
));
771 fprintf_filtered (stream
, "\t%5s %20s %16s %s\n", "Index", "Opcode",
772 "Hex Value", "String Value");
773 for (elt
= 0; elt
< exp
->nelts
; elt
++)
775 fprintf_filtered (stream
, "\t%5d ", elt
);
776 opcode_name
= op_name (exp
->elts
[elt
].opcode
);
778 fprintf_filtered (stream
, "%20s ", opcode_name
);
779 print_longest (stream
, 'd', 0, exp
->elts
[elt
].longconst
);
780 fprintf_filtered (stream
, " ");
782 for (eltscan
= (char *) &exp
->elts
[elt
],
783 eltsize
= sizeof (union exp_element
);
787 fprintf_filtered (stream
, "%c",
788 isprint (*eltscan
) ? (*eltscan
& 0xFF) : '.');
790 fprintf_filtered (stream
, "\n");
794 static int dump_subexp (struct expression
*exp
, struct ui_file
*stream
,
798 dump_subexp (struct expression
*exp
, struct ui_file
*stream
, int elt
)
800 static int indent
= 0;
803 fprintf_filtered (stream
, "\n");
804 fprintf_filtered (stream
, "\t%5d ", elt
);
806 for (i
= 1; i
<= indent
; i
++)
807 fprintf_filtered (stream
, " ");
810 fprintf_filtered (stream
, "%-20s ", op_name (exp
->elts
[elt
].opcode
));
812 switch (exp
->elts
[elt
++].opcode
)
816 case TERNOP_SLICE_COUNT
:
817 elt
= dump_subexp (exp
, stream
, elt
);
826 case BINOP_LOGICAL_AND
:
827 case BINOP_LOGICAL_OR
:
828 case BINOP_BITWISE_AND
:
829 case BINOP_BITWISE_IOR
:
830 case BINOP_BITWISE_XOR
:
840 case BINOP_SUBSCRIPT
:
845 case BINOP_ASSIGN_MODIFY
:
853 elt
= dump_subexp (exp
, stream
, elt
);
855 case UNOP_LOGICAL_NOT
:
856 case UNOP_COMPLEMENT
:
859 case UNOP_PREINCREMENT
:
860 case UNOP_POSTINCREMENT
:
861 case UNOP_PREDECREMENT
:
862 case UNOP_POSTDECREMENT
:
881 elt
= dump_subexp (exp
, stream
, elt
);
884 fprintf_filtered (stream
, "Type @");
885 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
886 fprintf_filtered (stream
, " (");
887 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
888 fprintf_filtered (stream
, "), value %ld (0x%lx)",
889 (long) exp
->elts
[elt
+ 1].longconst
,
890 (long) exp
->elts
[elt
+ 1].longconst
);
894 fprintf_filtered (stream
, "Type @");
895 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
896 fprintf_filtered (stream
, " (");
897 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
898 fprintf_filtered (stream
, "), value %g",
899 (double) exp
->elts
[elt
+ 1].doubleconst
);
903 fprintf_filtered (stream
, "Block @");
904 gdb_print_host_address (exp
->elts
[elt
].block
, stream
);
905 fprintf_filtered (stream
, ", symbol @");
906 gdb_print_host_address (exp
->elts
[elt
+ 1].symbol
, stream
);
907 fprintf_filtered (stream
, " (%s)",
908 SYMBOL_NAME (exp
->elts
[elt
+ 1].symbol
));
912 fprintf_filtered (stream
, "History element %ld",
913 (long) exp
->elts
[elt
].longconst
);
917 fprintf_filtered (stream
, "Register %ld",
918 (long) exp
->elts
[elt
].longconst
);
922 fprintf_filtered (stream
, "Internal var @");
923 gdb_print_host_address (exp
->elts
[elt
].internalvar
, stream
);
924 fprintf_filtered (stream
, " (%s)",
925 exp
->elts
[elt
].internalvar
->name
);
932 nargs
= longest_to_int (exp
->elts
[elt
].longconst
);
934 fprintf_filtered (stream
, "Number of args: %d", nargs
);
937 for (i
= 1; i
<= nargs
+ 1; i
++)
938 elt
= dump_subexp (exp
, stream
, elt
);
946 lower
= longest_to_int (exp
->elts
[elt
].longconst
);
947 upper
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
949 fprintf_filtered (stream
, "Bounds [%d:%d]", lower
, upper
);
952 for (i
= 1; i
<= upper
- lower
+ 1; i
++)
953 elt
= dump_subexp (exp
, stream
, elt
);
958 fprintf_filtered (stream
, "Type @");
959 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
960 fprintf_filtered (stream
, " (");
961 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
962 fprintf_filtered (stream
, ")");
963 elt
= dump_subexp (exp
, stream
, elt
+ 2);
966 fprintf_filtered (stream
, "Type @");
967 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
968 fprintf_filtered (stream
, " (");
969 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
970 fprintf_filtered (stream
, ")");
973 case STRUCTOP_STRUCT
:
979 len
= longest_to_int (exp
->elts
[elt
].longconst
);
980 elem_name
= &exp
->elts
[elt
+ 1].string
;
982 fprintf_filtered (stream
, "Element name: `%.*s'", len
, elem_name
);
983 elt
= dump_subexp (exp
, stream
, elt
+ 3 + BYTES_TO_EXP_ELEM (len
+ 1));
991 fprintf_filtered (stream
, "Type @");
992 gdb_print_host_address (exp
->elts
[elt
].type
, stream
);
993 fprintf_filtered (stream
, " (");
994 type_print (exp
->elts
[elt
].type
, NULL
, stream
, 0);
995 fprintf_filtered (stream
, ") ");
997 len
= longest_to_int (exp
->elts
[elt
+ 1].longconst
);
998 elem_name
= &exp
->elts
[elt
+ 2].string
;
1000 fprintf_filtered (stream
, "Field name: `%.*s'", len
, elem_name
);
1001 elt
+= 4 + BYTES_TO_EXP_ELEM (len
+ 1);
1006 case STRUCTOP_MEMBER
:
1008 case MULTI_SUBSCRIPT
:
1009 case OP_F77_UNDETERMINED_ARGLIST
:
1019 fprintf_filtered (stream
, "Unknown format");
1028 dump_postfix_expression (struct expression
*exp
, struct ui_file
*stream
,
1033 fprintf_filtered (stream
, "Dump of expression @ ");
1034 gdb_print_host_address (exp
, stream
);
1035 fprintf_filtered (stream
, ", %s:\nExpression: `", note
);
1036 if (exp
->elts
[0].opcode
!= OP_TYPE
)
1037 print_expression (exp
, stream
);
1039 fputs_filtered ("Type printing not yet supported....", stream
);
1040 fprintf_filtered (stream
, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
1041 exp
->language_defn
->la_name
, exp
->nelts
,
1042 (long) sizeof (union exp_element
));
1043 fputs_filtered ("\n", stream
);
1045 for (elt
= 0; elt
< exp
->nelts
;)
1046 elt
= dump_subexp (exp
, stream
, elt
);
1047 fputs_filtered ("\n", stream
);