OSDN Git Service

2008-01-15 Douglas Gregor <doug.gregor@gmail.com>
[pf3gnuchains/gcc-fork.git] / gcc / cp / dump.c
index ed4ecb4..a0f03e8 100644 (file)
@@ -1,5 +1,5 @@
 /* Tree-dumping functionality for intermediate representation.
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
    Free Software Foundation, Inc.
    Written by Mark Mitchell <mark@codesourcery.com>
 
@@ -7,7 +7,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GCC is distributed in the hope that it will be useful,
@@ -16,9 +16,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -39,11 +38,11 @@ static void
 dump_access (dump_info_p di, tree t)
 {
   if (TREE_PROTECTED(t))
-    dump_string (di, "protected");
+    dump_string_field (di, "accs", "prot");
   else if (TREE_PRIVATE(t))
-    dump_string (di, "private");
+    dump_string_field (di, "accs", "priv");
   else
-    dump_string (di, "public");
+    dump_string_field (di, "accs", "pub");
 }
 
 /* Dump a representation of the specific operator for an overloaded
@@ -215,7 +214,7 @@ cp_dump_tree (void* dump_info, tree t)
   if (DECL_P (t))
     {
       if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
-       dump_string (di, language_to_string (DECL_LANGUAGE (t)));
+       dump_string_field (di, "lang", language_to_string (DECL_LANGUAGE (t)));
     }
 
   switch (code)
@@ -223,7 +222,7 @@ cp_dump_tree (void* dump_info, tree t)
     case IDENTIFIER_NODE:
       if (IDENTIFIER_OPNAME_P (t))
        {
-         dump_string (di, "operator");
+         dump_string_field (di, "note", "operator");
          return true;
        }
       else if (IDENTIFIER_TYPENAME_P (t))
@@ -234,7 +233,7 @@ cp_dump_tree (void* dump_info, tree t)
       break;
 
     case OFFSET_TYPE:
-      dump_string (di, "ptrmem");
+      dump_string_field (di, "note", "ptrmem");
       dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
       dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
       return true;
@@ -242,7 +241,7 @@ cp_dump_tree (void* dump_info, tree t)
     case RECORD_TYPE:
       if (TYPE_PTRMEMFUNC_P (t))
        {
-         dump_string (di, "ptrmem");
+         dump_string_field (di, "note", "ptrmem");
          dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
          dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
          return true;
@@ -276,7 +275,7 @@ cp_dump_tree (void* dump_info, tree t)
            {
              dump_child ("base", BINFO_TYPE (base_binfo));
              if (BINFO_VIRTUAL_P (base_binfo))
-               dump_string (di, "virtual");
+               dump_string_field (di, "spec", "virt");
              dump_access (di, base_binfo);
            }
        }
@@ -285,55 +284,55 @@ cp_dump_tree (void* dump_info, tree t)
     case FIELD_DECL:
       dump_access (di, t);
       if (DECL_MUTABLE_P (t))
-       dump_string(di, "mutable");
+       dump_string_field (di, "spec", "mutable");
       break;
 
     case VAR_DECL:
       if (TREE_CODE (CP_DECL_CONTEXT (t)) == RECORD_TYPE)
        dump_access (di, t);
       if (TREE_STATIC (t) && !TREE_PUBLIC (t))
-       dump_string (di, "static");
+       dump_string_field (di, "link", "static");
       break;
 
     case FUNCTION_DECL:
       if (!DECL_THUNK_P (t))
        {
          if (DECL_OVERLOADED_OPERATOR_P (t)) {
-           dump_string (di, "operator");
+           dump_string_field (di, "note", "operator");
            dump_op (di, t);
          }
          if (DECL_FUNCTION_MEMBER_P (t))
            {
-             dump_string (di, "member");
+             dump_string_field (di, "note", "member");
              dump_access (di, t);
            }
          if (DECL_PURE_VIRTUAL_P (t))
-           dump_string (di, "pure");
+           dump_string_field (di, "spec", "pure");
          if (DECL_VIRTUAL_P (t))
-           dump_string (di, "virtual");
+           dump_string_field (di, "spec", "virt");
          if (DECL_CONSTRUCTOR_P (t))
-           dump_string (di, "constructor");
+           dump_string_field (di, "note", "constructor");
          if (DECL_DESTRUCTOR_P (t))
-           dump_string (di, "destructor");
+           dump_string_field (di, "note", "destructor");
          if (DECL_CONV_FN_P (t))
-           dump_string (di, "conversion");
+           dump_string_field (di, "note", "conversion");
          if (DECL_GLOBAL_CTOR_P (t))
-           dump_string (di, "global init");
+           dump_string_field (di, "note", "global init");
          if (DECL_GLOBAL_DTOR_P (t))
-           dump_string (di, "global fini");
+           dump_string_field (di, "note", "global fini");
          if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t))
-           dump_string (di, "pseudo tmpl");
+           dump_string_field (di, "note", "pseudo tmpl");
        }
       else
        {
          tree virt = THUNK_VIRTUAL_OFFSET (t);
 
-         dump_string (di, "thunk");
+         dump_string_field (di, "note", "thunk");
          if (DECL_THIS_THUNK_P (t))
-           dump_string (di, "this adjusting");
+           dump_string_field (di, "note", "this adjusting");
          else
            {
-             dump_string (di, "result adjusting");
+             dump_string_field (di, "note", "result adjusting");
              if (virt)
                virt = BINFO_VPTR_FIELD (virt);
            }
@@ -366,7 +365,7 @@ cp_dump_tree (void* dump_info, tree t)
     case TRY_BLOCK:
       dump_stmt (di, t);
       if (CLEANUP_P (t))
-       dump_string (di, "cleanup");
+       dump_string_field (di, "note", "cleanup");
       dump_child ("body", TRY_STMTS (t));
       dump_child ("hdlr", TRY_HANDLERS (t));
       break;
@@ -388,10 +387,21 @@ cp_dump_tree (void* dump_info, tree t)
       break;
 
     case AGGR_INIT_EXPR:
-      dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t));
-      dump_child ("fn", TREE_OPERAND (t, 0));
-      dump_child ("args", TREE_OPERAND (t, 1));
-      dump_child ("decl", TREE_OPERAND (t, 2));
+      {
+       int i = 0;
+       tree arg;
+       aggr_init_expr_arg_iterator iter;
+       dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t));
+       dump_child ("fn", AGGR_INIT_EXPR_FN (t));
+       FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t)
+         {
+           char buffer[32];
+           sprintf (buffer, "%u", i);
+           dump_child (buffer, arg);
+           i++;
+         }
+       dump_child ("decl", AGGR_INIT_EXPR_SLOT (t));
+      }
       break;
 
     case HANDLER: