fixed CRLF
[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.h"
30 #include "type_or_entity.h"
31
32 #include "irgraph.h"
33
34 /** Type of argument functions for type walkers.
35  *
36  * @param tore    points to the visited type or entity
37  * @param env     free environment pointer
38  */
39 typedef void type_walk_func(type_or_ent *tore, void *env);
40
41 /**  The class walk function
42  *
43  * @param clss    points to the visited class
44  * @param env     free environment pointer
45  */
46 typedef void class_walk_func(ir_type *clss, void *env);
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  *  Does not touch frame types or types for value params ... */
52 void type_walk(type_walk_func *pre, type_walk_func *post, void *env);
53
54 /** Walks over all type information reachable from an ir graph.
55  *
56  *  Walks over all type information reachable from irg, i.e., starts a
57  *  type walk at the irgs entity, the irgs frame type and all types and
58  *  entities that are attributes to firm nodes. */
59 void type_walk_irg(ir_graph *irg,
60            type_walk_func *pre,
61            type_walk_func *post,
62            void *env);
63
64 /**
65     Touches every class in specified order:
66     - first the super class
67     - second the class itself
68     - third the sub classes.  If new classes are created
69     during the traversal these will be visited, too.
70
71     @todo should be named class-walk
72
73     @deprecated will be removed?
74 */
75 void type_walk_super2sub(type_walk_func *pre,
76              type_walk_func *post,
77              void *env);
78
79 /** Walker for class types in inheritance order.
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  * Starts the walk at arbitrary classes.
87  * Executes pre when first visiting a class.  Executes post after
88  * visiting all superclasses.
89  *
90  * The arguments pre, post, env may be NULL. */
91 void type_walk_super(type_walk_func *pre,
92              type_walk_func *post,
93              void *env);
94
95 /** Same as type_walk_super2sub, but visits only class types.
96    Executes pre for a class if all superclasses have been visited.
97    Then iterates to subclasses.  Executes post after return from
98    subclass.
99    Does not visit global type, frame types.
100
101    @bug ?? something is wrong with this.
102 */
103 void class_walk_super2sub(class_walk_func *pre,
104                           class_walk_func *post,
105                           void *env);
106
107 /**
108  * the entity walk function.  A function type for entity walkers.
109  *
110  * @param ent     points to the visited entity
111  * @param env     free environment pointer
112  */
113 typedef void entity_walk_func(entity *ent, void *env);
114
115 /**
116  * Walks over all entities in the type.
117  *
118  * @param tp    the type
119  * @param doit  the entity walker function
120  * @param env   environment, will be passed to the walker function
121  */
122 void walk_types_entities(ir_type *tp,
123              entity_walk_func *doit,
124              void *env);
125
126 #endif /* _TYPEWALK_H_ */