OSDN Git Service

* typeck.c: Change copyright header to refer to version 3 of the GNU General
[pf3gnuchains/gcc-fork.git] / gcc / cp / ptree.c
index aa3066c..c91cb15 100644 (file)
 /* Prints out trees in human readable form.
-   Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998,
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
+   Free Software Foundation, Inc.
    Hacked by Michael Tiemann (tiemann@cygnus.com)
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
+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.
 
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 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 GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 
 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "tree.h"
 #include "cp-tree.h"
 
 void
-print_lang_decl (file, node, indent)
-     FILE *file;
-     tree node;
-     int indent;
+cxx_print_decl (FILE *file, tree node, int indent)
 {
-  if (!DECL_LANG_SPECIFIC (node))
-    return;
-  /* A FIELD_DECL only has the flags structure, which we aren't displaying
-     anyways.  */
-  if (DECL_MUTABLE_P (node))
+  if (TREE_CODE (node) == FIELD_DECL)
     {
-      indent_to (file, indent + 3);
-      fprintf (file, " mutable ");
+      if (DECL_MUTABLE_P (node))
+       {
+         indent_to (file, indent + 3);
+         fprintf (file, " mutable ");
+       }
+      return;
     }
-  if (TREE_CODE (node) == FIELD_DECL)
+
+  if (!CODE_CONTAINS_STRUCT (TREE_CODE (node), TS_DECL_COMMON)
+      || !DECL_LANG_SPECIFIC (node))
     return;
   indent_to (file, indent + 3);
-  if (DECL_MAIN_VARIANT (node))
-    {
-      fprintf (file, " decl-main-variant ");
-      fprintf (file, HOST_PTR_PRINTF, DECL_MAIN_VARIANT (node));
-    }
-  if (DECL_PENDING_INLINE_INFO (node))
-    {
-      fprintf (file, " pending-inline-info ");
-      fprintf (file, HOST_PTR_PRINTF, DECL_PENDING_INLINE_INFO (node));
-    }
-  if (DECL_TEMPLATE_INFO (node))
-    {
-      fprintf (file, " template-info ");
-      fprintf (file, HOST_PTR_PRINTF,  DECL_TEMPLATE_INFO (node));
-    }
+  if (TREE_CODE (node) == FUNCTION_DECL
+      && DECL_PENDING_INLINE_INFO (node))
+    fprintf (file, " pending-inline-info %p",
+            (void *) DECL_PENDING_INLINE_INFO (node));
+  if (TREE_CODE (node) == TYPE_DECL
+      && DECL_SORTED_FIELDS (node))
+    fprintf (file, " sorted-fields %p",
+            (void *) DECL_SORTED_FIELDS (node));
+  if ((TREE_CODE (node) == FUNCTION_DECL || TREE_CODE (node) == VAR_DECL)
+      && DECL_TEMPLATE_INFO (node))
+    fprintf (file, " template-info %p",
+            (void *) DECL_TEMPLATE_INFO (node));
 }
 
 void
-print_lang_type (file, node, indent)
-     FILE *file;
-     register tree node;
-     int indent;
+cxx_print_type (FILE *file, tree node, int indent)
 {
-  if (TREE_CODE (node) == TEMPLATE_TYPE_PARM
-      || TREE_CODE (node) == TEMPLATE_TEMPLATE_PARM)
+  switch (TREE_CODE (node))
     {
+    case TEMPLATE_TYPE_PARM:
+    case TEMPLATE_TEMPLATE_PARM:
+    case BOUND_TEMPLATE_TEMPLATE_PARM:
       indent_to (file, indent + 3);
-      fputs ("index ", file);
-      fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_IDX (node));
-      fputs (" level ", file);
-      fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_LEVEL (node));
-      fputs (" orig_level ", file);
-      fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_ORIG_LEVEL (node));
+      fprintf (file, "index %d level %d orig_level %d",
+              TEMPLATE_TYPE_IDX (node), TEMPLATE_TYPE_LEVEL (node),
+              TEMPLATE_TYPE_ORIG_LEVEL (node));
+      return;
+
+    case FUNCTION_TYPE:
+    case METHOD_TYPE:
+      if (TYPE_RAISES_EXCEPTIONS (node))
+       print_node (file, "throws", TYPE_RAISES_EXCEPTIONS (node), indent + 4);
+      return;
+
+    case RECORD_TYPE:
+    case UNION_TYPE:
+      break;
+
+    default:
       return;
     }
 
-  if (! (TREE_CODE (node) == RECORD_TYPE
-        || TREE_CODE (node) == UNION_TYPE))
-    return;
+  if (TYPE_PTRMEMFUNC_P (node))
+    print_node (file, "ptrmemfunc fn type", TYPE_PTRMEMFUNC_FN_TYPE (node),
+               indent + 4);
 
-  if (!TYPE_LANG_SPECIFIC (node))
+  if (! CLASS_TYPE_P (node))
     return;
 
   indent_to (file, indent + 3);
 
   if (TYPE_NEEDS_CONSTRUCTING (node))
     fputs ( "needs-constructor", file);
-  if (TYPE_NEEDS_DESTRUCTOR (node))
+  if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (node))
     fputs (" needs-destructor", file);
