Bugfix
[libfirm] / ir / tr / typewalk.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 * All rights reserved.
3 */
4
5 /**
6 * @file typewalk.h
7 *
8 * Traverse the type information.
9 *
10 * @author Goetz Lindenmaier
11 *
12 * The walker walks the whole ir graph
13 * to find the distinct type trees in the type graph forest.
14 * - execute the pre() function before recursion
15 * - execute the post() function after recursion
16 */
17
18 /* $Id$ */
19
20
21 /* walk over all type information reachable from the ir graph. */
22
23 #ifndef _TYPEWALK_H_
24 #define _TYPEWALK_H_
25
26 # include "type_or_entity.h"
27
28 /**
29  * the type walk function
30  *
31  * @param tore    points to the visited type or entity
32  * @param env     free environment pointer
33  */
34 typedef void type_walk_func(type_or_ent *tore, void *env);
35
36 /**
37  * the class walk function
38  *
39  * @param clss    points to the visited class
40  * @param env     free environment pointer
41  */
42 typedef void class_walk_func(type *clss, void *env);
43
44 /**
45     Touches every type and entity in unspecified order.  If new
46     types/entities are created during the traversal these will
47     be visited, too. */
48 void type_walk(type_walk_func *pre,
49                type_walk_func *post,
50                void *env);
51
52 /** Walks over all type information reachable from an ir graph.
53  *
54  *  Walks over all type information reachable from irg, i.e., starts a
55  *  type walk at the irgs entity, the irgs frame type and all types and
56  *  entities that are attributes to firm nodes. */
57 void type_walk_irg(ir_graph *irg,
58                    type_walk_func *pre,
59                    type_walk_func *post,
60                    void *env);
61
62 /**
63     Touches every class in specified order:
64     - first the super class
65     - second the class itself
66     - third the sub classes.  If new classes are created
67     during the traversal these will be visited, too.
68
69     @todo should be named class-walk
70
71     @deprecated will be removed?
72 */
73 void type_walk_super2sub(type_walk_func *pre,
74                          type_walk_func *post,
75                          void *env);
76
77 /**
78     Touches every class in specified order:
79     - first the super class
80     - second the class itself
81     If new classes are created during the traversal these
82     will be visited, too. */
83 void type_walk_super(type_walk_func *pre,
84                      type_walk_func *post,
85                      void *env);
86
87 /** Same as type_walk_super2sub, but visits only class types.
88    Executes pre for a class if all superclasses have been visited.
89    Then iterates to subclasses.  Executes post after return from
90    subclass.
91    Does not visit global type, frame types.
92
93    @bug ?? something is wrong with this.
94 */
95 void class_walk_super2sub(class_walk_func *pre,
96                           class_walk_func *post,
97                           void *env);
98
99 /**
100  * the entity walk function
101  *
102  * @param ent     points to the visited entity
103  * @param env     free environment pointer
104  */
105 typedef void entity_walk_func(entity *ent, void *env);
106
107 /**
108  * Walks over all entities in the type.
109  *
110  * @param tp    the type
111  * @param doit  the entity walker function
112  * @param env   environment, wil be passed to the walker function
113  */
114 void walk_types_entities(type *tp,
115                          entity_walk_func *doit,
116                          void *env);
117 #endif /* _TYPEWALK_H_ */