removed warnings
[libfirm] / ir / tr / typewalk.c
index f1b3bcb..bd8e83f 100644 (file)
@@ -1,12 +1,12 @@
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Author: Goetz Lindenmaier
-**
-** traverse the type information.  The walker walks the whole ir graph
-** to find the distinct type trees in the type graph forest.
-** - execute the pre function before recursion
-** - execute the post function after recursion
+* All rights reserved.
+*
+* Author: Goetz Lindenmaier
+*
+* traverse the type information.  The walker walks the whole ir graph
+* to find the distinct type trees in the type graph forest.
+* - execute the pre function before recursion
+* - execute the post function after recursion
 */
 
 /* $Id$ */
@@ -35,9 +35,9 @@ typedef struct type_walk_env {
 } type_walk_env;
 
 
-void type_walk_2(type_or_ent *tore,
-              void (pre)(type_or_ent*, void*),
-              void (post)(type_or_ent*, void*),
+static void type_walk_2(type_or_ent *tore,
+              void (*pre)(type_or_ent*, void*),
+              void (*post)(type_or_ent*, void*),
               void *env)
 {
   int i;
@@ -80,17 +80,17 @@ void type_walk_2(type_or_ent *tore,
       switch (get_type_tpop_code(tp)) {
       case tpo_class:
        {
-         for (i=0; i<get_class_n_supertype(tp); i++)
+         for (i=0; i<get_class_n_supertypes(tp); i++)
            type_walk_2((type_or_ent *)get_class_supertype(tp, i), pre, post, env);
-         for (i=0; i<get_class_n_member(tp); i++)
+         for (i=0; i<get_class_n_members(tp); i++)
            type_walk_2((type_or_ent *)get_class_member(tp, i), pre, post, env);
-         for (i=0; i<get_class_n_subtype(tp); i++)
+         for (i=0; i<get_class_n_subtypes(tp); i++)
            type_walk_2((type_or_ent *)get_class_subtype(tp, i), pre, post, env);
        }
        break;
       case tpo_struct:
        {
-         for (i=0; i<get_struct_n_member(tp); i++)
+         for (i=0; i<get_struct_n_members(tp); i++)
            type_walk_2((type_or_ent *)get_struct_member(tp, i), pre, post, env);
        }
        break;
@@ -98,7 +98,7 @@ void type_walk_2(type_or_ent *tore,
        {
          for (i = 0; i < get_method_n_params(tp); i++)
            type_walk_2((type_or_ent *)get_method_param_type(tp, i), pre, post, env);
-         for (i = 0; i < get_method_n_res(tp); i++)
+         for (i = 0; i < get_method_n_ress(tp); i++)
            type_walk_2((type_or_ent *)get_method_res_type(tp, i), pre, post, env);
        }
        break;
@@ -142,7 +142,7 @@ void type_walk_2(type_or_ent *tore,
   return;
 }
 
-void start_type_walk(ir_node *node, void *env) {
+static void start_type_walk(ir_node *node, void *env) {
   void *pre  = ((type_walk_env *)env)->pre;
   void *post = ((type_walk_env *)env)->post;
   void *envi = ((type_walk_env *)env)->env;
@@ -182,6 +182,7 @@ void type_walk(void (pre)(type_or_ent*, void*),
   for (i = 0; i < get_irp_n_types(); i++) {
     type_walk_2((type_or_ent *)get_irp_type(i), pre, post, env);
   }
+  type_walk_2((type_or_ent *)get_glob_type(), pre, post, env);
 }
 
 void type_walk_irg (ir_graph *irg,
@@ -206,10 +207,10 @@ void type_walk_irg (ir_graph *irg,
   return;
 }
 
-void type_walk_s2s_2(type_or_ent *tore,
-                    void (pre)(type_or_ent*, void*),
-                    void (post)(type_or_ent*, void*),
-                    void *env)
+static void type_walk_s2s_2(type_or_ent *tore,
+                           void (*pre)(type_or_ent*, void*),
+                           void (*post)(type_or_ent*, void*),
+                           void *env)
 {
   int i;
 
@@ -238,7 +239,7 @@ void type_walk_s2s_2(type_or_ent *tore,
       switch (get_type_tpop_code(tp)) {
       case tpo_class:
        {
-         for (i = 0; i < get_class_n_supertype(tp); i++) {
+         for (i = 0; i < get_class_n_supertypes(tp); i++) {
            type_walk_s2s_2((type_or_ent *)get_class_supertype(tp, i), pre,
                            post, env);
          }
@@ -247,7 +248,7 @@ void type_walk_s2s_2(type_or_ent *tore,
            pre(tore, env);
          tp = skip_tid((type*)tore);
 
-         for (i = 0; i < get_class_n_subtype(tp); i++) {
+         for (i = 0; i < get_class_n_subtypes(tp); i++) {
            type_walk_s2s_2((type_or_ent *)get_class_subtype(tp, i), pre,
                            post, env);
          }
@@ -282,9 +283,11 @@ void type_walk_s2s_2(type_or_ent *tore,
   return;
 }
 
-void type_walk_super2sub(void (pre)(type_or_ent*, void*),
-                        void (post)(type_or_ent*, void*),
-                        void *env) {
+void type_walk_super2sub(
+                 void (*pre)(type_or_ent*, void*),
+                 void (*post)(type_or_ent*, void*),
+                 void *env)
+{
   int i;
   type *tp;
   ++type_visited;
@@ -297,11 +300,11 @@ void type_walk_super2sub(void (pre)(type_or_ent*, void*),
 
 /*****************************************************************************/
 
-static
-void type_walk_super_2(type_or_ent *tore,
-                      void (pre)(type_or_ent*, void*),
-                      void (post)(type_or_ent*, void*),
-                      void *env)
+static void
+type_walk_super_2(type_or_ent *tore,
+                 void (*pre)(type_or_ent*, void*),
+                 void (*post)(type_or_ent*, void*),
+                 void *env)
 {
   int i;
 
@@ -335,7 +338,7 @@ void type_walk_super_2(type_or_ent *tore,
            pre(tore, env);
          tp = skip_tid((type*)tore);
 
-         for (i = 0; i < get_class_n_supertype(tp); i++) {
+         for (i = 0; i < get_class_n_supertypes(tp); i++) {
            type_walk_super_2((type_or_ent *)get_class_supertype(tp, i), pre,
                              post, env);
          }
@@ -370,9 +373,10 @@ void type_walk_super_2(type_or_ent *tore,
   return;
 }
 
-void type_walk_super(void (pre)(type_or_ent*, void*),
-                    void (post)(type_or_ent*, void*),
-                    void *env) {
+void type_walk_super(
+                 void (*pre)(type_or_ent*, void*),
+                 void (*post)(type_or_ent*, void*),
+                 void *env) {
   int i;
   type *tp;
   ++type_visited;
@@ -386,10 +390,11 @@ void type_walk_super(void (pre)(type_or_ent*, void*),
 /*****************************************************************************/
 
 
-void class_walk_s2s_2(type *tp,
-                    void (pre)(type*, void*),
-                    void (post)(type*, void*),
-                    void *env)
+static void
+class_walk_s2s_2(type *tp,
+                void (*pre)(type*, void*),
+                void (*post)(type*, void*),
+                void *env)
 {
   int i;
 
@@ -398,7 +403,7 @@ void class_walk_s2s_2(type *tp,
 
   assert(is_class_type(tp));
   /* Assure all supertypes are visited before */
-  for (i=0; i < get_class_n_supertype(tp); i++) {
+  for (i=0; i < get_class_n_supertypes(tp); i++) {
     if (get_type_visited(get_class_supertype(tp, i)) < type_visited)
       return;
   }
@@ -410,7 +415,7 @@ void class_walk_s2s_2(type *tp,
     pre(tp, env);
 
   tp = skip_tid((type*)tp);
-  for (i=0; i<get_class_n_subtype(tp); i++) {
+  for (i=0; i<get_class_n_subtypes(tp); i++) {
     class_walk_s2s_2(get_class_subtype(tp, i), pre, post, env);
   }
   /* execute post method */
@@ -420,10 +425,12 @@ void class_walk_s2s_2(type *tp,
   return;
 }
 
-
-void class_walk_super2sub(void (pre)(type*, void*),
-                         void (post)(type*, void*),
-                         void *env) {
+#if 0
+void class_walk_super2sub(
+                 void (*pre)(type*, void*),
+                 void (*post)(type*, void*),
+                 void *env)
+{
   int i;
   type *tp;
 
@@ -431,7 +438,7 @@ void class_walk_super2sub(void (pre)(type*, void*),
   for (i = 0; i < get_irp_n_types(); i++) {
     tp = get_irp_type(i);
     if (is_class_type(tp) &&
-       (get_class_n_supertype(tp) == 0) &&
+       (get_class_n_supertypes(tp) == 0) &&
        (tp->visit < type_visited) &&
        (!is_frame_type(tp)) &&
        (tp != get_glob_type())) {
@@ -439,3 +446,58 @@ void class_walk_super2sub(void (pre)(type*, void*),
     }
   }
 }
+#endif
+void class_walk_super2sub(
+                 void (*pre)(type*, void*),
+                 void (post)(type*, void*),
+                 void *env)
+{
+  int i;
+  type *tp;
+
+  ++type_visited;
+  for (i = 0; i < get_irp_n_types(); i++) {
+    tp = get_irp_type(i);
+    if (is_class_type(tp) &&
+       (get_class_n_supertypes(tp) == 0) &&
+       (tp->visit < type_visited))  {
+      assert(!is_frame_type(tp));
+      assert(tp != get_glob_type());
+      class_walk_s2s_2(tp, pre, post, env);
+    }
+  }
+}
+
+
+/* Walks over all entities in the type */
+void walk_types_entities(
+                 type *tp,
+                 void (*doit)(entity*, void*),
+                 void *env)
+{
+  int i;
+  switch(get_type_tpop_code(tp)) {
+  case tpo_class: {
+    for (i=0; i<get_class_n_members(tp); i++)
+      doit(get_class_member(tp, i), env);
+  } break;
+  case tpo_struct: {
+    for (i=0; i<get_struct_n_members(tp); i++)
+      doit(get_struct_member(tp, i), env);
+  } break;
+  case tpo_union: {
+    for (i = 0; i < get_union_n_members(tp); i++)
+      doit(get_union_member(tp, i), env);
+  } break;
+  case tpo_array: {
+      doit(get_array_element_entity(tp), env);
+  } break;
+  case tpo_method:
+  case tpo_enumeration:
+  case tpo_pointer:
+  case tpo_primitive:
+  case tpo_id:
+  default:
+    break;
+  }
+}