xref: /dflybsd-src/contrib/gdb-7/gdb/expprint.c (revision cf7f2e2d389e8012d562650bd94d7e433f449d6e)
15796c8dcSSimon Schubert /* Print in infix form a struct expression.
25796c8dcSSimon Schubert 
35796c8dcSSimon Schubert    Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
4*cf7f2e2dSJohn Marino    1998, 1999, 2000, 2003, 2007, 2008, 2009, 2010
5*cf7f2e2dSJohn Marino    Free Software Foundation, Inc.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This file is part of GDB.
85796c8dcSSimon Schubert 
95796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
105796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
115796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
125796c8dcSSimon Schubert    (at your option) any later version.
135796c8dcSSimon Schubert 
145796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
155796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
165796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
175796c8dcSSimon Schubert    GNU General Public License for more details.
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
205796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
215796c8dcSSimon Schubert 
225796c8dcSSimon Schubert #include "defs.h"
235796c8dcSSimon Schubert #include "symtab.h"
245796c8dcSSimon Schubert #include "gdbtypes.h"
255796c8dcSSimon Schubert #include "expression.h"
265796c8dcSSimon Schubert #include "value.h"
275796c8dcSSimon Schubert #include "language.h"
285796c8dcSSimon Schubert #include "parser-defs.h"
295796c8dcSSimon Schubert #include "user-regs.h"		/* For user_reg_map_regnum_to_name.  */
305796c8dcSSimon Schubert #include "target.h"
315796c8dcSSimon Schubert #include "gdb_string.h"
325796c8dcSSimon Schubert #include "block.h"
335796c8dcSSimon Schubert #include "objfiles.h"
345796c8dcSSimon Schubert #include "gdb_assert.h"
355796c8dcSSimon Schubert #include "valprint.h"
365796c8dcSSimon Schubert 
375796c8dcSSimon Schubert #ifdef HAVE_CTYPE_H
385796c8dcSSimon Schubert #include <ctype.h>
395796c8dcSSimon Schubert #endif
405796c8dcSSimon Schubert 
415796c8dcSSimon Schubert void
425796c8dcSSimon Schubert print_expression (struct expression *exp, struct ui_file *stream)
435796c8dcSSimon Schubert {
445796c8dcSSimon Schubert   int pc = 0;
45*cf7f2e2dSJohn Marino 
465796c8dcSSimon Schubert   print_subexp (exp, &pc, stream, PREC_NULL);
475796c8dcSSimon Schubert }
485796c8dcSSimon Schubert 
495796c8dcSSimon Schubert /* Print the subexpression of EXP that starts in position POS, on STREAM.
505796c8dcSSimon Schubert    PREC is the precedence of the surrounding operator;
515796c8dcSSimon Schubert    if the precedence of the main operator of this subexpression is less,
525796c8dcSSimon Schubert    parentheses are needed here.  */
535796c8dcSSimon Schubert 
545796c8dcSSimon Schubert void
555796c8dcSSimon Schubert print_subexp (struct expression *exp, int *pos,
565796c8dcSSimon Schubert 	      struct ui_file *stream, enum precedence prec)
575796c8dcSSimon Schubert {
585796c8dcSSimon Schubert   exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec);
595796c8dcSSimon Schubert }
605796c8dcSSimon Schubert 
615796c8dcSSimon Schubert /* Standard implementation of print_subexp for use in language_defn
625796c8dcSSimon Schubert    vectors.  */
635796c8dcSSimon Schubert void
645796c8dcSSimon Schubert print_subexp_standard (struct expression *exp, int *pos,
655796c8dcSSimon Schubert 		       struct ui_file *stream, enum precedence prec)
665796c8dcSSimon Schubert {
675796c8dcSSimon Schubert   unsigned tem;
685796c8dcSSimon Schubert   const struct op_print *op_print_tab;
695796c8dcSSimon Schubert   int pc;
705796c8dcSSimon Schubert   unsigned nargs;
715796c8dcSSimon Schubert   char *op_str;
725796c8dcSSimon Schubert   int assign_modify = 0;
735796c8dcSSimon Schubert   enum exp_opcode opcode;
745796c8dcSSimon Schubert   enum precedence myprec = PREC_NULL;
755796c8dcSSimon Schubert   /* Set to 1 for a right-associative operator.  */
765796c8dcSSimon Schubert   int assoc = 0;
775796c8dcSSimon Schubert   struct value *val;
785796c8dcSSimon Schubert   char *tempstr = NULL;
795796c8dcSSimon Schubert 
805796c8dcSSimon Schubert   op_print_tab = exp->language_defn->la_op_print_tab;
815796c8dcSSimon Schubert   pc = (*pos)++;
825796c8dcSSimon Schubert   opcode = exp->elts[pc].opcode;
835796c8dcSSimon Schubert   switch (opcode)
845796c8dcSSimon Schubert     {
855796c8dcSSimon Schubert       /* Common ops */
865796c8dcSSimon Schubert 
875796c8dcSSimon Schubert     case OP_SCOPE:
885796c8dcSSimon Schubert       myprec = PREC_PREFIX;
895796c8dcSSimon Schubert       assoc = 0;
905796c8dcSSimon Schubert       fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream);
915796c8dcSSimon Schubert       fputs_filtered ("::", stream);
925796c8dcSSimon Schubert       nargs = longest_to_int (exp->elts[pc + 2].longconst);
935796c8dcSSimon Schubert       (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1);
945796c8dcSSimon Schubert       fputs_filtered (&exp->elts[pc + 3].string, stream);
955796c8dcSSimon Schubert       return;
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert     case OP_LONG:
985796c8dcSSimon Schubert       {
995796c8dcSSimon Schubert 	struct value_print_options opts;
100*cf7f2e2dSJohn Marino 
1015796c8dcSSimon Schubert 	get_raw_print_options (&opts);
1025796c8dcSSimon Schubert 	(*pos) += 3;
1035796c8dcSSimon Schubert 	value_print (value_from_longest (exp->elts[pc + 1].type,
1045796c8dcSSimon Schubert 					 exp->elts[pc + 2].longconst),
1055796c8dcSSimon Schubert 		     stream, &opts);
1065796c8dcSSimon Schubert       }
1075796c8dcSSimon Schubert       return;
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert     case OP_DOUBLE:
1105796c8dcSSimon Schubert       {
1115796c8dcSSimon Schubert 	struct value_print_options opts;
112*cf7f2e2dSJohn Marino 
1135796c8dcSSimon Schubert 	get_raw_print_options (&opts);
1145796c8dcSSimon Schubert 	(*pos) += 3;
1155796c8dcSSimon Schubert 	value_print (value_from_double (exp->elts[pc + 1].type,
1165796c8dcSSimon Schubert 					exp->elts[pc + 2].doubleconst),
1175796c8dcSSimon Schubert 		     stream, &opts);
1185796c8dcSSimon Schubert       }
1195796c8dcSSimon Schubert       return;
1205796c8dcSSimon Schubert 
1215796c8dcSSimon Schubert     case OP_VAR_VALUE:
1225796c8dcSSimon Schubert       {
1235796c8dcSSimon Schubert 	struct block *b;
124*cf7f2e2dSJohn Marino 
1255796c8dcSSimon Schubert 	(*pos) += 3;
1265796c8dcSSimon Schubert 	b = exp->elts[pc + 1].block;
1275796c8dcSSimon Schubert 	if (b != NULL
1285796c8dcSSimon Schubert 	    && BLOCK_FUNCTION (b) != NULL
1295796c8dcSSimon Schubert 	    && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL)
1305796c8dcSSimon Schubert 	  {
1315796c8dcSSimon Schubert 	    fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream);
1325796c8dcSSimon Schubert 	    fputs_filtered ("::", stream);
1335796c8dcSSimon Schubert 	  }
1345796c8dcSSimon Schubert 	fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream);
1355796c8dcSSimon Schubert       }
1365796c8dcSSimon Schubert       return;
1375796c8dcSSimon Schubert 
1385796c8dcSSimon Schubert     case OP_LAST:
1395796c8dcSSimon Schubert       (*pos) += 2;
1405796c8dcSSimon Schubert       fprintf_filtered (stream, "$%d",
1415796c8dcSSimon Schubert 			longest_to_int (exp->elts[pc + 1].longconst));
1425796c8dcSSimon Schubert       return;
1435796c8dcSSimon Schubert 
1445796c8dcSSimon Schubert     case OP_REGISTER:
1455796c8dcSSimon Schubert       {
1465796c8dcSSimon Schubert 	const char *name = &exp->elts[pc + 2].string;
147*cf7f2e2dSJohn Marino 
1485796c8dcSSimon Schubert 	(*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
1495796c8dcSSimon Schubert 	fprintf_filtered (stream, "$%s", name);
1505796c8dcSSimon Schubert 	return;
1515796c8dcSSimon Schubert       }
1525796c8dcSSimon Schubert 
1535796c8dcSSimon Schubert     case OP_BOOL:
1545796c8dcSSimon Schubert       (*pos) += 2;
1555796c8dcSSimon Schubert       fprintf_filtered (stream, "%s",
1565796c8dcSSimon Schubert 			longest_to_int (exp->elts[pc + 1].longconst)
1575796c8dcSSimon Schubert 			? "TRUE" : "FALSE");
1585796c8dcSSimon Schubert       return;
1595796c8dcSSimon Schubert 
1605796c8dcSSimon Schubert     case OP_INTERNALVAR:
1615796c8dcSSimon Schubert       (*pos) += 2;
1625796c8dcSSimon Schubert       fprintf_filtered (stream, "$%s",
1635796c8dcSSimon Schubert 			internalvar_name (exp->elts[pc + 1].internalvar));
1645796c8dcSSimon Schubert       return;
1655796c8dcSSimon Schubert 
1665796c8dcSSimon Schubert     case OP_FUNCALL:
1675796c8dcSSimon Schubert       (*pos) += 2;
1685796c8dcSSimon Schubert       nargs = longest_to_int (exp->elts[pc + 1].longconst);
1695796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
1705796c8dcSSimon Schubert       fputs_filtered (" (", stream);
1715796c8dcSSimon Schubert       for (tem = 0; tem < nargs; tem++)
1725796c8dcSSimon Schubert 	{
1735796c8dcSSimon Schubert 	  if (tem != 0)
1745796c8dcSSimon Schubert 	    fputs_filtered (", ", stream);
1755796c8dcSSimon Schubert 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
1765796c8dcSSimon Schubert 	}
1775796c8dcSSimon Schubert       fputs_filtered (")", stream);
1785796c8dcSSimon Schubert       return;
1795796c8dcSSimon Schubert 
1805796c8dcSSimon Schubert     case OP_NAME:
1815796c8dcSSimon Schubert       nargs = longest_to_int (exp->elts[pc + 1].longconst);
1825796c8dcSSimon Schubert       (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
1835796c8dcSSimon Schubert       fputs_filtered (&exp->elts[pc + 2].string, stream);
1845796c8dcSSimon Schubert       return;
1855796c8dcSSimon Schubert 
1865796c8dcSSimon Schubert     case OP_STRING:
1875796c8dcSSimon Schubert       {
1885796c8dcSSimon Schubert 	struct value_print_options opts;
189*cf7f2e2dSJohn Marino 
1905796c8dcSSimon Schubert 	nargs = longest_to_int (exp->elts[pc + 1].longconst);
1915796c8dcSSimon Schubert 	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
1925796c8dcSSimon Schubert 	/* LA_PRINT_STRING will print using the current repeat count threshold.
1935796c8dcSSimon Schubert 	   If necessary, we can temporarily set it to zero, or pass it as an
1945796c8dcSSimon Schubert 	   additional parameter to LA_PRINT_STRING.  -fnf */
1955796c8dcSSimon Schubert 	get_user_print_options (&opts);
1965796c8dcSSimon Schubert 	LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
197*cf7f2e2dSJohn Marino 			 &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
1985796c8dcSSimon Schubert       }
1995796c8dcSSimon Schubert       return;
2005796c8dcSSimon Schubert 
2015796c8dcSSimon Schubert     case OP_BITSTRING:
2025796c8dcSSimon Schubert       nargs = longest_to_int (exp->elts[pc + 1].longconst);
2035796c8dcSSimon Schubert       (*pos)
2045796c8dcSSimon Schubert 	+= 3 + BYTES_TO_EXP_ELEM ((nargs + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT);
2055796c8dcSSimon Schubert       fprintf_unfiltered (stream, "B'<unimplemented>'");
2065796c8dcSSimon Schubert       return;
2075796c8dcSSimon Schubert 
2085796c8dcSSimon Schubert     case OP_OBJC_NSSTRING:	/* Objective-C Foundation Class NSString constant.  */
2095796c8dcSSimon Schubert       {
2105796c8dcSSimon Schubert 	struct value_print_options opts;
211*cf7f2e2dSJohn Marino 
2125796c8dcSSimon Schubert 	nargs = longest_to_int (exp->elts[pc + 1].longconst);
2135796c8dcSSimon Schubert 	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
2145796c8dcSSimon Schubert 	fputs_filtered ("@\"", stream);
2155796c8dcSSimon Schubert 	get_user_print_options (&opts);
2165796c8dcSSimon Schubert 	LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
217*cf7f2e2dSJohn Marino 			 &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
2185796c8dcSSimon Schubert 	fputs_filtered ("\"", stream);
2195796c8dcSSimon Schubert       }
2205796c8dcSSimon Schubert       return;
2215796c8dcSSimon Schubert 
2225796c8dcSSimon Schubert     case OP_OBJC_MSGCALL:
2235796c8dcSSimon Schubert       {			/* Objective C message (method) call.  */
2245796c8dcSSimon Schubert 	char *selector;
225*cf7f2e2dSJohn Marino 
2265796c8dcSSimon Schubert 	(*pos) += 3;
2275796c8dcSSimon Schubert 	nargs = longest_to_int (exp->elts[pc + 2].longconst);
2285796c8dcSSimon Schubert 	fprintf_unfiltered (stream, "[");
2295796c8dcSSimon Schubert 	print_subexp (exp, pos, stream, PREC_SUFFIX);
2305796c8dcSSimon Schubert 	if (0 == target_read_string (exp->elts[pc + 1].longconst,
2315796c8dcSSimon Schubert 				     &selector, 1024, NULL))
2325796c8dcSSimon Schubert 	  {
2335796c8dcSSimon Schubert 	    error (_("bad selector"));
2345796c8dcSSimon Schubert 	    return;
2355796c8dcSSimon Schubert 	  }
2365796c8dcSSimon Schubert 	if (nargs)
2375796c8dcSSimon Schubert 	  {
2385796c8dcSSimon Schubert 	    char *s, *nextS;
239*cf7f2e2dSJohn Marino 
2405796c8dcSSimon Schubert 	    s = alloca (strlen (selector) + 1);
2415796c8dcSSimon Schubert 	    strcpy (s, selector);
2425796c8dcSSimon Schubert 	    for (tem = 0; tem < nargs; tem++)
2435796c8dcSSimon Schubert 	      {
2445796c8dcSSimon Schubert 		nextS = strchr (s, ':');
2455796c8dcSSimon Schubert 		gdb_assert (nextS);	/* Make sure we found ':'.  */
2465796c8dcSSimon Schubert 		*nextS = '\0';
2475796c8dcSSimon Schubert 		fprintf_unfiltered (stream, " %s: ", s);
2485796c8dcSSimon Schubert 		s = nextS + 1;
2495796c8dcSSimon Schubert 		print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
2505796c8dcSSimon Schubert 	      }
2515796c8dcSSimon Schubert 	  }
2525796c8dcSSimon Schubert 	else
2535796c8dcSSimon Schubert 	  {
2545796c8dcSSimon Schubert 	    fprintf_unfiltered (stream, " %s", selector);
2555796c8dcSSimon Schubert 	  }
2565796c8dcSSimon Schubert 	fprintf_unfiltered (stream, "]");
2575796c8dcSSimon Schubert 	/* "selector" was malloc'd by target_read_string. Free it.  */
2585796c8dcSSimon Schubert 	xfree (selector);
2595796c8dcSSimon Schubert 	return;
2605796c8dcSSimon Schubert       }
2615796c8dcSSimon Schubert 
2625796c8dcSSimon Schubert     case OP_ARRAY:
2635796c8dcSSimon Schubert       (*pos) += 3;
2645796c8dcSSimon Schubert       nargs = longest_to_int (exp->elts[pc + 2].longconst);
2655796c8dcSSimon Schubert       nargs -= longest_to_int (exp->elts[pc + 1].longconst);
2665796c8dcSSimon Schubert       nargs++;
2675796c8dcSSimon Schubert       tem = 0;
2685796c8dcSSimon Schubert       if (exp->elts[pc + 4].opcode == OP_LONG
2695796c8dcSSimon Schubert 	  && exp->elts[pc + 5].type
2705796c8dcSSimon Schubert 	     == builtin_type (exp->gdbarch)->builtin_char
2715796c8dcSSimon Schubert 	  && exp->language_defn->la_language == language_c)
2725796c8dcSSimon Schubert 	{
2735796c8dcSSimon Schubert 	  /* Attempt to print C character arrays using string syntax.
2745796c8dcSSimon Schubert 	     Walk through the args, picking up one character from each
2755796c8dcSSimon Schubert 	     of the OP_LONG expression elements.  If any array element
2765796c8dcSSimon Schubert 	     does not match our expection of what we should find for
2775796c8dcSSimon Schubert 	     a simple string, revert back to array printing.  Note that
2785796c8dcSSimon Schubert 	     the last expression element is an explicit null terminator
2795796c8dcSSimon Schubert 	     byte, which doesn't get printed. */
2805796c8dcSSimon Schubert 	  tempstr = alloca (nargs);
2815796c8dcSSimon Schubert 	  pc += 4;
2825796c8dcSSimon Schubert 	  while (tem < nargs)
2835796c8dcSSimon Schubert 	    {
2845796c8dcSSimon Schubert 	      if (exp->elts[pc].opcode != OP_LONG
2855796c8dcSSimon Schubert 		  || exp->elts[pc + 1].type
2865796c8dcSSimon Schubert 		     != builtin_type (exp->gdbarch)->builtin_char)
2875796c8dcSSimon Schubert 		{
2885796c8dcSSimon Schubert 		  /* Not a simple array of char, use regular array printing. */
2895796c8dcSSimon Schubert 		  tem = 0;
2905796c8dcSSimon Schubert 		  break;
2915796c8dcSSimon Schubert 		}
2925796c8dcSSimon Schubert 	      else
2935796c8dcSSimon Schubert 		{
2945796c8dcSSimon Schubert 		  tempstr[tem++] =
2955796c8dcSSimon Schubert 		    longest_to_int (exp->elts[pc + 2].longconst);
2965796c8dcSSimon Schubert 		  pc += 4;
2975796c8dcSSimon Schubert 		}
2985796c8dcSSimon Schubert 	    }
2995796c8dcSSimon Schubert 	}
3005796c8dcSSimon Schubert       if (tem > 0)
3015796c8dcSSimon Schubert 	{
3025796c8dcSSimon Schubert 	  struct value_print_options opts;
303*cf7f2e2dSJohn Marino 
3045796c8dcSSimon Schubert 	  get_user_print_options (&opts);
3055796c8dcSSimon Schubert 	  LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
306*cf7f2e2dSJohn Marino 			   tempstr, nargs - 1, NULL, 0, &opts);
3075796c8dcSSimon Schubert 	  (*pos) = pc;
3085796c8dcSSimon Schubert 	}
3095796c8dcSSimon Schubert       else
3105796c8dcSSimon Schubert 	{
3115796c8dcSSimon Schubert 	  fputs_filtered (" {", stream);
3125796c8dcSSimon Schubert 	  for (tem = 0; tem < nargs; tem++)
3135796c8dcSSimon Schubert 	    {
3145796c8dcSSimon Schubert 	      if (tem != 0)
3155796c8dcSSimon Schubert 		{
3165796c8dcSSimon Schubert 		  fputs_filtered (", ", stream);
3175796c8dcSSimon Schubert 		}
3185796c8dcSSimon Schubert 	      print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
3195796c8dcSSimon Schubert 	    }
3205796c8dcSSimon Schubert 	  fputs_filtered ("}", stream);
3215796c8dcSSimon Schubert 	}
3225796c8dcSSimon Schubert       return;
3235796c8dcSSimon Schubert 
3245796c8dcSSimon Schubert     case OP_LABELED:
3255796c8dcSSimon Schubert       tem = longest_to_int (exp->elts[pc + 1].longconst);
3265796c8dcSSimon Schubert       (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
3275796c8dcSSimon Schubert       /* Gcc support both these syntaxes.  Unsure which is preferred.  */
3285796c8dcSSimon Schubert #if 1
3295796c8dcSSimon Schubert       fputs_filtered (&exp->elts[pc + 2].string, stream);
3305796c8dcSSimon Schubert       fputs_filtered (": ", stream);
3315796c8dcSSimon Schubert #else
3325796c8dcSSimon Schubert       fputs_filtered (".", stream);
3335796c8dcSSimon Schubert       fputs_filtered (&exp->elts[pc + 2].string, stream);
3345796c8dcSSimon Schubert       fputs_filtered ("=", stream);
3355796c8dcSSimon Schubert #endif
3365796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3375796c8dcSSimon Schubert       return;
3385796c8dcSSimon Schubert 
3395796c8dcSSimon Schubert     case TERNOP_COND:
3405796c8dcSSimon Schubert       if ((int) prec > (int) PREC_COMMA)
3415796c8dcSSimon Schubert 	fputs_filtered ("(", stream);
3425796c8dcSSimon Schubert       /* Print the subexpressions, forcing parentheses
3435796c8dcSSimon Schubert          around any binary operations within them.
3445796c8dcSSimon Schubert          This is more parentheses than are strictly necessary,
3455796c8dcSSimon Schubert          but it looks clearer.  */
3465796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_HYPER);
3475796c8dcSSimon Schubert       fputs_filtered (" ? ", stream);
3485796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_HYPER);
3495796c8dcSSimon Schubert       fputs_filtered (" : ", stream);
3505796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_HYPER);
3515796c8dcSSimon Schubert       if ((int) prec > (int) PREC_COMMA)
3525796c8dcSSimon Schubert 	fputs_filtered (")", stream);
3535796c8dcSSimon Schubert       return;
3545796c8dcSSimon Schubert 
3555796c8dcSSimon Schubert     case TERNOP_SLICE:
3565796c8dcSSimon Schubert     case TERNOP_SLICE_COUNT:
3575796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3585796c8dcSSimon Schubert       fputs_filtered ("(", stream);
3595796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
3605796c8dcSSimon Schubert       fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream);
3615796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
3625796c8dcSSimon Schubert       fputs_filtered (")", stream);
3635796c8dcSSimon Schubert       return;
3645796c8dcSSimon Schubert 
3655796c8dcSSimon Schubert     case STRUCTOP_STRUCT:
3665796c8dcSSimon Schubert       tem = longest_to_int (exp->elts[pc + 1].longconst);
3675796c8dcSSimon Schubert       (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
3685796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3695796c8dcSSimon Schubert       fputs_filtered (".", stream);
3705796c8dcSSimon Schubert       fputs_filtered (&exp->elts[pc + 2].string, stream);
3715796c8dcSSimon Schubert       return;
3725796c8dcSSimon Schubert 
3735796c8dcSSimon Schubert       /* Will not occur for Modula-2 */
3745796c8dcSSimon Schubert     case STRUCTOP_PTR:
3755796c8dcSSimon Schubert       tem = longest_to_int (exp->elts[pc + 1].longconst);
3765796c8dcSSimon Schubert       (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
3775796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3785796c8dcSSimon Schubert       fputs_filtered ("->", stream);
3795796c8dcSSimon Schubert       fputs_filtered (&exp->elts[pc + 2].string, stream);
3805796c8dcSSimon Schubert       return;
3815796c8dcSSimon Schubert 
3825796c8dcSSimon Schubert     case STRUCTOP_MEMBER:
3835796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3845796c8dcSSimon Schubert       fputs_filtered (".*", stream);
3855796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3865796c8dcSSimon Schubert       return;
3875796c8dcSSimon Schubert 
3885796c8dcSSimon Schubert     case STRUCTOP_MPTR:
3895796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3905796c8dcSSimon Schubert       fputs_filtered ("->*", stream);
3915796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3925796c8dcSSimon Schubert       return;
3935796c8dcSSimon Schubert 
3945796c8dcSSimon Schubert     case BINOP_SUBSCRIPT:
3955796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
3965796c8dcSSimon Schubert       fputs_filtered ("[", stream);
3975796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
3985796c8dcSSimon Schubert       fputs_filtered ("]", stream);
3995796c8dcSSimon Schubert       return;
4005796c8dcSSimon Schubert 
4015796c8dcSSimon Schubert     case UNOP_POSTINCREMENT:
4025796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
4035796c8dcSSimon Schubert       fputs_filtered ("++", stream);
4045796c8dcSSimon Schubert       return;
4055796c8dcSSimon Schubert 
4065796c8dcSSimon Schubert     case UNOP_POSTDECREMENT:
4075796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
4085796c8dcSSimon Schubert       fputs_filtered ("--", stream);
4095796c8dcSSimon Schubert       return;
4105796c8dcSSimon Schubert 
4115796c8dcSSimon Schubert     case UNOP_CAST:
4125796c8dcSSimon Schubert       (*pos) += 2;
4135796c8dcSSimon Schubert       if ((int) prec > (int) PREC_PREFIX)
4145796c8dcSSimon Schubert 	fputs_filtered ("(", stream);
4155796c8dcSSimon Schubert       fputs_filtered ("(", stream);
4165796c8dcSSimon Schubert       type_print (exp->elts[pc + 1].type, "", stream, 0);
4175796c8dcSSimon Schubert       fputs_filtered (") ", stream);
4185796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_PREFIX);
4195796c8dcSSimon Schubert       if ((int) prec > (int) PREC_PREFIX)
4205796c8dcSSimon Schubert 	fputs_filtered (")", stream);
4215796c8dcSSimon Schubert       return;
4225796c8dcSSimon Schubert 
423*cf7f2e2dSJohn Marino     case UNOP_DYNAMIC_CAST:
424*cf7f2e2dSJohn Marino     case UNOP_REINTERPRET_CAST:
425*cf7f2e2dSJohn Marino       fputs_filtered (opcode == UNOP_DYNAMIC_CAST ? "dynamic_cast"
426*cf7f2e2dSJohn Marino 		      : "reinterpret_cast", stream);
427*cf7f2e2dSJohn Marino       fputs_filtered ("<", stream);
428*cf7f2e2dSJohn Marino       (*pos) += 2;
429*cf7f2e2dSJohn Marino       type_print (exp->elts[pc + 1].type, "", stream, 0);
430*cf7f2e2dSJohn Marino       fputs_filtered ("> (", stream);
431*cf7f2e2dSJohn Marino       print_subexp (exp, pos, stream, PREC_PREFIX);
432*cf7f2e2dSJohn Marino       fputs_filtered (")", stream);
433*cf7f2e2dSJohn Marino       return;
434*cf7f2e2dSJohn Marino 
4355796c8dcSSimon Schubert     case UNOP_MEMVAL:
4365796c8dcSSimon Schubert       (*pos) += 2;
4375796c8dcSSimon Schubert       if ((int) prec > (int) PREC_PREFIX)
4385796c8dcSSimon Schubert 	fputs_filtered ("(", stream);
439*cf7f2e2dSJohn Marino       if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC
440*cf7f2e2dSJohn Marino 	  && exp->elts[pc + 3].opcode == OP_LONG)
4415796c8dcSSimon Schubert 	{
4425796c8dcSSimon Schubert 	  struct value_print_options opts;
4435796c8dcSSimon Schubert 
4445796c8dcSSimon Schubert 	  /* We have a minimal symbol fn, probably.  It's encoded
4455796c8dcSSimon Schubert 	     as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
4465796c8dcSSimon Schubert 	     Swallow the OP_LONG (including both its opcodes); ignore
4475796c8dcSSimon Schubert 	     its type; print the value in the type of the MEMVAL.  */
4485796c8dcSSimon Schubert 	  (*pos) += 4;
4495796c8dcSSimon Schubert 	  val = value_at_lazy (exp->elts[pc + 1].type,
4505796c8dcSSimon Schubert 			       (CORE_ADDR) exp->elts[pc + 5].longconst);
4515796c8dcSSimon Schubert 	  get_raw_print_options (&opts);
4525796c8dcSSimon Schubert 	  value_print (val, stream, &opts);
4535796c8dcSSimon Schubert 	}
4545796c8dcSSimon Schubert       else
4555796c8dcSSimon Schubert 	{
4565796c8dcSSimon Schubert 	  fputs_filtered ("{", stream);
4575796c8dcSSimon Schubert 	  type_print (exp->elts[pc + 1].type, "", stream, 0);
4585796c8dcSSimon Schubert 	  fputs_filtered ("} ", stream);
4595796c8dcSSimon Schubert 	  print_subexp (exp, pos, stream, PREC_PREFIX);
4605796c8dcSSimon Schubert 	}
4615796c8dcSSimon Schubert       if ((int) prec > (int) PREC_PREFIX)
4625796c8dcSSimon Schubert 	fputs_filtered (")", stream);
4635796c8dcSSimon Schubert       return;
4645796c8dcSSimon Schubert 
4655796c8dcSSimon Schubert     case UNOP_MEMVAL_TLS:
4665796c8dcSSimon Schubert       (*pos) += 3;
4675796c8dcSSimon Schubert       if ((int) prec > (int) PREC_PREFIX)
4685796c8dcSSimon Schubert 	fputs_filtered ("(", stream);
4695796c8dcSSimon Schubert       fputs_filtered ("{", stream);
4705796c8dcSSimon Schubert       type_print (exp->elts[pc + 2].type, "", stream, 0);
4715796c8dcSSimon Schubert       fputs_filtered ("} ", stream);
4725796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_PREFIX);
4735796c8dcSSimon Schubert       if ((int) prec > (int) PREC_PREFIX)
4745796c8dcSSimon Schubert 	fputs_filtered (")", stream);
4755796c8dcSSimon Schubert       return;
4765796c8dcSSimon Schubert 
4775796c8dcSSimon Schubert     case BINOP_ASSIGN_MODIFY:
4785796c8dcSSimon Schubert       opcode = exp->elts[pc + 1].opcode;
4795796c8dcSSimon Schubert       (*pos) += 2;
4805796c8dcSSimon Schubert       myprec = PREC_ASSIGN;
4815796c8dcSSimon Schubert       assoc = 1;
4825796c8dcSSimon Schubert       assign_modify = 1;
4835796c8dcSSimon Schubert       op_str = "???";
4845796c8dcSSimon Schubert       for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
4855796c8dcSSimon Schubert 	if (op_print_tab[tem].opcode == opcode)
4865796c8dcSSimon Schubert 	  {
4875796c8dcSSimon Schubert 	    op_str = op_print_tab[tem].string;
4885796c8dcSSimon Schubert 	    break;
4895796c8dcSSimon Schubert 	  }
4905796c8dcSSimon Schubert       if (op_print_tab[tem].opcode != opcode)
4915796c8dcSSimon Schubert 	/* Not found; don't try to keep going because we don't know how
4925796c8dcSSimon Schubert 	   to interpret further elements.  */
4935796c8dcSSimon Schubert 	error (_("Invalid expression"));
4945796c8dcSSimon Schubert       break;
4955796c8dcSSimon Schubert 
4965796c8dcSSimon Schubert       /* C++ ops */
4975796c8dcSSimon Schubert 
4985796c8dcSSimon Schubert     case OP_THIS:
4995796c8dcSSimon Schubert       ++(*pos);
5005796c8dcSSimon Schubert       fputs_filtered ("this", stream);
5015796c8dcSSimon Schubert       return;
5025796c8dcSSimon Schubert 
5035796c8dcSSimon Schubert       /* Objective-C ops */
5045796c8dcSSimon Schubert 
5055796c8dcSSimon Schubert     case OP_OBJC_SELF:
5065796c8dcSSimon Schubert       ++(*pos);
5075796c8dcSSimon Schubert       fputs_filtered ("self", stream);	/* The ObjC equivalent of "this".  */
5085796c8dcSSimon Schubert       return;
5095796c8dcSSimon Schubert 
5105796c8dcSSimon Schubert       /* Modula-2 ops */
5115796c8dcSSimon Schubert 
5125796c8dcSSimon Schubert     case MULTI_SUBSCRIPT:
5135796c8dcSSimon Schubert       (*pos) += 2;
5145796c8dcSSimon Schubert       nargs = longest_to_int (exp->elts[pc + 1].longconst);
5155796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_SUFFIX);
5165796c8dcSSimon Schubert       fprintf_unfiltered (stream, " [");
5175796c8dcSSimon Schubert       for (tem = 0; tem < nargs; tem++)
5185796c8dcSSimon Schubert 	{
5195796c8dcSSimon Schubert 	  if (tem != 0)
5205796c8dcSSimon Schubert 	    fprintf_unfiltered (stream, ", ");
5215796c8dcSSimon Schubert 	  print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
5225796c8dcSSimon Schubert 	}
5235796c8dcSSimon Schubert       fprintf_unfiltered (stream, "]");
5245796c8dcSSimon Schubert       return;
5255796c8dcSSimon Schubert 
5265796c8dcSSimon Schubert     case BINOP_VAL:
5275796c8dcSSimon Schubert       (*pos) += 2;
5285796c8dcSSimon Schubert       fprintf_unfiltered (stream, "VAL(");
5295796c8dcSSimon Schubert       type_print (exp->elts[pc + 1].type, "", stream, 0);
5305796c8dcSSimon Schubert       fprintf_unfiltered (stream, ",");
5315796c8dcSSimon Schubert       print_subexp (exp, pos, stream, PREC_PREFIX);
5325796c8dcSSimon Schubert       fprintf_unfiltered (stream, ")");
5335796c8dcSSimon Schubert       return;
5345796c8dcSSimon Schubert 
5355796c8dcSSimon Schubert       /* Default ops */
5365796c8dcSSimon Schubert 
5375796c8dcSSimon Schubert     default:
5385796c8dcSSimon Schubert       op_str = "???";
5395796c8dcSSimon Schubert       for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
5405796c8dcSSimon Schubert 	if (op_print_tab[tem].opcode == opcode)
5415796c8dcSSimon Schubert 	  {
5425796c8dcSSimon Schubert 	    op_str = op_print_tab[tem].string;
5435796c8dcSSimon Schubert 	    myprec = op_print_tab[tem].precedence;
5445796c8dcSSimon Schubert 	    assoc = op_print_tab[tem].right_assoc;
5455796c8dcSSimon Schubert 	    break;
5465796c8dcSSimon Schubert 	  }
5475796c8dcSSimon Schubert       if (op_print_tab[tem].opcode != opcode)
5485796c8dcSSimon Schubert 	/* Not found; don't try to keep going because we don't know how
5495796c8dcSSimon Schubert 	   to interpret further elements.  For example, this happens
5505796c8dcSSimon Schubert 	   if opcode is OP_TYPE.  */
5515796c8dcSSimon Schubert 	error (_("Invalid expression"));
5525796c8dcSSimon Schubert     }
5535796c8dcSSimon Schubert 
5545796c8dcSSimon Schubert   /* Note that PREC_BUILTIN will always emit parentheses. */
5555796c8dcSSimon Schubert   if ((int) myprec < (int) prec)
5565796c8dcSSimon Schubert     fputs_filtered ("(", stream);
5575796c8dcSSimon Schubert   if ((int) opcode > (int) BINOP_END)
5585796c8dcSSimon Schubert     {
5595796c8dcSSimon Schubert       if (assoc)
5605796c8dcSSimon Schubert 	{
5615796c8dcSSimon Schubert 	  /* Unary postfix operator.  */
5625796c8dcSSimon Schubert 	  print_subexp (exp, pos, stream, PREC_SUFFIX);
5635796c8dcSSimon Schubert 	  fputs_filtered (op_str, stream);
5645796c8dcSSimon Schubert 	}
5655796c8dcSSimon Schubert       else
5665796c8dcSSimon Schubert 	{
5675796c8dcSSimon Schubert 	  /* Unary prefix operator.  */
5685796c8dcSSimon Schubert 	  fputs_filtered (op_str, stream);
5695796c8dcSSimon Schubert 	  if (myprec == PREC_BUILTIN_FUNCTION)
5705796c8dcSSimon Schubert 	    fputs_filtered ("(", stream);
5715796c8dcSSimon Schubert 	  print_subexp (exp, pos, stream, PREC_PREFIX);
5725796c8dcSSimon Schubert 	  if (myprec == PREC_BUILTIN_FUNCTION)
5735796c8dcSSimon Schubert 	    fputs_filtered (")", stream);
5745796c8dcSSimon Schubert 	}
5755796c8dcSSimon Schubert     }
5765796c8dcSSimon Schubert   else
5775796c8dcSSimon Schubert     {
5785796c8dcSSimon Schubert       /* Binary operator.  */
5795796c8dcSSimon Schubert       /* Print left operand.
5805796c8dcSSimon Schubert          If operator is right-associative,
5815796c8dcSSimon Schubert          increment precedence for this operand.  */
5825796c8dcSSimon Schubert       print_subexp (exp, pos, stream,
5835796c8dcSSimon Schubert 		    (enum precedence) ((int) myprec + assoc));
5845796c8dcSSimon Schubert       /* Print the operator itself.  */
5855796c8dcSSimon Schubert       if (assign_modify)
5865796c8dcSSimon Schubert 	fprintf_filtered (stream, " %s= ", op_str);
5875796c8dcSSimon Schubert       else if (op_str[0] == ',')
5885796c8dcSSimon Schubert 	fprintf_filtered (stream, "%s ", op_str);
5895796c8dcSSimon Schubert       else
5905796c8dcSSimon Schubert 	fprintf_filtered (stream, " %s ", op_str);
5915796c8dcSSimon Schubert       /* Print right operand.
5925796c8dcSSimon Schubert          If operator is left-associative,
5935796c8dcSSimon Schubert          increment precedence for this operand.  */
5945796c8dcSSimon Schubert       print_subexp (exp, pos, stream,
5955796c8dcSSimon Schubert 		    (enum precedence) ((int) myprec + !assoc));
5965796c8dcSSimon Schubert     }
5975796c8dcSSimon Schubert 
5985796c8dcSSimon Schubert   if ((int) myprec < (int) prec)
5995796c8dcSSimon Schubert     fputs_filtered (")", stream);
6005796c8dcSSimon Schubert }
6015796c8dcSSimon Schubert 
6025796c8dcSSimon Schubert /* Return the operator corresponding to opcode OP as
6035796c8dcSSimon Schubert    a string.   NULL indicates that the opcode was not found in the
6045796c8dcSSimon Schubert    current language table.  */
6055796c8dcSSimon Schubert char *
6065796c8dcSSimon Schubert op_string (enum exp_opcode op)
6075796c8dcSSimon Schubert {
6085796c8dcSSimon Schubert   int tem;
6095796c8dcSSimon Schubert   const struct op_print *op_print_tab;
6105796c8dcSSimon Schubert 
6115796c8dcSSimon Schubert   op_print_tab = current_language->la_op_print_tab;
6125796c8dcSSimon Schubert   for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++)
6135796c8dcSSimon Schubert     if (op_print_tab[tem].opcode == op)
6145796c8dcSSimon Schubert       return op_print_tab[tem].string;
6155796c8dcSSimon Schubert   return NULL;
6165796c8dcSSimon Schubert }
6175796c8dcSSimon Schubert 
6185796c8dcSSimon Schubert /* Support for dumping the raw data from expressions in a human readable
6195796c8dcSSimon Schubert    form.  */
6205796c8dcSSimon Schubert 
6215796c8dcSSimon Schubert static char *op_name (struct expression *, enum exp_opcode);
6225796c8dcSSimon Schubert static int dump_subexp_body (struct expression *exp, struct ui_file *, int);
6235796c8dcSSimon Schubert 
6245796c8dcSSimon Schubert /* Name for OPCODE, when it appears in expression EXP. */
6255796c8dcSSimon Schubert 
6265796c8dcSSimon Schubert static char *
6275796c8dcSSimon Schubert op_name (struct expression *exp, enum exp_opcode opcode)
6285796c8dcSSimon Schubert {
6295796c8dcSSimon Schubert   return exp->language_defn->la_exp_desc->op_name (opcode);
6305796c8dcSSimon Schubert }
6315796c8dcSSimon Schubert 
6325796c8dcSSimon Schubert /* Default name for the standard operator OPCODE (i.e., one defined in
6335796c8dcSSimon Schubert    the definition of enum exp_opcode).  */
6345796c8dcSSimon Schubert 
6355796c8dcSSimon Schubert char *
6365796c8dcSSimon Schubert op_name_standard (enum exp_opcode opcode)
6375796c8dcSSimon Schubert {
6385796c8dcSSimon Schubert   switch (opcode)
6395796c8dcSSimon Schubert     {
6405796c8dcSSimon Schubert     default:
6415796c8dcSSimon Schubert       {
6425796c8dcSSimon Schubert 	static char buf[30];
6435796c8dcSSimon Schubert 
6445796c8dcSSimon Schubert 	sprintf (buf, "<unknown %d>", opcode);
6455796c8dcSSimon Schubert 	return buf;
6465796c8dcSSimon Schubert       }
6475796c8dcSSimon Schubert     case OP_NULL:
6485796c8dcSSimon Schubert       return "OP_NULL";
6495796c8dcSSimon Schubert     case BINOP_ADD:
6505796c8dcSSimon Schubert       return "BINOP_ADD";
6515796c8dcSSimon Schubert     case BINOP_SUB:
6525796c8dcSSimon Schubert       return "BINOP_SUB";
6535796c8dcSSimon Schubert     case BINOP_MUL:
6545796c8dcSSimon Schubert       return "BINOP_MUL";
6555796c8dcSSimon Schubert     case BINOP_DIV:
6565796c8dcSSimon Schubert       return "BINOP_DIV";
6575796c8dcSSimon Schubert     case BINOP_REM:
6585796c8dcSSimon Schubert       return "BINOP_REM";
6595796c8dcSSimon Schubert     case BINOP_MOD:
6605796c8dcSSimon Schubert       return "BINOP_MOD";
6615796c8dcSSimon Schubert     case BINOP_LSH:
6625796c8dcSSimon Schubert       return "BINOP_LSH";
6635796c8dcSSimon Schubert     case BINOP_RSH:
6645796c8dcSSimon Schubert       return "BINOP_RSH";
6655796c8dcSSimon Schubert     case BINOP_LOGICAL_AND:
6665796c8dcSSimon Schubert       return "BINOP_LOGICAL_AND";
6675796c8dcSSimon Schubert     case BINOP_LOGICAL_OR:
6685796c8dcSSimon Schubert       return "BINOP_LOGICAL_OR";
6695796c8dcSSimon Schubert     case BINOP_BITWISE_AND:
6705796c8dcSSimon Schubert       return "BINOP_BITWISE_AND";
6715796c8dcSSimon Schubert     case BINOP_BITWISE_IOR:
6725796c8dcSSimon Schubert       return "BINOP_BITWISE_IOR";
6735796c8dcSSimon Schubert     case BINOP_BITWISE_XOR:
6745796c8dcSSimon Schubert       return "BINOP_BITWISE_XOR";
6755796c8dcSSimon Schubert     case BINOP_EQUAL:
6765796c8dcSSimon Schubert       return "BINOP_EQUAL";
6775796c8dcSSimon Schubert     case BINOP_NOTEQUAL:
6785796c8dcSSimon Schubert       return "BINOP_NOTEQUAL";
6795796c8dcSSimon Schubert     case BINOP_LESS:
6805796c8dcSSimon Schubert       return "BINOP_LESS";
6815796c8dcSSimon Schubert     case BINOP_GTR:
6825796c8dcSSimon Schubert       return "BINOP_GTR";
6835796c8dcSSimon Schubert     case BINOP_LEQ:
6845796c8dcSSimon Schubert       return "BINOP_LEQ";
6855796c8dcSSimon Schubert     case BINOP_GEQ:
6865796c8dcSSimon Schubert       return "BINOP_GEQ";
6875796c8dcSSimon Schubert     case BINOP_REPEAT:
6885796c8dcSSimon Schubert       return "BINOP_REPEAT";
6895796c8dcSSimon Schubert     case BINOP_ASSIGN:
6905796c8dcSSimon Schubert       return "BINOP_ASSIGN";
6915796c8dcSSimon Schubert     case BINOP_COMMA:
6925796c8dcSSimon Schubert       return "BINOP_COMMA";
6935796c8dcSSimon Schubert     case BINOP_SUBSCRIPT:
6945796c8dcSSimon Schubert       return "BINOP_SUBSCRIPT";
6955796c8dcSSimon Schubert     case MULTI_SUBSCRIPT:
6965796c8dcSSimon Schubert       return "MULTI_SUBSCRIPT";
6975796c8dcSSimon Schubert     case BINOP_EXP:
6985796c8dcSSimon Schubert       return "BINOP_EXP";
6995796c8dcSSimon Schubert     case BINOP_MIN:
7005796c8dcSSimon Schubert       return "BINOP_MIN";
7015796c8dcSSimon Schubert     case BINOP_MAX:
7025796c8dcSSimon Schubert       return "BINOP_MAX";
7035796c8dcSSimon Schubert     case STRUCTOP_MEMBER:
7045796c8dcSSimon Schubert       return "STRUCTOP_MEMBER";
7055796c8dcSSimon Schubert     case STRUCTOP_MPTR:
7065796c8dcSSimon Schubert       return "STRUCTOP_MPTR";
7075796c8dcSSimon Schubert     case BINOP_INTDIV:
7085796c8dcSSimon Schubert       return "BINOP_INTDIV";
7095796c8dcSSimon Schubert     case BINOP_ASSIGN_MODIFY:
7105796c8dcSSimon Schubert       return "BINOP_ASSIGN_MODIFY";
7115796c8dcSSimon Schubert     case BINOP_VAL:
7125796c8dcSSimon Schubert       return "BINOP_VAL";
7135796c8dcSSimon Schubert     case BINOP_CONCAT:
7145796c8dcSSimon Schubert       return "BINOP_CONCAT";
7155796c8dcSSimon Schubert     case BINOP_RANGE:
7165796c8dcSSimon Schubert       return "BINOP_RANGE";
7175796c8dcSSimon Schubert     case BINOP_END:
7185796c8dcSSimon Schubert       return "BINOP_END";
7195796c8dcSSimon Schubert     case TERNOP_COND:
7205796c8dcSSimon Schubert       return "TERNOP_COND";
7215796c8dcSSimon Schubert     case TERNOP_SLICE:
7225796c8dcSSimon Schubert       return "TERNOP_SLICE";
7235796c8dcSSimon Schubert     case TERNOP_SLICE_COUNT:
7245796c8dcSSimon Schubert       return "TERNOP_SLICE_COUNT";
7255796c8dcSSimon Schubert     case OP_LONG:
7265796c8dcSSimon Schubert       return "OP_LONG";
7275796c8dcSSimon Schubert     case OP_DOUBLE:
7285796c8dcSSimon Schubert       return "OP_DOUBLE";
7295796c8dcSSimon Schubert     case OP_VAR_VALUE:
7305796c8dcSSimon Schubert       return "OP_VAR_VALUE";
7315796c8dcSSimon Schubert     case OP_LAST:
7325796c8dcSSimon Schubert       return "OP_LAST";
7335796c8dcSSimon Schubert     case OP_REGISTER:
7345796c8dcSSimon Schubert       return "OP_REGISTER";
7355796c8dcSSimon Schubert     case OP_INTERNALVAR:
7365796c8dcSSimon Schubert       return "OP_INTERNALVAR";
7375796c8dcSSimon Schubert     case OP_FUNCALL:
7385796c8dcSSimon Schubert       return "OP_FUNCALL";
7395796c8dcSSimon Schubert     case OP_STRING:
7405796c8dcSSimon Schubert       return "OP_STRING";
7415796c8dcSSimon Schubert     case OP_BITSTRING:
7425796c8dcSSimon Schubert       return "OP_BITSTRING";
7435796c8dcSSimon Schubert     case OP_ARRAY:
7445796c8dcSSimon Schubert       return "OP_ARRAY";
7455796c8dcSSimon Schubert     case UNOP_CAST:
7465796c8dcSSimon Schubert       return "UNOP_CAST";
747*cf7f2e2dSJohn Marino     case UNOP_DYNAMIC_CAST:
748*cf7f2e2dSJohn Marino       return "UNOP_DYNAMIC_CAST";
749*cf7f2e2dSJohn Marino     case UNOP_REINTERPRET_CAST:
750*cf7f2e2dSJohn Marino       return "UNOP_REINTERPRET_CAST";
7515796c8dcSSimon Schubert     case UNOP_MEMVAL:
7525796c8dcSSimon Schubert       return "UNOP_MEMVAL";
7535796c8dcSSimon Schubert     case UNOP_MEMVAL_TLS:
7545796c8dcSSimon Schubert       return "UNOP_MEMVAL_TLS";
7555796c8dcSSimon Schubert     case UNOP_NEG:
7565796c8dcSSimon Schubert       return "UNOP_NEG";
7575796c8dcSSimon Schubert     case UNOP_LOGICAL_NOT:
7585796c8dcSSimon Schubert       return "UNOP_LOGICAL_NOT";
7595796c8dcSSimon Schubert     case UNOP_COMPLEMENT:
7605796c8dcSSimon Schubert       return "UNOP_COMPLEMENT";
7615796c8dcSSimon Schubert     case UNOP_IND:
7625796c8dcSSimon Schubert       return "UNOP_IND";
7635796c8dcSSimon Schubert     case UNOP_ADDR:
7645796c8dcSSimon Schubert       return "UNOP_ADDR";
7655796c8dcSSimon Schubert     case UNOP_PREINCREMENT:
7665796c8dcSSimon Schubert       return "UNOP_PREINCREMENT";
7675796c8dcSSimon Schubert     case UNOP_POSTINCREMENT:
7685796c8dcSSimon Schubert       return "UNOP_POSTINCREMENT";
7695796c8dcSSimon Schubert     case UNOP_PREDECREMENT:
7705796c8dcSSimon Schubert       return "UNOP_PREDECREMENT";
7715796c8dcSSimon Schubert     case UNOP_POSTDECREMENT:
7725796c8dcSSimon Schubert       return "UNOP_POSTDECREMENT";
7735796c8dcSSimon Schubert     case UNOP_SIZEOF:
7745796c8dcSSimon Schubert       return "UNOP_SIZEOF";
7755796c8dcSSimon Schubert     case UNOP_PLUS:
7765796c8dcSSimon Schubert       return "UNOP_PLUS";
7775796c8dcSSimon Schubert     case UNOP_CAP:
7785796c8dcSSimon Schubert       return "UNOP_CAP";
7795796c8dcSSimon Schubert     case UNOP_CHR:
7805796c8dcSSimon Schubert       return "UNOP_CHR";
7815796c8dcSSimon Schubert     case UNOP_ORD:
7825796c8dcSSimon Schubert       return "UNOP_ORD";
7835796c8dcSSimon Schubert     case UNOP_ABS:
7845796c8dcSSimon Schubert       return "UNOP_ABS";
7855796c8dcSSimon Schubert     case UNOP_FLOAT:
7865796c8dcSSimon Schubert       return "UNOP_FLOAT";
7875796c8dcSSimon Schubert     case UNOP_HIGH:
7885796c8dcSSimon Schubert       return "UNOP_HIGH";
7895796c8dcSSimon Schubert     case UNOP_MAX:
7905796c8dcSSimon Schubert       return "UNOP_MAX";
7915796c8dcSSimon Schubert     case UNOP_MIN:
7925796c8dcSSimon Schubert       return "UNOP_MIN";
7935796c8dcSSimon Schubert     case UNOP_ODD:
7945796c8dcSSimon Schubert       return "UNOP_ODD";
7955796c8dcSSimon Schubert     case UNOP_TRUNC:
7965796c8dcSSimon Schubert       return "UNOP_TRUNC";
7975796c8dcSSimon Schubert     case OP_BOOL:
7985796c8dcSSimon Schubert       return "OP_BOOL";
7995796c8dcSSimon Schubert     case OP_M2_STRING:
8005796c8dcSSimon Schubert       return "OP_M2_STRING";
8015796c8dcSSimon Schubert     case STRUCTOP_STRUCT:
8025796c8dcSSimon Schubert       return "STRUCTOP_STRUCT";
8035796c8dcSSimon Schubert     case STRUCTOP_PTR:
8045796c8dcSSimon Schubert       return "STRUCTOP_PTR";
8055796c8dcSSimon Schubert     case OP_THIS:
8065796c8dcSSimon Schubert       return "OP_THIS";
8075796c8dcSSimon Schubert     case OP_OBJC_SELF:
8085796c8dcSSimon Schubert       return "OP_OBJC_SELF";
8095796c8dcSSimon Schubert     case OP_SCOPE:
8105796c8dcSSimon Schubert       return "OP_SCOPE";
8115796c8dcSSimon Schubert     case OP_TYPE:
8125796c8dcSSimon Schubert       return "OP_TYPE";
8135796c8dcSSimon Schubert     case OP_LABELED:
8145796c8dcSSimon Schubert       return "OP_LABELED";
815*cf7f2e2dSJohn Marino     case OP_ADL_FUNC:
816*cf7f2e2dSJohn Marino       return "OP_ADL_FUNC";
8175796c8dcSSimon Schubert     }
8185796c8dcSSimon Schubert }
8195796c8dcSSimon Schubert 
8205796c8dcSSimon Schubert /* Print a raw dump of expression EXP to STREAM.
8215796c8dcSSimon Schubert    NOTE, if non-NULL, is printed as extra explanatory text.  */
8225796c8dcSSimon Schubert 
8235796c8dcSSimon Schubert void
8245796c8dcSSimon Schubert dump_raw_expression (struct expression *exp, struct ui_file *stream,
8255796c8dcSSimon Schubert 		     char *note)
8265796c8dcSSimon Schubert {
8275796c8dcSSimon Schubert   int elt;
8285796c8dcSSimon Schubert   char *opcode_name;
8295796c8dcSSimon Schubert   char *eltscan;
8305796c8dcSSimon Schubert   int eltsize;
8315796c8dcSSimon Schubert 
8325796c8dcSSimon Schubert   fprintf_filtered (stream, "Dump of expression @ ");
8335796c8dcSSimon Schubert   gdb_print_host_address (exp, stream);
8345796c8dcSSimon Schubert   if (note)
8355796c8dcSSimon Schubert     fprintf_filtered (stream, ", %s:", note);
8365796c8dcSSimon Schubert   fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
8375796c8dcSSimon Schubert 		    exp->language_defn->la_name, exp->nelts,
8385796c8dcSSimon Schubert 		    (long) sizeof (union exp_element));
8395796c8dcSSimon Schubert   fprintf_filtered (stream, "\t%5s  %20s  %16s  %s\n", "Index", "Opcode",
8405796c8dcSSimon Schubert 		    "Hex Value", "String Value");
8415796c8dcSSimon Schubert   for (elt = 0; elt < exp->nelts; elt++)
8425796c8dcSSimon Schubert     {
8435796c8dcSSimon Schubert       fprintf_filtered (stream, "\t%5d  ", elt);
8445796c8dcSSimon Schubert       opcode_name = op_name (exp, exp->elts[elt].opcode);
8455796c8dcSSimon Schubert 
8465796c8dcSSimon Schubert       fprintf_filtered (stream, "%20s  ", opcode_name);
8475796c8dcSSimon Schubert       print_longest (stream, 'd', 0, exp->elts[elt].longconst);
8485796c8dcSSimon Schubert       fprintf_filtered (stream, "  ");
8495796c8dcSSimon Schubert 
8505796c8dcSSimon Schubert       for (eltscan = (char *) &exp->elts[elt],
8515796c8dcSSimon Schubert 	   eltsize = sizeof (union exp_element);
8525796c8dcSSimon Schubert 	   eltsize-- > 0;
8535796c8dcSSimon Schubert 	   eltscan++)
8545796c8dcSSimon Schubert 	{
8555796c8dcSSimon Schubert 	  fprintf_filtered (stream, "%c",
8565796c8dcSSimon Schubert 			    isprint (*eltscan) ? (*eltscan & 0xFF) : '.');
8575796c8dcSSimon Schubert 	}
8585796c8dcSSimon Schubert       fprintf_filtered (stream, "\n");
8595796c8dcSSimon Schubert     }
8605796c8dcSSimon Schubert }
8615796c8dcSSimon Schubert 
8625796c8dcSSimon Schubert /* Dump the subexpression of prefix expression EXP whose operator is at
8635796c8dcSSimon Schubert    position ELT onto STREAM.  Returns the position of the next
8645796c8dcSSimon Schubert    subexpression in EXP.  */
8655796c8dcSSimon Schubert 
8665796c8dcSSimon Schubert int
8675796c8dcSSimon Schubert dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
8685796c8dcSSimon Schubert {
8695796c8dcSSimon Schubert   static int indent = 0;
8705796c8dcSSimon Schubert   int i;
8715796c8dcSSimon Schubert 
8725796c8dcSSimon Schubert   fprintf_filtered (stream, "\n");
8735796c8dcSSimon Schubert   fprintf_filtered (stream, "\t%5d  ", elt);
8745796c8dcSSimon Schubert 
8755796c8dcSSimon Schubert   for (i = 1; i <= indent; i++)
8765796c8dcSSimon Schubert     fprintf_filtered (stream, " ");
8775796c8dcSSimon Schubert   indent += 2;
8785796c8dcSSimon Schubert 
8795796c8dcSSimon Schubert   fprintf_filtered (stream, "%-20s  ", op_name (exp, exp->elts[elt].opcode));
8805796c8dcSSimon Schubert 
8815796c8dcSSimon Schubert   elt = dump_subexp_body (exp, stream, elt);
8825796c8dcSSimon Schubert 
8835796c8dcSSimon Schubert   indent -= 2;
8845796c8dcSSimon Schubert 
8855796c8dcSSimon Schubert   return elt;
8865796c8dcSSimon Schubert }
8875796c8dcSSimon Schubert 
8885796c8dcSSimon Schubert /* Dump the operands of prefix expression EXP whose opcode is at
8895796c8dcSSimon Schubert    position ELT onto STREAM.  Returns the position of the next
8905796c8dcSSimon Schubert    subexpression in EXP.  */
8915796c8dcSSimon Schubert 
8925796c8dcSSimon Schubert static int
8935796c8dcSSimon Schubert dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt)
8945796c8dcSSimon Schubert {
8955796c8dcSSimon Schubert   return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt);
8965796c8dcSSimon Schubert }
8975796c8dcSSimon Schubert 
8985796c8dcSSimon Schubert /* Default value for subexp_body in exp_descriptor vector.  */
8995796c8dcSSimon Schubert 
9005796c8dcSSimon Schubert int
9015796c8dcSSimon Schubert dump_subexp_body_standard (struct expression *exp,
9025796c8dcSSimon Schubert 			   struct ui_file *stream, int elt)
9035796c8dcSSimon Schubert {
9045796c8dcSSimon Schubert   int opcode = exp->elts[elt++].opcode;
9055796c8dcSSimon Schubert 
9065796c8dcSSimon Schubert   switch (opcode)
9075796c8dcSSimon Schubert     {
9085796c8dcSSimon Schubert     case TERNOP_COND:
9095796c8dcSSimon Schubert     case TERNOP_SLICE:
9105796c8dcSSimon Schubert     case TERNOP_SLICE_COUNT:
9115796c8dcSSimon Schubert       elt = dump_subexp (exp, stream, elt);
9125796c8dcSSimon Schubert     case BINOP_ADD:
9135796c8dcSSimon Schubert     case BINOP_SUB:
9145796c8dcSSimon Schubert     case BINOP_MUL:
9155796c8dcSSimon Schubert     case BINOP_DIV:
9165796c8dcSSimon Schubert     case BINOP_REM:
9175796c8dcSSimon Schubert     case BINOP_MOD:
9185796c8dcSSimon Schubert     case BINOP_LSH:
9195796c8dcSSimon Schubert     case BINOP_RSH:
9205796c8dcSSimon Schubert     case BINOP_LOGICAL_AND:
9215796c8dcSSimon Schubert     case BINOP_LOGICAL_OR:
9225796c8dcSSimon Schubert     case BINOP_BITWISE_AND:
9235796c8dcSSimon Schubert     case BINOP_BITWISE_IOR:
9245796c8dcSSimon Schubert     case BINOP_BITWISE_XOR:
9255796c8dcSSimon Schubert     case BINOP_EQUAL:
9265796c8dcSSimon Schubert     case BINOP_NOTEQUAL:
9275796c8dcSSimon Schubert     case BINOP_LESS:
9285796c8dcSSimon Schubert     case BINOP_GTR:
9295796c8dcSSimon Schubert     case BINOP_LEQ:
9305796c8dcSSimon Schubert     case BINOP_GEQ:
9315796c8dcSSimon Schubert     case BINOP_REPEAT:
9325796c8dcSSimon Schubert     case BINOP_ASSIGN:
9335796c8dcSSimon Schubert     case BINOP_COMMA:
9345796c8dcSSimon Schubert     case BINOP_SUBSCRIPT:
9355796c8dcSSimon Schubert     case BINOP_EXP:
9365796c8dcSSimon Schubert     case BINOP_MIN:
9375796c8dcSSimon Schubert     case BINOP_MAX:
9385796c8dcSSimon Schubert     case BINOP_INTDIV:
9395796c8dcSSimon Schubert     case BINOP_ASSIGN_MODIFY:
9405796c8dcSSimon Schubert     case BINOP_VAL:
9415796c8dcSSimon Schubert     case BINOP_CONCAT:
9425796c8dcSSimon Schubert     case BINOP_IN:
9435796c8dcSSimon Schubert     case BINOP_RANGE:
9445796c8dcSSimon Schubert     case BINOP_END:
9455796c8dcSSimon Schubert     case STRUCTOP_MEMBER:
9465796c8dcSSimon Schubert     case STRUCTOP_MPTR:
9475796c8dcSSimon Schubert       elt = dump_subexp (exp, stream, elt);
9485796c8dcSSimon Schubert     case UNOP_NEG:
9495796c8dcSSimon Schubert     case UNOP_LOGICAL_NOT:
9505796c8dcSSimon Schubert     case UNOP_COMPLEMENT:
9515796c8dcSSimon Schubert     case UNOP_IND:
9525796c8dcSSimon Schubert     case UNOP_ADDR:
9535796c8dcSSimon Schubert     case UNOP_PREINCREMENT:
9545796c8dcSSimon Schubert     case UNOP_POSTINCREMENT:
9555796c8dcSSimon Schubert     case UNOP_PREDECREMENT:
9565796c8dcSSimon Schubert     case UNOP_POSTDECREMENT:
9575796c8dcSSimon Schubert     case UNOP_SIZEOF:
9585796c8dcSSimon Schubert     case UNOP_PLUS:
9595796c8dcSSimon Schubert     case UNOP_CAP:
9605796c8dcSSimon Schubert     case UNOP_CHR:
9615796c8dcSSimon Schubert     case UNOP_ORD:
9625796c8dcSSimon Schubert     case UNOP_ABS:
9635796c8dcSSimon Schubert     case UNOP_FLOAT:
9645796c8dcSSimon Schubert     case UNOP_HIGH:
9655796c8dcSSimon Schubert     case UNOP_MAX:
9665796c8dcSSimon Schubert     case UNOP_MIN:
9675796c8dcSSimon Schubert     case UNOP_ODD:
9685796c8dcSSimon Schubert     case UNOP_TRUNC:
9695796c8dcSSimon Schubert       elt = dump_subexp (exp, stream, elt);
9705796c8dcSSimon Schubert       break;
9715796c8dcSSimon Schubert     case OP_LONG:
9725796c8dcSSimon Schubert       fprintf_filtered (stream, "Type @");
9735796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt].type, stream);
9745796c8dcSSimon Schubert       fprintf_filtered (stream, " (");
9755796c8dcSSimon Schubert       type_print (exp->elts[elt].type, NULL, stream, 0);
9765796c8dcSSimon Schubert       fprintf_filtered (stream, "), value %ld (0x%lx)",
9775796c8dcSSimon Schubert 			(long) exp->elts[elt + 1].longconst,
9785796c8dcSSimon Schubert 			(long) exp->elts[elt + 1].longconst);
9795796c8dcSSimon Schubert       elt += 3;
9805796c8dcSSimon Schubert       break;
9815796c8dcSSimon Schubert     case OP_DOUBLE:
9825796c8dcSSimon Schubert       fprintf_filtered (stream, "Type @");
9835796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt].type, stream);
9845796c8dcSSimon Schubert       fprintf_filtered (stream, " (");
9855796c8dcSSimon Schubert       type_print (exp->elts[elt].type, NULL, stream, 0);
9865796c8dcSSimon Schubert       fprintf_filtered (stream, "), value %g",
9875796c8dcSSimon Schubert 			(double) exp->elts[elt + 1].doubleconst);
9885796c8dcSSimon Schubert       elt += 3;
9895796c8dcSSimon Schubert       break;
9905796c8dcSSimon Schubert     case OP_VAR_VALUE:
9915796c8dcSSimon Schubert       fprintf_filtered (stream, "Block @");
9925796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt].block, stream);
9935796c8dcSSimon Schubert       fprintf_filtered (stream, ", symbol @");
9945796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
9955796c8dcSSimon Schubert       fprintf_filtered (stream, " (%s)",
9965796c8dcSSimon Schubert 			SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol));
9975796c8dcSSimon Schubert       elt += 3;
9985796c8dcSSimon Schubert       break;
9995796c8dcSSimon Schubert     case OP_LAST:
10005796c8dcSSimon Schubert       fprintf_filtered (stream, "History element %ld",
10015796c8dcSSimon Schubert 			(long) exp->elts[elt].longconst);
10025796c8dcSSimon Schubert       elt += 2;
10035796c8dcSSimon Schubert       break;
10045796c8dcSSimon Schubert     case OP_REGISTER:
10055796c8dcSSimon Schubert       fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string);
10065796c8dcSSimon Schubert       elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1);
10075796c8dcSSimon Schubert       break;
10085796c8dcSSimon Schubert     case OP_INTERNALVAR:
10095796c8dcSSimon Schubert       fprintf_filtered (stream, "Internal var @");
10105796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt].internalvar, stream);
10115796c8dcSSimon Schubert       fprintf_filtered (stream, " (%s)",
10125796c8dcSSimon Schubert 			internalvar_name (exp->elts[elt].internalvar));
10135796c8dcSSimon Schubert       elt += 2;
10145796c8dcSSimon Schubert       break;
10155796c8dcSSimon Schubert     case OP_FUNCALL:
10165796c8dcSSimon Schubert       {
10175796c8dcSSimon Schubert 	int i, nargs;
10185796c8dcSSimon Schubert 
10195796c8dcSSimon Schubert 	nargs = longest_to_int (exp->elts[elt].longconst);
10205796c8dcSSimon Schubert 
10215796c8dcSSimon Schubert 	fprintf_filtered (stream, "Number of args: %d", nargs);
10225796c8dcSSimon Schubert 	elt += 2;
10235796c8dcSSimon Schubert 
10245796c8dcSSimon Schubert 	for (i = 1; i <= nargs + 1; i++)
10255796c8dcSSimon Schubert 	  elt = dump_subexp (exp, stream, elt);
10265796c8dcSSimon Schubert       }
10275796c8dcSSimon Schubert       break;
10285796c8dcSSimon Schubert     case OP_ARRAY:
10295796c8dcSSimon Schubert       {
10305796c8dcSSimon Schubert 	int lower, upper;
10315796c8dcSSimon Schubert 	int i;
10325796c8dcSSimon Schubert 
10335796c8dcSSimon Schubert 	lower = longest_to_int (exp->elts[elt].longconst);
10345796c8dcSSimon Schubert 	upper = longest_to_int (exp->elts[elt + 1].longconst);
10355796c8dcSSimon Schubert 
10365796c8dcSSimon Schubert 	fprintf_filtered (stream, "Bounds [%d:%d]", lower, upper);
10375796c8dcSSimon Schubert 	elt += 3;
10385796c8dcSSimon Schubert 
10395796c8dcSSimon Schubert 	for (i = 1; i <= upper - lower + 1; i++)
10405796c8dcSSimon Schubert 	  elt = dump_subexp (exp, stream, elt);
10415796c8dcSSimon Schubert       }
10425796c8dcSSimon Schubert       break;
10435796c8dcSSimon Schubert     case UNOP_MEMVAL:
10445796c8dcSSimon Schubert     case UNOP_CAST:
1045*cf7f2e2dSJohn Marino     case UNOP_DYNAMIC_CAST:
1046*cf7f2e2dSJohn Marino     case UNOP_REINTERPRET_CAST:
10475796c8dcSSimon Schubert       fprintf_filtered (stream, "Type @");
10485796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt].type, stream);
10495796c8dcSSimon Schubert       fprintf_filtered (stream, " (");
10505796c8dcSSimon Schubert       type_print (exp->elts[elt].type, NULL, stream, 0);
10515796c8dcSSimon Schubert       fprintf_filtered (stream, ")");
10525796c8dcSSimon Schubert       elt = dump_subexp (exp, stream, elt + 2);
10535796c8dcSSimon Schubert       break;
10545796c8dcSSimon Schubert     case UNOP_MEMVAL_TLS:
10555796c8dcSSimon Schubert       fprintf_filtered (stream, "TLS type @");
10565796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt + 1].type, stream);
10575796c8dcSSimon Schubert       fprintf_filtered (stream, " (__thread /* \"%s\" */ ",
10585796c8dcSSimon Schubert                         (exp->elts[elt].objfile == NULL ? "(null)"
10595796c8dcSSimon Schubert 			 : exp->elts[elt].objfile->name));
10605796c8dcSSimon Schubert       type_print (exp->elts[elt + 1].type, NULL, stream, 0);
10615796c8dcSSimon Schubert       fprintf_filtered (stream, ")");
10625796c8dcSSimon Schubert       elt = dump_subexp (exp, stream, elt + 3);
10635796c8dcSSimon Schubert       break;
10645796c8dcSSimon Schubert     case OP_TYPE:
10655796c8dcSSimon Schubert       fprintf_filtered (stream, "Type @");
10665796c8dcSSimon Schubert       gdb_print_host_address (exp->elts[elt].type, stream);
10675796c8dcSSimon Schubert       fprintf_filtered (stream, " (");
10685796c8dcSSimon Schubert       type_print (exp->elts[elt].type, NULL, stream, 0);
10695796c8dcSSimon Schubert       fprintf_filtered (stream, ")");
10705796c8dcSSimon Schubert       elt += 2;
10715796c8dcSSimon Schubert       break;
10725796c8dcSSimon Schubert     case STRUCTOP_STRUCT:
10735796c8dcSSimon Schubert     case STRUCTOP_PTR:
10745796c8dcSSimon Schubert       {
10755796c8dcSSimon Schubert 	char *elem_name;
10765796c8dcSSimon Schubert 	int len;
10775796c8dcSSimon Schubert 
10785796c8dcSSimon Schubert 	len = longest_to_int (exp->elts[elt].longconst);
10795796c8dcSSimon Schubert 	elem_name = &exp->elts[elt + 1].string;
10805796c8dcSSimon Schubert 
10815796c8dcSSimon Schubert 	fprintf_filtered (stream, "Element name: `%.*s'", len, elem_name);
10825796c8dcSSimon Schubert 	elt = dump_subexp (exp, stream, elt + 3 + BYTES_TO_EXP_ELEM (len + 1));
10835796c8dcSSimon Schubert       }
10845796c8dcSSimon Schubert       break;
10855796c8dcSSimon Schubert     case OP_SCOPE:
10865796c8dcSSimon Schubert       {
10875796c8dcSSimon Schubert 	char *elem_name;
10885796c8dcSSimon Schubert 	int len;
10895796c8dcSSimon Schubert 
10905796c8dcSSimon Schubert 	fprintf_filtered (stream, "Type @");
10915796c8dcSSimon Schubert 	gdb_print_host_address (exp->elts[elt].type, stream);
10925796c8dcSSimon Schubert 	fprintf_filtered (stream, " (");
10935796c8dcSSimon Schubert 	type_print (exp->elts[elt].type, NULL, stream, 0);
10945796c8dcSSimon Schubert 	fprintf_filtered (stream, ") ");
10955796c8dcSSimon Schubert 
10965796c8dcSSimon Schubert 	len = longest_to_int (exp->elts[elt + 1].longconst);
10975796c8dcSSimon Schubert 	elem_name = &exp->elts[elt + 2].string;
10985796c8dcSSimon Schubert 
10995796c8dcSSimon Schubert 	fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
11005796c8dcSSimon Schubert 	elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
11015796c8dcSSimon Schubert       }
11025796c8dcSSimon Schubert       break;
11035796c8dcSSimon Schubert     default:
11045796c8dcSSimon Schubert     case OP_NULL:
11055796c8dcSSimon Schubert     case MULTI_SUBSCRIPT:
11065796c8dcSSimon Schubert     case OP_F77_UNDETERMINED_ARGLIST:
11075796c8dcSSimon Schubert     case OP_COMPLEX:
11085796c8dcSSimon Schubert     case OP_STRING:
11095796c8dcSSimon Schubert     case OP_BITSTRING:
11105796c8dcSSimon Schubert     case OP_BOOL:
11115796c8dcSSimon Schubert     case OP_M2_STRING:
11125796c8dcSSimon Schubert     case OP_THIS:
11135796c8dcSSimon Schubert     case OP_LABELED:
11145796c8dcSSimon Schubert     case OP_NAME:
11155796c8dcSSimon Schubert       fprintf_filtered (stream, "Unknown format");
11165796c8dcSSimon Schubert     }
11175796c8dcSSimon Schubert 
11185796c8dcSSimon Schubert   return elt;
11195796c8dcSSimon Schubert }
11205796c8dcSSimon Schubert 
11215796c8dcSSimon Schubert void
11225796c8dcSSimon Schubert dump_prefix_expression (struct expression *exp, struct ui_file *stream)
11235796c8dcSSimon Schubert {
11245796c8dcSSimon Schubert   int elt;
11255796c8dcSSimon Schubert 
11265796c8dcSSimon Schubert   fprintf_filtered (stream, "Dump of expression @ ");
11275796c8dcSSimon Schubert   gdb_print_host_address (exp, stream);
11285796c8dcSSimon Schubert   fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
11295796c8dcSSimon Schubert   if (exp->elts[0].opcode != OP_TYPE)
11305796c8dcSSimon Schubert     print_expression (exp, stream);
11315796c8dcSSimon Schubert   else
11325796c8dcSSimon Schubert     fputs_filtered ("Type printing not yet supported....", stream);
11335796c8dcSSimon Schubert   fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
11345796c8dcSSimon Schubert 		    exp->language_defn->la_name, exp->nelts,
11355796c8dcSSimon Schubert 		    (long) sizeof (union exp_element));
11365796c8dcSSimon Schubert   fputs_filtered ("\n", stream);
11375796c8dcSSimon Schubert 
11385796c8dcSSimon Schubert   for (elt = 0; elt < exp->nelts;)
11395796c8dcSSimon Schubert     elt = dump_subexp (exp, stream, elt);
11405796c8dcSSimon Schubert   fputs_filtered ("\n", stream);
11415796c8dcSSimon Schubert }
1142