OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / tree-browser.c
index 1ac5dda..dab7286 100644 (file)
@@ -1,12 +1,13 @@
 /* Tree browser.
-   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2007, 2008, 2010
+   Free Software Foundation, Inc.
    Contributed by Sebastian Pop <s.pop@laposte.net>
 
 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) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,27 +16,20 @@ 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, 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 "errors.h"
 #include "tree.h"
-#include "tree-inline.h"
-#include "diagnostic.h"
-#include "hashtab.h"
-
+#include "tree-pretty-print.h"
 
 #define TB_OUT_FILE stdout
 #define TB_IN_FILE stdin
 #define TB_NIY fprintf (TB_OUT_FILE, "Sorry this command is not yet implemented.\n")
 #define TB_WF fprintf (TB_OUT_FILE, "Warning, this command failed.\n")
 
-
 /* Structures for handling Tree Browser's commands.  */
 #define DEFTBCODE(COMMAND, STRING, HELP)   COMMAND,
 enum TB_Comm_code {
@@ -53,11 +47,7 @@ struct tb_command {
 };
 
 #define DEFTBCODE(code, str, help) { help, str, sizeof(str) - 1, code },
-#ifdef HOST_EBCDIC
-static struct tb_command tb_commands[] =
-#else
 static const struct tb_command tb_commands[] =
-#endif
 {
 #include "tree-browser.def"
 };
@@ -77,15 +67,14 @@ struct tb_tree_code {
 };
 
 #define DEFTREECODE(SYM, STRING, TYPE, NARGS) { SYM, STRING, sizeof (STRING) - 1 },
-#ifdef HOST_EBCDIC
-static struct tb_tree_code tb_tree_codes[] =
-#else
+#define END_OF_BASE_TREE_CODES \
+  { LAST_AND_UNUSED_TREE_CODE, "@dummy", sizeof ("@dummy") - 1 },
 static const struct tb_tree_code tb_tree_codes[] =
-#endif
 {
-#include "tree.def"
+#include "all-tree.def"
 };
 #undef DEFTREECODE
+#undef END_OF_BASE_TREE_CODES
 
 #define TB_TREE_CODE(N) (tb_tree_codes[N].code)
 #define TB_TREE_CODE_TEXT(N) (tb_tree_codes[N].code_string)
@@ -114,7 +103,7 @@ void browse_tree (tree);
 
 /* Static variables.  */
 static htab_t TB_up_ht;
-static tree TB_history_stack = NULL_TREE;
+static VEC(tree,gc) *TB_history_stack;
 static int TB_verbose = 1;
 
 
@@ -132,7 +121,7 @@ browse_tree (tree begin)
   fprintf (TB_OUT_FILE, "\nTree Browser\n");
 
 #define TB_SET_HEAD(N) do {                                           \
-  TB_history_stack = tree_cons (NULL_TREE, (N), TB_history_stack);    \
+  VEC_safe_push (tree, gc, TB_history_stack, N);                      \
   head = N;                                                           \
   if (TB_verbose)                                                     \
     if (head)                                                         \
@@ -172,7 +161,8 @@ browse_tree (tree begin)
 
        case TB_MAX:
          if (head && (INTEGRAL_TYPE_P (head)
-                      || TREE_CODE (head) == REAL_TYPE))
+                      || TREE_CODE (head) == REAL_TYPE
+                      || TREE_CODE (head) == FIXED_POINT_TYPE))
            TB_SET_HEAD (TYPE_MAX_VALUE (head));
          else
            TB_WF;
@@ -180,7 +170,8 @@ browse_tree (tree begin)
 
        case TB_MIN:
          if (head && (INTEGRAL_TYPE_P (head)
-                      || TREE_CODE (head) == REAL_TYPE))
+                      || TREE_CODE (head) == REAL_TYPE
+                      || TREE_CODE (head) == FIXED_POINT_TYPE))
            TB_SET_HEAD (TYPE_MIN_VALUE (head));
          else
            TB_WF;
@@ -309,8 +300,7 @@ browse_tree (tree begin)
          break;
 
        case TB_DOMAIN:
-         if (head && (TREE_CODE (head) == ARRAY_TYPE
-                      || TREE_CODE (head) == SET_TYPE))
+         if (head && TREE_CODE (head) == ARRAY_TYPE)
            TB_SET_HEAD (TYPE_DOMAIN (head));
          else
            TB_WF;
