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 * File name: ir/tr/typewalk.h
23 * Purpose: Traverse the type information.
24 * Author: Goetz Lindenmaier
28 * Copyright: (c) 1999-2003 Universität Karlsruhe
34 * Traverse the type information.
36 * @author Goetz Lindenmaier
38 * The walker walks the whole ir graph
39 * to find the distinct type trees in the type graph forest.
40 * - execute the pre() function before recursion
41 * - execute the post() function after recursion
48 #include "type_or_entity.h"
52 /** Type of argument functions for type walkers.
54 * @param tore points to the visited type or entity
55 * @param env free environment pointer
57 typedef void type_walk_func(type_or_ent *tore, void *env);
59 /** The class walk function
61 * @param clss points to the visited class
62 * @param env free environment pointer
64 typedef void class_walk_func(ir_type *clss, void *env);
66 /** Touches every type and entity in unspecified order. If new
67 * types/entities are created during the traversal these will
69 * Does not touch frame types or types for value params ... */
70 void type_walk(type_walk_func *pre, type_walk_func *post, void *env);
72 /** Walks over all type information reachable from an ir graph.
74 * Walks over all type information reachable from irg, i.e., starts a
75 * type walk at the irgs entity, the irgs frame type and all types and
76 * entities that are attributes to firm nodes. */
77 void type_walk_irg(ir_graph *irg,
83 Touches every class in specified order:
84 - first the super class
85 - second the class itself
86 - third the sub classes. If new classes are created
87 during the traversal these will be visited, too.
89 @todo should be named class-walk
91 @deprecated will be removed?
93 void type_walk_super2sub(type_walk_func *pre,
97 /** Walker for class types in inheritance order.
99 * Touches every class in specified order:
100 * - first the super class
101 * - second the class itself
102 * If new classes are created during the traversal these
103 * will be visited, too.
104 * Starts the walk at arbitrary classes.
105 * Executes pre when first visiting a class. Executes post after
106 * visiting all superclasses.
108 * The arguments pre, post, env may be NULL. */
109 void type_walk_super(type_walk_func *pre,
110 type_walk_func *post,
113 /** Same as type_walk_super2sub, but visits only class types.
114 Executes pre for a class if all superclasses have been visited.
115 Then iterates to subclasses. Executes post after return from
117 Does not visit global type, frame types.
119 @bug ?? something is wrong with this.
121 void class_walk_super2sub(class_walk_func *pre,
122 class_walk_func *post,
126 * the entity walk function. A function type for entity walkers.
128 * @param ent points to the visited entity
129 * @param env free environment pointer
131 typedef void entity_walk_func(ir_entity *ent, void *env);
134 * Walks over all entities in the type.
137 * @param doit the entity walker function
138 * @param env environment, will be passed to the walker function
140 void walk_types_entities(ir_type *tp,
141 entity_walk_func *doit,
144 #endif /* _TYPEWALK_H_ */