* vax-tdep.c (INVALID_FLOAT, MAXLEN, NOPCODES): Don't define.
[deliverable/binutils-gdb.git] / gdb / expprint.c
index 8c0fe4f736fdf83663554ef56fdbf6ecb85559ac..d0e940b3821c25c960c56360009ef3889c7cad23 100644 (file)
@@ -1,5 +1,7 @@
 /* Print in infix form a struct expression.
-   Copyright (C) 1986, 1989, 1991, 2000 Free Software Foundation, Inc.
+
+   Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "value.h"
 #include "language.h"
 #include "parser-defs.h"
+#include "frame.h"             /* For frame_map_regnum_to_name.  */
+#include "target.h"
+#include "gdb_string.h"
+#include "block.h"
 
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
@@ -36,9 +42,7 @@ static void print_subexp (struct expression *, int *, struct ui_file *,
                          enum precedence);
 
 void
-print_expression (exp, stream)
-     struct expression *exp;
-     struct ui_file *stream;
+print_expression (struct expression *exp, struct ui_file *stream)
 {
   int pc = 0;
   print_subexp (exp, &pc, stream, PREC_NULL);
@@ -50,11 +54,8 @@ print_expression (exp, stream)
    parentheses are needed here.  */
 
 static void
-print_subexp (exp, pos, stream, prec)
-     register struct expression *exp;
-     register int *pos;
-     struct ui_file *stream;
-     enum precedence prec;
+print_subexp (register struct expression *exp, register int *pos,
+             struct ui_file *stream, enum precedence prec)
 {
   register unsigned tem;
   register const struct op_print *op_print_tab;
@@ -66,7 +67,7 @@ print_subexp (exp, pos, stream, prec)
   enum precedence myprec = PREC_NULL;
   /* Set to 1 for a right-associative operator.  */
   int assoc = 0;
-  value_ptr val;
+  struct value *val;
   char *tempstr = NULL;
 
   op_print_tab = exp->language_defn->la_op_print_tab;
@@ -107,12 +108,12 @@ print_subexp (exp, pos, stream, prec)
        b = exp->elts[pc + 1].block;
        if (b != NULL
            && BLOCK_FUNCTION (b) != NULL
-           && SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b)) != NULL)
+           && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL)
          {
-           fputs_filtered (SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b)), stream);
+           fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream);
            fputs_filtered ("::", stream);
          }
-       fputs_filtered (SYMBOL_SOURCE_NAME (exp->elts[pc + 2].symbol), stream);
+       fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream);
       }
       return;
 
@@ -123,10 +124,12 @@ print_subexp (exp, pos, stream, prec)
       return;
 
     case OP_REGISTER:
-      (*pos) += 2;
-      fprintf_filtered (stream, "$%s",
-             REGISTER_NAME (longest_to_int (exp->elts[pc + 1].longconst)));
-      return;
+      {
+       int regnum = longest_to_int (exp->elts[pc + 1].longconst);
+       (*pos) += 2;
+       fprintf_filtered (stream, "$%s", frame_map_regnum_to_name (regnum));
+       return;
+      }
 
     case OP_BOOL:
       (*pos) += 2;
@@ -178,6 +181,51 @@ print_subexp (exp, pos, stream, prec)
       fprintf_unfiltered (stream, "B'<unimplemented>'");
       return;
 
+    case OP_OBJC_NSSTRING:     /* Objective-C Foundation Class NSString constant.  */
+      nargs = longest_to_int (exp->elts[pc + 1].longconst);
+      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+      fputs_filtered ("@\"", stream);
+      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+      fputs_filtered ("\"", stream);
+      return;
+
+    case OP_OBJC_MSGCALL:
+      {                        /* Objective C message (method) call.  */
+       char *selector;
+       (*pos) += 3;
+       nargs = longest_to_int (exp->elts[pc + 2].longconst);
+       fprintf_unfiltered (stream, "[");
+       print_subexp (exp, pos, stream, PREC_SUFFIX);
+       if (0 == target_read_string (exp->elts[pc + 1].longconst,
+                                    &selector, 1024, NULL))
+         {
+           error ("bad selector");
+           return;
+         }
+       if (nargs)
+         {
+           char *s, *nextS;
+           s = alloca (strlen (selector) + 1);
+           strcpy (s, selector);
+           for (tem = 0; tem < nargs; tem++)
+             {
+               nextS = strchr (s, ':');
+               *nextS = '\0';
+               fprintf_unfiltered (stream, " %s: ", s);
+               s = nextS + 1;
+               print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
+             }
+         }
+       else
+         {
+           fprintf_unfiltered (stream, " %s", selector);
+         }
+       fprintf_unfiltered (stream, "]");
+       /* "selector" was malloc'd by target_read_string. Free it.  */
+       xfree (selector);
+       return;
+      }
+
     case OP_ARRAY:
       (*pos) += 3;
       nargs = longest_to_int (exp->elts[pc + 2].longconst);
@@ -221,8 +269,7 @@ print_subexp (exp, pos, stream, prec)
        }
       else
        {
-         int is_chill = exp->language_defn->la_language == language_chill;
-         fputs_filtered (is_chill ? " [" : " {", stream);
+         fputs_filtered (" {", stream);
          for (tem = 0; tem < nargs; tem++)
            {
              if (tem != 0)
@@ -231,34 +278,22 @@ print_subexp (exp, pos, stream, prec)
                }
              print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
            }