-  if (TYPE_HAS_DESTRUCTOR (node))
-    fputs (" ~X()", file);
   if (TYPE_HAS_DEFAULT_CONSTRUCTOR (node))
     fputs (" X()", file);
   if (TYPE_HAS_CONVERSION (node))
@@ -105,72 +111,68 @@ print_lang_type (file, node, indent)
       else
        fputs (" X(X&)", file);
     }
-  if (TYPE_GETS_NEW (node) & 1)
+  if (TYPE_HAS_NEW_OPERATOR (node))
     fputs (" new", file);
-  if (TYPE_GETS_NEW (node) & 2)
+  if (TYPE_HAS_ARRAY_NEW_OPERATOR (node))
     fputs (" new[]", file);
   if (TYPE_GETS_DELETE (node) & 1)
     fputs (" delete", file);
   if (TYPE_GETS_DELETE (node) & 2)
     fputs (" delete[]", file);
-  if (TYPE_HAS_ASSIGNMENT (node))
-    fputs (" has=", file);
   if (TYPE_HAS_ASSIGN_REF (node))
     fputs (" this=(X&)", file);
-  if (TYPE_OVERLOADS_CALL_EXPR (node))
-    fputs (" op()", file);
-  if (TYPE_OVERLOADS_ARRAY_REF (node))
-    fputs (" op[]", file);
-  if (TYPE_OVERLOADS_ARROW (node))
-    fputs (" op->", file);
-  if (TYPE_USES_MULTIPLE_INHERITANCE (node))
-    fputs (" uses-multiple-inheritance", file);
 
   if (TREE_CODE (node) == RECORD_TYPE)
     {
-      fprintf (file, " n_parents %d n_ancestors %d",
-              CLASSTYPE_N_BASECLASSES (node),
-              CLASSTYPE_N_SUPERCLASSES (node));
+      if (TYPE_BINFO (node))
+       fprintf (file, " n_parents=%d",
+                BINFO_N_BASE_BINFOS (TYPE_BINFO (node)));
+      else
+       fprintf (file, " no-binfo");
+
       fprintf (file, " use_template=%d", CLASSTYPE_USE_TEMPLATE (node));
       if (CLASSTYPE_INTERFACE_ONLY (node))
        fprintf (file, " interface-only");
       if (CLASSTYPE_INTERFACE_UNKNOWN (node))
        fprintf (file, " interface-unknown");
-      print_node (file, "member-functions", CLASSTYPE_METHOD_VEC (node),
-                 indent + 4);
-      print_node (file, "baselinks",
-                 TYPE_BINFO_BASETYPES (node) ? CLASSTYPE_BASELINK_VEC (node) : NULL_TREE,
-                 indent + 4);
     }
 }
 
+
+static void
+cxx_print_binding (FILE *stream, cxx_binding *binding, const char *prefix)
+{
+  fprintf (stream, "%s <%p>",
+          prefix, (void *) binding);
+}
+
 void
-print_lang_identifier (file, node, indent)
-     FILE *file;
-     tree node;
-     int indent;
+cxx_print_identifier (FILE *file, tree node, int indent)
 {
-  print_node (file, "bindings", IDENTIFIER_NAMESPACE_BINDINGS (node), indent + 4);
-  print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
-  print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
+  if (indent == 0)
+    fprintf (file, " ");
+  else
+    indent_to (file, indent);
+  cxx_print_binding (file, IDENTIFIER_NAMESPACE_BINDINGS (node), "bindings");
+  if (indent == 0)
+    fprintf (file, " ");
+  else
+    indent_to (file, indent);
+  cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings");
   print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
   print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4);
-  print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
-  print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
 }
 
 void
-lang_print_xnode (file, node, indent)
-     FILE *file;
-     tree node;
-     int indent;
+cxx_print_xnode (FILE *file, tree node, int indent)
 {
   switch (TREE_CODE (node))
     {
-    case CPLUS_BINDING:
-      print_node (file, "scope", BINDING_SCOPE (node), indent+4);
-      print_node (file, "value", BINDING_VALUE (node), indent+4);
-      print_node (file, "chain", TREE_CHAIN (node), indent+4);
+    case BASELINK:
+      print_node (file, "functions", BASELINK_FUNCTIONS (node), indent + 4);
+      print_node (file, "binfo", BASELINK_BINFO (node), indent + 4);
+      print_node (file, "access_binfo", BASELINK_ACCESS_BINFO (node),
+                 indent + 4);
       break;
     case OVERLOAD:
       print_node (file, "function", OVL_FUNCTION (node), indent+4);
@@ -178,12 +180,9 @@ lang_print_xnode (file, node, indent)
       break;
     case TEMPLATE_PARM_INDEX:
       indent_to (file, indent + 3);
-      fputs ("index ", file);
-      fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_IDX (node));
-      fputs (" level ", file);
-      fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_LEVEL (node));
-      fputs (" orig_level ", file);
-      fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_ORIG_LEVEL (node));
+      fprintf (file, "index %d level %d orig_level %d",
+              TEMPLATE_PARM_IDX (node), TEMPLATE_PARM_LEVEL (node),
+              TEMPLATE_PARM_ORIG_LEVEL (node));
       break;
     default:
       break;