Fixed the last fix again:
[libfirm] / ir / tr / typewalk.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file    typewalk.h
22  * @brief   Functionality to modify the type graph.
23  * @author  Goetz Lindenmaier
24  * @version $Id$
25  * @summary
26  *
27  * Traverse the type information.
28  *
29  * The walker walks the whole ir graph
30  * to find the distinct type trees in the type graph forest.
31  * - execute the pre() function before recursion
32  * - execute the post() function after recursion
33  */
34 #ifndef FIRM_TR_TYPEWALK_H
35 #define FIRM_TR_TYPEWALK_H
36
37 #include "type.h"
38 #include "type_or_entity.h"
39
40 #include "irgraph.h"
41
42 /** Type of argument functions for type walkers.
43  *
44  * @param tore    points to the visited type or entity
45  * @param env     free environment pointer
46  */
47 typedef void type_walk_func(type_or_ent *tore, void *env);
48
49 /**  The class walk function
50  *
51  * @param clss    points to the visited class
52  * @param env     free environment pointer
53  */
54 typedef void class_walk_func(ir_type *clss, void *env);
55
56 /** Touches every type and entity in unspecified order.  If new
57  *  types/entities are created during the traversal these will
58  *  be visited, too.
59  *  Does not touch frame types or types for value params ... */
60 void type_walk(type_walk_func *pre, type_walk_func *post, void *env);
61
62 /** Walks over all type information reachable from an ir graph.
63  *
64  *  Walks over all type information reachable from irg, i.e., starts a
65  *  type walk at the irgs entity, the irgs frame type and all types and
66  *  entities that are attributes to firm nodes. */
67 void type_walk_irg(ir_graph *irg,
68            type_walk_func *pre,
69            type_walk_func *post,
70            void *env);
71
72 /**
73     Touches every class in specified order:
74     - first the super class
75     - second the class itself
76     - third the sub classes.  If new classes are created
77     during the traversal these will be visited, too.
78
79     @todo should be named class-walk
80
81     @deprecated will be removed?
82 */
83 void type_walk_super2sub(type_walk_func *pre,
84              type_walk_func *post,
85              void *env);
86
87 /** Walker for class types in inheritance order.
88  *
89  *  Touches every class in specified order:
90  *   - first the super class
91  *   - second the class itself
92  *   If new classes are created during the traversal these
93  *   will be visited, too.
94  * Starts the walk at arbitrary classes.
95  * Executes pre when first visiting a class.  Executes post after
96  * visiting all superclasses.
97  *
98  * The arguments pre, post, env may be NULL. */
99 void type_walk_super(type_walk_func *pre,
100              type_walk_func *post,
101              void *env);
102
103 /** Same as type_walk_super2sub, but visits only class types.
104    Executes pre for a class if all superclasses have been visited.
105    Then iterates to subclasses.  Executes post after return from
106    subclass.
107    Does not visit global type, frame types.
108
109    @bug ?? something is wrong with this.
110 */
111 void class_walk_super2sub(class_walk_func *pre,
112                           class_walk_func *post,
113                           void *env);
114
115 /**
116  * the entity walk function.  A function type for entity walkers.
117  *
118  * @param ent     points to the visited entity
119  * @param env     free environment pointer
120  */
121 typedef void entity_walk_func(ir_entity *ent, void *env);
122
123 /**
124  * Walks over all entities in the type.
125  *
126  * @param tp    the type
127  * @param doit  the entity walker function
128  * @param env   environment, will be passed to the walker function
129  */
130 void walk_types_entities(ir_type *tp,
131              entity_walk_func *doit,
132              void *env);
133
134 #endif /* FIRM_TR_TYPEWALK_H */