** - execute the post function after recursion
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
#include "irgwalk.h"
#include "irgraph.h"
#include "irnode.h"
+#include "irprog.h"
#include "type_or_entity.h"
/* Make types visible to allow most efficient access */
void type_walk_2(type_or_ent *tore,
- void (pre)(type_or_ent*, void*), void (post)(type_or_ent*, void*),
- void *env)
+ void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env)
{
int i, visited = 0;
}
break;
case k_type_class:
- ((type_class *)tore)->visit = type_visited;
- /* !!!!! */
+ {
+ int i;
+ ((type_class *)tore)->visit = type_visited;
+ /* CS */
+ for (i=0; i<get_class_n_member((type_class *)tore); i++)
+ {
+ type_walk_2((type_or_ent *)get_class_member((type_class *)tore, i),
+ pre, post, env);
+ }
+ for (i=0; i<get_class_n_subtype((type_class *)tore); i++)
+ {
+ type_walk_2((type_or_ent *)get_class_subtype((type_class *)tore, i),
+ pre, post, env);
+ }
+ for (i=0; i<get_class_n_supertype((type_class *)tore); i++)
+ {
+ type_walk_2((type_or_ent *)get_class_supertype((type_class *)tore, i),
+ pre, post, env);
+ }
+ }
break;
case k_type_strct:
- ((type_strct *)tore)->visit = type_visited;
- /* !!!!! */
+ {
+ int i;
+
+ ((type_strct *)tore)->visit = type_visited;
+ /* CS */
+ for (i=0; i<get_strct_n_member((type_strct *)tore); i++)
+ {
+ type_walk_2((type_or_ent *)get_strct_member((type_strct *)tore, i),
+ pre, post, env);
+ }
+ }
break;
case k_type_method:
{
break;
case k_type_union:
((type_union *)tore)->visit = type_visited;
+ /* !!!!! */
break;
case k_type_array:
((type_array *)tore)->visit = type_visited;
}
}
-void type_walk(ir_graph *irg,
- void (pre)(type_or_ent*, void*), void (post)(type_or_ent*, void*),
- void *env)
+void type_walk(void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env) {
+ int i;
+ ++type_visited;
+ type_walk_2((type_or_ent *)get_glob_type(), pre, post, env);
+ for (i = 0; i < get_irp_n_types(); i++) {
+ type_walk_2((type_or_ent *)get_irp_type(i), pre, post, env);
+ }
+}
+
+void type_walk_irg (ir_graph *irg,
+ void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env)
{
/* this is needed to pass the parameters to the walker that actually
walks the type information */
type_env->env = env;
++type_visited;
- irg_walk(irg->end, start_type_walk, NULL, type_env);
+ irg_walk(get_irg_end(irg), start_type_walk, NULL, type_env);
+
+ type_walk_2((type_or_ent *)get_irg_ent(irg), pre, post, env);
+ /* @@@ free type_walk_env!! */
return;
}