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