-         fputs_filtered (is_chill ? "]" : "}", stream);
+         fputs_filtered ("}", stream);
        }
       return;
 
     case OP_LABELED:
       tem = longest_to_int (exp->elts[pc + 1].longconst);
       (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
-
-      if (exp->language_defn->la_language == language_chill)
-       {
-         fputs_filtered (".", stream);
-         fputs_filtered (&exp->elts[pc + 2].string, stream);
-         fputs_filtered (exp->elts[*pos].opcode == OP_LABELED ? ", "
-                         : ": ",
-                         stream);
-       }
-      else
-       {
-         /* Gcc support both these syntaxes.  Unsure which is preferred.  */
+      /* Gcc support both these syntaxes.  Unsure which is preferred.  */
 #if 1
-         fputs_filtered (&exp->elts[pc + 2].string, stream);
-         fputs_filtered (": ", stream);
+      fputs_filtered (&exp->elts[pc + 2].string, stream);
+      fputs_filtered (": ", stream);
 #else
-         fputs_filtered (".", stream);
-         fputs_filtered (&exp->elts[pc + 2].string, stream);
-         fputs_filtered ("=", stream);
+      fputs_filtered (".", stream);
+      fputs_filtered (&exp->elts[pc + 2].string, stream);
+      fputs_filtered ("=", stream);
 #endif
-       }
       print_subexp (exp, pos, stream, PREC_SUFFIX);
       return;
 
@@ -338,7 +373,7 @@ print_subexp (exp, pos, stream, prec)
       (*pos) += 2;
       if ((int) prec > (int) PREC_PREFIX)
        fputs_filtered ("(", stream);
-      if (exp->elts[pc + 1].type->code == TYPE_CODE_FUNC &&
+      if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
          exp->elts[pc + 3].opcode == OP_LONG)
        {
          /* We have a minimal symbol fn, probably.  It's encoded
@@ -388,6 +423,13 @@ print_subexp (exp, pos, stream, prec)
       fputs_filtered ("this", stream);
       return;
 
+      /* Objective-C ops */
+
+    case OP_OBJC_SELF:
+      ++(*pos);
+      fputs_filtered ("self", stream); /* The ObjC equivalent of "this".  */
+      return;
+
       /* Modula-2 ops */
 
     case MULTI_SUBSCRIPT:
@@ -488,8 +530,7 @@ print_subexp (exp, pos, stream, prec)
    a string.   NULL indicates that the opcode was not found in the
    current language table.  */
 char *
-op_string (op)
-     enum exp_opcode op;
+op_string (enum exp_opcode op)
 {
   int tem;
   register const struct op_print *op_print_tab;
@@ -504,11 +545,10 @@ op_string (op)
 /* Support for dumping the raw data from expressions in a human readable
    form.  */
 
-static char *op_name PARAMS ((int opcode));
+static char *op_name (int opcode);
 
 static char *
-op_name (opcode)
-     int opcode;
+op_name (int opcode)
 {
   switch (opcode)
     {
@@ -683,6 +723,8 @@ op_name (opcode)
       return "STRUCTOP_PTR";
     case OP_THIS:
       return "OP_THIS";
+    case OP_OBJC_SELF:
+      return "OP_OBJC_SELF";
     case OP_SCOPE:
       return "OP_SCOPE";
     case OP_TYPE:
@@ -693,10 +735,8 @@ op_name (opcode)
 }
 
 void
-dump_prefix_expression (exp, stream, note)
-     struct expression *exp;
-     struct ui_file *stream;
-     char *note;
+dump_prefix_expression (struct expression *exp, struct ui_file *stream,
+                       char *note)
 {
   int elt;
   char *opcode_name;
@@ -710,9 +750,9 @@ dump_prefix_expression (exp, stream, note)
     print_expression (exp, stream);
   else
     fprintf_filtered (stream, "Type printing not yet supported....");
-  fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %d bytes each.\n",
+  fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
                    exp->language_defn->la_name, exp->nelts,
-                   sizeof (union exp_element));
+                   (long) sizeof (union exp_element));
   fprintf_filtered (stream, "\t%5s  %20s  %16s  %s\n", "Index", "Opcode",
                    "Hex Value", "String Value");
   for (elt = 0; elt < exp->nelts; elt++)
@@ -736,13 +776,11 @@ dump_prefix_expression (exp, stream, note)
     }
 }
 
-static int dump_subexp PARAMS ((struct expression * exp, struct ui_file * stream, int elt));
+static int dump_subexp (struct expression *exp, struct ui_file *stream,
+                       int elt);
 
 static int
-dump_subexp (exp, stream, elt)
-     struct expression *exp;
-     struct ui_file *stream;
-     int elt;
+dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
 {
   static int indent = 0;
   int i;
@@ -852,7 +890,7 @@ dump_subexp (exp, stream, elt)
       fprintf_filtered (stream, ", symbol @");
       gdb_print_host_address (exp->elts[elt + 1].symbol, stream);
       fprintf_filtered (stream, " (%s)",
-                       SYMBOL_NAME (exp->elts[elt + 1].symbol));
+                       DEPRECATED_SYMBOL_NAME (exp->elts[elt + 1].symbol));
       elt += 3;
       break;
     case OP_LAST:
@@ -972,10 +1010,8 @@ dump_subexp (exp, stream, elt)
 }
 
 void
-dump_postfix_expression (exp, stream, note)
-     struct expression *exp;
-     struct ui_file *stream;
-     char *note;
+dump_postfix_expression (struct expression *exp, struct ui_file *stream,
+                        char *note)
 {
   int elt;
 
@@ -986,9 +1022,9 @@ dump_postfix_expression (exp, stream, note)
     print_expression (exp, stream);
   else
     fputs_filtered ("Type printing not yet supported....", stream);
-  fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %d bytes each.\n",
+  fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
                    exp->language_defn->la_name, exp->nelts,
-                   sizeof (union exp_element));
+                   (long) sizeof (union exp_element));
   fputs_filtered ("\n", stream);
 
   for (elt = 0; elt < exp->nelts;)
This page took 0.02722 seconds and 4 git commands to generate.