2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Functionality to modify the type graph.
23 * @author Goetz Lindenmaier
27 * Traverse the type information.
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
34 #ifndef FIRM_TR_TYPEWALK_H
35 #define FIRM_TR_TYPEWALK_H
38 #include "type_or_entity.h"
42 /** Type of argument functions for type walkers.
44 * @param tore points to the visited type or entity
45 * @param env free environment pointer
47 typedef void type_walk_func(type_or_ent *tore, void *env);
49 /** The class walk function
51 * @param clss points to the visited class
52 * @param env free environment pointer
54 typedef void class_walk_func(ir_type *clss, void *env);
56 /** Touches every type and entity in unspecified order. If new
57 * types/entities are created during the traversal these will
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);
62 /** Walks over all type information reachable from an ir graph.
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,
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.
79 @todo should be named class-walk
81 @deprecated will be removed?
83 void type_walk_super2sub(type_walk_func *pre,
87 /** Walker for class types in inheritance order.
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.
98 * The arguments pre, post, env may be NULL. */
99 void type_walk_super(type_walk_func *pre,
100 type_walk_func *post,
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
107 Does not visit global type, frame types.
109 @bug ?? something is wrong with this.
111 void class_walk_super2sub(class_walk_func *pre,
112 class_walk_func *post,
116 * the entity walk function. A function type for entity walkers.
118 * @param ent points to the visited entity
119 * @param env free environment pointer
121 typedef void entity_walk_func(ir_entity *ent, void *env);
124 * Walks over all entities in the type.
127 * @param doit the entity walker function
128 * @param env environment, will be passed to the walker function
130 void walk_types_entities(ir_type *tp,
131 entity_walk_func *doit,
134 #endif /* FIRM_TR_TYPEWALK_H */