@@ -323,13 +313,6 @@ browse_tree (tree begin)
            TB_WF;
          break;
 
-       case TB_ARG_TYPE_AS_WRITTEN:
-         if (head && TREE_CODE (head) == PARM_DECL)
-           TB_SET_HEAD (DECL_ARG_TYPE_AS_WRITTEN (head));
-         else
-           TB_WF;
-         break;
-
        case TB_ARG_TYPE:
          if (head && TREE_CODE (head) == PARM_DECL)
            TB_SET_HEAD (DECL_ARG_TYPE (head));
@@ -747,45 +730,16 @@ store_child_info (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
   node = *tp;
 
   /* 'node' is the parent of 'TREE_OPERAND (node, *)'.  */
-  if (EXPRESSION_CLASS_P (node))
+  if (EXPR_P (node))
     {
-
-#define STORE_CHILD(N) do {                                                \
-  tree op = TREE_OPERAND (node, N);                                        \
-  slot = htab_find_slot (TB_up_ht, op, INSERT);                               \
-  *slot = (void *) node;                                                   \
-} while (0)
-
-      switch (TREE_CODE_LENGTH (TREE_CODE (node)))
+      int n = TREE_OPERAND_LENGTH (node);
+      int i;
+      for (i = 0; i < n; i++)
        {
-       case 4:
-         STORE_CHILD (0);
-         STORE_CHILD (1);
-         STORE_CHILD (2);
-         STORE_CHILD (3);
-         break;
-
-       case 3:
-         STORE_CHILD (0);
-         STORE_CHILD (1);
-         STORE_CHILD (2);
-         break;
-
-       case 2:
-         STORE_CHILD (0);
-         STORE_CHILD (1);
-         break;
-
-       case 1:
-         STORE_CHILD (0);
-         break;
-
-       case 0:
-       default:
-         /* No children: nothing to do.  */
-         break;
+         tree op = TREE_OPERAND (node, i);
+         slot = htab_find_slot (TB_up_ht, op, INSERT);
+         *slot = (void *) node;
        }
-#undef STORE_CHILD
     }
 
   /* Never stop walk_tree.  */
@@ -797,53 +751,20 @@ store_child_info (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
 static int
 TB_parent_eq (const void *p1, const void *p2)
 {
-  tree node, parent;
-  node = (tree) p2;
-  parent = (tree) p1;
+  const_tree const node = (const_tree)p2;
+  const_tree const parent = (const_tree) p1;
 
   if (p1 == NULL || p2 == NULL)
     return 0;
 
-  if (EXPRESSION_CLASS_P (parent))
+  if (EXPR_P (parent))
     {
-
-#define TEST_CHILD(N) do {               \
-  if (node == TREE_OPERAND (parent, N))  \
-    return 1;                            \
-} while (0)
-
-    switch (TREE_CODE_LENGTH (TREE_CODE (parent)))
-      {
-      case 4:
-       TEST_CHILD (0);
-       TEST_CHILD (1);
-       TEST_CHILD (2);
-       TEST_CHILD (3);
-       break;
-
-      case 3:
-       TEST_CHILD (0);
-       TEST_CHILD (1);
-       TEST_CHILD (2);
-       break;
-
-      case 2:
-       TEST_CHILD (0);
-       TEST_CHILD (1);
-       break;
-
-      case 1:
-       TEST_CHILD (0);
-       break;
-
-      case 0:
-      default:
-       /* No children: nothing to do.  */
-       break;
-      }
-#undef TEST_CHILD
+      int n = TREE_OPERAND_LENGTH (parent);
+      int i;
+      for (i = 0; i < n; i++)
+       if (node == TREE_OPERAND (parent, i))
+         return 1;
     }
-
   return 0;
 }
 
@@ -950,11 +871,11 @@ find_node_with_code (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
 static tree
 TB_history_prev (void)
 {
-  if (TB_history_stack)
+  if (!VEC_empty (tree, TB_history_stack))
     {
-      TB_history_stack = TREE_CHAIN (TB_history_stack);
-      if (TB_history_stack)
-       return TREE_VALUE (TB_history_stack);
+      tree last = VEC_last (tree, TB_history_stack);
+      VEC_pop (tree, TB_history_stack);
+      return last;
     }
   return NULL_TREE;
 }