e00a36bb3bbe4fb9a0667b2ac7b56d9a1c55e377
[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 irg */
53 void type_walk_irg(ir_graph *irg,
54                    type_walk_func *pre,
55                    type_walk_func *post,
56                    void *env);
57
58 /**
59     Touches every class in specified order:
60     - first the super class
61     - second the class itself
62     - third the sub classes.  If new classes are created
63     during the traversal these will be visited, too.
64
65     @todo should be named class-walk
66
67     @deprecated will be removed?
68 */
69 void type_walk_super2sub(type_walk_func *pre,
70                          type_walk_func *post,
71                          void *env);
72
73 /**
74     Touches every class in specified order:
75     - first the super class
76     - second the class itself
77     If new classes are created during the traversal these
78     will be visited, too. */
79 void type_walk_super(type_walk_func *pre,
80                      type_walk_func *post,
81                      void *env);
82
83 /** Same as type_walk_super2sub, but visits only class types.
84    Executes pre for a class if all superclasses have been visited.
85    Then iterates to subclasses.  Executes post after return from
86    subclass.
87    Does not visit global type, frame types.
88
89    @bug ?? something is wrong with this.
90 */
91 void class_walk_super2sub(class_walk_func *pre,
92                           class_walk_func *post,
93                           void *env);
94
95 /**
96  * the entity walk function
97  *
98  * @param ent     points to the visited entity
99  * @param env     free environment pointer
100  */
101 typedef void entity_walk_func(entity *ent, void *env);
102
103 /**
104  * Walks over all entities in the type.
105  *
106  * @param tp    the type
107  * @param doit  the entity walker function
108  * @param env   environment, wil be passed to the walker function
109  */
110 void walk_types_entities(type *tp,
111                          entity_walk_func *doit,
112                          void *env);
113 #endif /* _TYPEWALK_H_ */