3 * File name: ir/tr/typewalk.h
4 * Purpose: Traverse the type information.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 1999-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 * Traverse the type information.
18 * @author Goetz Lindenmaier
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
30 #include "type_or_entity.h"
34 /** Type of argument functions for type walkers.
36 * @param tore points to the visited type or entity
37 * @param env free environment pointer
39 typedef void type_walk_func(type_or_ent *tore, void *env);
41 /** The class walk function
43 * @param clss points to the visited class
44 * @param env free environment pointer
46 typedef void class_walk_func(ir_type *clss, void *env);
48 /** Touches every type and entity in unspecified order. If new
49 * types/entities are created during the traversal these will
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);
54 /** Walks over all type information reachable from an ir graph.
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,
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.
71 @todo should be named class-walk
73 @deprecated will be removed?
75 void type_walk_super2sub(type_walk_func *pre,
79 /** Walker for class types in inheritance order.
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.
90 * The arguments pre, post, env may be NULL. */
91 void type_walk_super(type_walk_func *pre,
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
99 Does not visit global type, frame types.
101 @bug ?? something is wrong with this.
103 void class_walk_super2sub(class_walk_func *pre,
104 class_walk_func *post,
108 * the entity walk function. A function type for entity walkers.
110 * @param ent points to the visited entity
111 * @param env free environment pointer
113 typedef void entity_walk_func(entity *ent, void *env);
116 * Walks over all entities in the type.
119 * @param doit the entity walker function
120 * @param env environment, will be passed to the walker function
122 void walk_types_entities(ir_type *tp,
123 entity_walk_func *doit,
126 #endif /* _TYPEWALK_H_ */