Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
43f61f31
Commit
43f61f31
authored
Jul 25, 2008
by
Michael Beck
Browse files
- fixed type_or_ent type: get rod of casts
[r20678]
parent
c465867d
Changes
11
Hide whitespace changes
Inline
Side-by-side
include/libfirm/typerep.h
View file @
43f61f31
...
...
@@ -2565,7 +2565,7 @@ typedef union {
* @param tore points to the visited type or entity
* @param env free environment pointer
*/
typedef
void
type_walk_func
(
type_or_ent
*
tore
,
void
*
env
);
typedef
void
type_walk_func
(
type_or_ent
tore
,
void
*
env
);
/** The class walk function
*
...
...
ir/ana/rta.c
View file @
43f61f31
...
...
@@ -451,10 +451,10 @@ void rta_init (int do_verbose)
* Changes the peculiarity of entities that represents
* dead graphs to peculiarity_description.
*/
static
void
make_entity_to_description
(
type_or_ent
*
tore
,
void
*
env
)
{
static
void
make_entity_to_description
(
type_or_ent
tore
,
void
*
env
)
{
(
void
)
env
;
if
(
get_kind
(
tore
)
==
k_entity
)
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
if
(
is_entity
(
tore
.
ent
)
)
{
ir_entity
*
ent
=
tore
.
ent
;
if
((
is_Method_type
(
get_entity_type
(
ent
)))
&&
(
get_entity_peculiarity
(
ent
)
!=
peculiarity_description
)
&&
...
...
ir/be/bestabs.c
View file @
43f61f31
...
...
@@ -469,13 +469,13 @@ static void gen_method_type(wenv_t *env, ir_type *tp) {
* type-walker: generate declaration for simple types,
* put all other types on a wait queue
*/
static
void
walk_type
(
type_or_ent
*
tore
,
void
*
ctx
)
static
void
walk_type
(
type_or_ent
tore
,
void
*
ctx
)
{
wenv_t
*
env
=
ctx
;
ir_type
*
tp
;
if
(
get_kind
(
tore
)
==
k_
typ
e
)
{
tp
=
(
ir_type
*
)
tore
;
if
(
is_type
(
tore
.
typ
)
)
{
tp
=
tore
.
typ
;
/* ignore the unknown type */
if
(
tp
==
firm_unknown_type
)
...
...
ir/common/firmwalk.c
View file @
43f61f31
...
...
@@ -229,21 +229,21 @@ void *get_firm_walk_link(void *thing)
* @param env Environment pointer (currently unused)
*/
static
void
fw_collect_tore
(
type_or_ent
*
tore
,
void
*
env
)
void
fw_collect_tore
(
type_or_ent
tore
,
void
*
env
)
{
ir_type
*
tp
;
ir_entity
*
ent
;
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
ent
=
(
ir_entity
*
)
tore
;
ent
=
tore
.
ent
;
/* append entity to list */
set_entity_link
(
ent
,
NULL
);
if
(
!
pmap_contains
(
entity_map
,
ent
))
pmap_insert
(
entity_map
,
ent
,
env
);
break
;
case
k_type
:
tp
=
(
ir_type
*
)
tore
;
tp
=
tore
.
typ
;
/* append type to list */
set_type_link
(
tp
,
NULL
);
...
...
ir/debug/debugger.c
View file @
43f61f31
...
...
@@ -765,26 +765,25 @@ typedef struct find_env {
/**
* Type-walker: Find an entity with given number.
*/
static
void
check_ent_nr
(
type_or_ent
*
tore
,
void
*
ctx
)
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
static
void
check_ent_nr
(
type_or_ent
tore
,
void
*
ctx
)
{
find_env_t
*
env
=
ctx
;
if
(
is_entity
(
ent
))
if
(
get_entity_nr
(
ent
)
==
env
->
u
.
nr
)
{
env
->
res
=
ent
;
if
(
is_entity
(
tore
.
ent
))
{
if
(
get_entity_nr
(
tore
.
ent
)
==
env
->
u
.
nr
)
{
env
->
res
=
tore
.
ent
;
}
}
}
/* check_ent_nr */
/**
* Type-walker: Find an entity with given name.
*/
static
void
check_ent_name
(
type_or_ent
*
tore
,
void
*
ctx
)
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
static
void
check_ent_name
(
type_or_ent
tore
,
void
*
ctx
)
{
find_env_t
*
env
=
ctx
;
if
(
is_entity
(
ent
))
if
(
strcmp
(
get_entity_name
(
ent
),
env
->
u
.
name
)
==
0
)
{
env
->
res
=
ent
;
if
(
is_entity
(
tore
.
ent
))
if
(
strcmp
(
get_entity_name
(
tore
.
ent
),
env
->
u
.
name
)
==
0
)
{
env
->
res
=
tore
.
ent
;
}
}
/* check_ent_name */
...
...
@@ -843,11 +842,11 @@ static void show_by_name(type_or_ent *tore, void *env) {
/**
* Search methods for a ldname.
*/
static
void
show_by_ldname
(
type_or_ent
*
tore
,
void
*
env
)
{
static
void
show_by_ldname
(
type_or_ent
tore
,
void
*
env
)
{
ident
*
id
=
(
ident
*
)
env
;
if
(
is_entity
(
tore
))
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
if
(
is_entity
(
tore
.
ent
))
{
ir_entity
*
ent
=
tore
.
ent
;
if
(
is_method_entity
(
ent
))
{
if
(
get_entity_ld_ident
(
ent
)
==
id
)
{
...
...
ir/ir/irdump.c
View file @
43f61f31
...
...
@@ -2042,15 +2042,15 @@ static void dump_enum_item(FILE *F, ir_type *tp, int pos)
/* dumps a type or entity and it's edges. */
static
void
dump_type_info
(
type_or_ent
*
tore
,
void
*
env
)
{
dump_type_info
(
type_or_ent
tore
,
void
*
env
)
{
FILE
*
F
=
env
;
int
i
=
0
;
/* to shutup gcc */
/* dump this type or entity */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
ir_entity
*
ent
=
tore
.
ent
;
ir_node
*
value
;
/* The node */
dump_entity_node
(
F
,
ent
,
0
);
...
...
@@ -2092,7 +2092,7 @@ dump_type_info(type_or_ent *tore, void *env) {
break
;
}
case
k_type
:
{
ir_type
*
tp
=
(
ir_type
*
)
tore
;
ir_type
*
tp
=
tore
.
typ
;
dump_type_node
(
F
,
tp
);
/* and now the edges */
switch
(
get_type_tpop_code
(
tp
))
{
...
...
@@ -2159,17 +2159,18 @@ typedef struct _h_env {
* If env->dump_ent dumps entities of classes and overwrites edges.
*/
static
void
dump_class_hierarchy_node
(
type_or_ent
*
tore
,
void
*
ctx
)
{
dump_class_hierarchy_node
(
type_or_ent
tore
,
void
*
ctx
)
{
h_env_t
*
env
=
ctx
;
FILE
*
F
=
env
->
f
;
int
i
=
0
;
/* to shutup gcc */
/* dump this type or entity */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
ir_entity
*
ent
=
tore
.
ent
;
if
(
get_entity_owner
(
ent
)
==
get_glob_type
())
break
;
if
(
!
is_Method_type
(
get_entity_type
(
ent
)))
break
;
/* GL */
if
(
!
is_Method_type
(
get_entity_type
(
ent
)))
break
;
/* GL */
if
(
env
->
dump_ent
&&
is_Class_type
(
get_entity_owner
(
ent
)))
{
/* The node */
dump_entity_node
(
F
,
ent
,
0
);
...
...
@@ -2181,8 +2182,9 @@ dump_class_hierarchy_node(type_or_ent *tore, void *ctx) {
break
;
}
case
k_type
:
{
ir_type
*
tp
=
(
ir_type
*
)
tore
;
if
(
tp
==
get_glob_type
())
break
;
ir_type
*
tp
=
tore
.
typ
;
if
(
tp
==
get_glob_type
())
break
;
switch
(
get_type_tpop_code
(
tp
))
{
case
tpo_class
:
dump_type_node
(
F
,
tp
);
...
...
ir/lower/lower_calls.c
View file @
43f61f31
...
...
@@ -808,14 +808,14 @@ static int must_be_lowered(const lower_params_t *lp, ir_type *tp) {
* type-walker: lower all method types of entities
* and points-to types.
*/
static
void
lower_method_types
(
type_or_ent
*
tore
,
void
*
env
)
static
void
lower_method_types
(
type_or_ent
tore
,
void
*
env
)
{
const
lower_params_t
*
lp
=
env
;
ir_type
*
tp
;
/* fix method entities */
if
(
is_entity
(
tore
))
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
if
(
is_entity
(
tore
.
ent
))
{
ir_entity
*
ent
=
tore
.
ent
;
tp
=
get_entity_type
(
ent
);
if
(
must_be_lowered
(
lp
,
tp
))
{
...
...
@@ -823,7 +823,7 @@ static void lower_method_types(type_or_ent *tore, void *env)
set_entity_type
(
ent
,
tp
);
}
}
else
{
tp
=
(
ir_type
*
)
tore
;
tp
=
tore
.
typ
;
/* fix pointer to methods */
if
(
is_Pointer_type
(
tp
))
{
...
...
ir/opt/ircgopt.c
View file @
43f61f31
...
...
@@ -63,9 +63,9 @@ static void collect_call(ir_node *node, void *env) {
* Type walker, set the peculiarity of entities which graphs
* gets removed to peculiarity_description.
*/
static
void
make_entity_to_description
(
type_or_ent
*
tore
,
void
*
env
)
{
if
(
get_kind
(
tore
)
==
k_entity
)
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
static
void
make_entity_to_description
(
type_or_ent
tore
,
void
*
env
)
{
if
(
is_entity
(
tore
.
ent
)
)
{
ir_entity
*
ent
=
tore
.
ent
;
if
((
is_Method_type
(
get_entity_type
(
ent
)))
&&
(
get_entity_peculiarity
(
ent
)
!=
peculiarity_description
)
&&
...
...
ir/tr/trvrfy.c
View file @
43f61f31
...
...
@@ -417,14 +417,14 @@ int check_entity(ir_entity *ent) {
/*
* check types and entities
*/
static
void
check_tore
(
type_or_ent
*
tore
,
void
*
env
)
{
static
void
check_tore
(
type_or_ent
tore
,
void
*
env
)
{
int
*
res
=
env
;
assert
(
tore
);
if
(
is_type
(
tore
))
{
*
res
=
check_type
(
(
ir_type
*
)
tore
);
assert
(
tore
.
ent
);
if
(
is_type
(
tore
.
typ
))
{
*
res
=
check_type
(
tore
.
typ
);
}
else
{
assert
(
is_entity
(
tore
));
*
res
=
check_entity
(
(
ir_entity
*
)
tore
);
assert
(
is_entity
(
tore
.
ent
));
*
res
=
check_entity
(
tore
.
ent
);
}
}
...
...
ir/tr/type_finalization.c
View file @
43f61f31
...
...
@@ -36,11 +36,11 @@
DEBUG_ONLY
(
static
firm_dbg_module_t
*
dbg
;)
static
void
do_finalization
(
type_or_ent
*
tore
,
void
*
env
)
{
static
void
do_finalization
(
type_or_ent
tore
,
void
*
env
)
{
ir_type
*
glob_tp
=
env
;
if
(
is_type
(
tore
))
{
ir_type
*
cls
=
(
ir_type
*
)
tore
;
if
(
is_type
(
tore
.
typ
))
{
ir_type
*
cls
=
tore
.
typ
;
if
(
!
is_Class_type
(
cls
)
||
cls
==
glob_tp
)
return
;
...
...
@@ -55,7 +55,7 @@ static void do_finalization(type_or_ent *tore, void *env) {
get_type_name
(
cls
)));
}
}
else
{
ir_entity
*
ent
=
(
ir_entity
*
)
tore
;
ir_entity
*
ent
=
tore
.
ent
;
ir_type
*
owner
;
if
(
is_entity_final
(
ent
))
...
...
ir/tr/typewalk.c
View file @
43f61f31
...
...
@@ -90,25 +90,28 @@ static void walk_initializer(ir_initializer_t *initializer,
* Main walker: walks over all used types/entities of a
* type entity.
*/
static
void
do_type_walk
(
type_or_ent
*
tore
,
static
void
do_type_walk
(
type_or_ent
tore
,
type_walk_func
*
pre
,
type_walk_func
*
post
,
void
*
env
)
{
int
i
,
n_types
,
n_mem
;
ir_entity
*
ent
=
NULL
;
ir_type
*
tp
=
NULL
;
ir_node
*
n
;
int
i
,
n_types
,
n_mem
;
ir_entity
*
ent
=
NULL
;
ir_type
*
tp
=
NULL
;
ir_node
*
n
;
type_or_ent
cont
;
/* marked? */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
ent
=
(
ir_entity
*
)
tore
;
if
(
entity_visited
(
ent
))
return
;
ent
=
tore
.
ent
;
if
(
entity_visited
(
ent
))
return
;
break
;
case
k_type
:
tp
=
skip_tid
((
ir_type
*
)
tore
);
if
(
type_visited
(
tp
))
return
;
tp
=
skip_tid
(
tore
.
typ
);
if
(
type_visited
(
tp
))
return
;
break
;
default:
break
;
...
...
@@ -119,11 +122,13 @@ static void do_type_walk(type_or_ent *tore,
pre
(
tore
,
env
);
/* iterate */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
mark_entity_visited
(
ent
);
do_type_walk
((
type_or_ent
*
)
get_entity_owner
(
ent
),
pre
,
post
,
env
);
do_type_walk
((
type_or_ent
*
)
get_entity_type
(
ent
),
pre
,
post
,
env
);
cont
.
typ
=
get_entity_owner
(
ent
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
cont
.
typ
=
get_entity_type
(
ent
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
if
(
get_entity_variability
(
ent
)
!=
variability_uninitialized
)
{
/* walk over the value types */
...
...
@@ -147,45 +152,56 @@ static void do_type_walk(type_or_ent *tore,
case
tpo_class
:
n_types
=
get_class_n_supertypes
(
tp
);
for
(
i
=
0
;
i
<
n_types
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_class_supertype
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_types
;
++
i
)
{
cont
.
typ
=
get_class_supertype
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
n_mem
=
get_class_n_members
(
tp
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_class_member
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
{
cont
.
ent
=
get_class_member
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
n_types
=
get_class_n_subtypes
(
tp
);
for
(
i
=
0
;
i
<
n_types
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_class_subtype
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_types
;
++
i
)
{
cont
.
typ
=
get_class_subtype
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
break
;
case
tpo_struct
:
n_mem
=
get_struct_n_members
(
tp
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_struct_member
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
{
cont
.
ent
=
get_struct_member
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
break
;
case
tpo_method
:
n_mem
=
get_method_n_params
(
tp
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_method_param_type
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
{
cont
.
typ
=
get_method_param_type
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
n_mem
=
get_method_n_ress
(
tp
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_method_res_type
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
{
cont
.
typ
=
get_method_res_type
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
break
;
case
tpo_union
:
n_mem
=
get_union_n_members
(
tp
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
do_type_walk
((
type_or_ent
*
)
get_union_member
(
tp
,
i
),
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_mem
;
++
i
)
{
cont
.
ent
=
get_union_member
(
tp
,
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
break
;
case
tpo_array
:
do_type_walk
((
type_or_ent
*
)
get_array_element_type
(
tp
)
,
pre
,
post
,
env
);
do_type_walk
((
type_or_
ent
*
)
get_array_element_entity
(
tp
)
,
pre
,
post
,
env
);
cont
.
typ
=
get_array_element_type
(
tp
)
;
do_type_walk
(
cont
,
pre
,
post
,
env
);
cont
.
ent
=
get_array_element_entity
(
tp
)
;
do_type_walk
(
cont
,
pre
,
post
,
env
);
break
;
case
tpo_enumeration
:
...
...
@@ -193,8 +209,8 @@ static void do_type_walk(type_or_ent *tore,
break
;
case
tpo_pointer
:
do_type_walk
((
type_or_ent
*
)
get_pointer_points_to_type
(
tp
)
,
pre
,
post
,
env
);
cont
.
typ
=
get_pointer_points_to_type
(
tp
)
;
do_type_walk
(
cont
,
pre
,
post
,
env
);
break
;
case
tpo_primitive
:
...
...
@@ -226,17 +242,16 @@ static void do_type_walk(type_or_ent *tore,
static
void
irn_type_walker
(
ir_node
*
node
,
type_walk_func
*
pre
,
type_walk_func
*
post
,
void
*
env
)
{
ir_entity
*
ent
;
ir_type
*
tp
;
type_or_ent
cont
;
assert
(
node
);
ent
=
get_irn_entity_attr
(
node
);
if
(
ent
)
do_type_walk
(
(
type_or_ent
*
)
e
nt
,
pre
,
post
,
env
);
tp
=
get_irn_type_attr
(
node
);
if
(
t
p
)
do_type_walk
(
(
type_or_ent
*
)
tp
,
pre
,
post
,
env
);
cont
.
ent
=
get_irn_entity_attr
(
node
);
if
(
cont
.
ent
)
do_type_walk
(
co
nt
,
pre
,
post
,
env
);
cont
.
typ
=
get_irn_type_attr
(
node
);
if
(
cont
.
ty
p
)
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
/** Check whether node contains types or entities as an attribute.
...
...
@@ -256,13 +271,16 @@ static void start_type_walk(ir_node *node, void *ctx) {
/* walker: walks over all types */
void
type_walk
(
type_walk_func
*
pre
,
type_walk_func
*
post
,
void
*
env
)
{
int
i
,
n_types
=
get_irp_n_types
();
int
i
,
n_types
=
get_irp_n_types
();
type_or_ent
cont
;
inc_master_type_visited
();
for
(
i
=
0
;
i
<
n_types
;
++
i
)
{
do_type_walk
((
type_or_ent
*
)
get_irp_type
(
i
),
pre
,
post
,
env
);
cont
.
typ
=
get_irp_type
(
i
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
do_type_walk
((
type_or_ent
*
)
get_glob_type
(),
pre
,
post
,
env
);
cont
.
typ
=
get_glob_type
();
do_type_walk
(
cont
,
pre
,
post
,
env
);
}
void
type_walk_irg
(
ir_graph
*
irg
,
...
...
@@ -274,6 +292,7 @@ void type_walk_irg(ir_graph *irg,
/* this is needed to pass the parameters to the walker that actually
walks the type information */
type_walk_env
type_env
;
type_or_ent
cont
;
type_env
.
pre
=
pre
;
type_env
.
post
=
post
;
...
...
@@ -281,10 +300,10 @@ void type_walk_irg(ir_graph *irg,
current_ir_graph
=
irg
;
/* We walk over the irg to find all
ir
nodes that contain an attribute
/* We walk over the irg to find all
IR-
nodes that contain an attribute
with type information. If we find one we call a type walker to
touch the reachable type information.
The same type can be referenced by several
ir
nodes. To avoid
The same type can be referenced by several
IR-
nodes. To avoid
repeated visits of the same type node we must decrease the
type visited flag for each walk. This is done in start_type_walk().
Here we initially increase the flag. We only call do_type_walk that does
...
...
@@ -293,58 +312,64 @@ void type_walk_irg(ir_graph *irg,
inc_master_type_visited
();
irg_walk
(
get_irg_end
(
irg
),
start_type_walk
,
NULL
,
&
type_env
);
do_type_walk
((
type_or_ent
*
)
get_irg_entity
(
irg
),
pre
,
post
,
env
);
cont
.
ent
=
get_irg_entity
(
irg
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
do_type_walk
((
type_or_ent
*
)
get_irg_frame_type
(
irg
),
pre
,
post
,
env
);
cont
.
typ
=
get_irg_frame_type
(
irg
);
do_type_walk
(
cont
,
pre
,
post
,
env
);
current_ir_graph
=
rem
;
return
;
}
static
void
type_walk_s2s_2
(
type_or_ent
*
tore
,
static
void
type_walk_s2s_2
(
type_or_ent
tore
,
type_walk_func
*
pre
,
type_walk_func
*
post
,
void
*
env
)
{
int
i
,
n
;
type_or_ent
cont
;
int
i
,
n
;
/* marked? */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
if
(
entity_visited
(
(
ir_entity
*
)
tore
))
return
;
if
(
entity_visited
(
tore
.
ent
))
return
;
break
;
case
k_type
:
if
(
type_id
==
get_type_tpop
((
ir_type
*
)
tore
))
{
type_walk_s2s_2
((
type_or_ent
*
)
skip_tid
((
ir_type
*
)
tore
),
pre
,
post
,
env
);
if
(
type_id
==
get_type_tpop
(
tore
.
typ
))
{
cont
.
typ
=
skip_tid
(
tore
.
typ
);
type_walk_s2s_2
(
cont
,
pre
,
post
,
env
);
return
;
}
if
(
type_visited
(
(
ir_type
*
)
tore
))
return
;
if
(
type_visited
(
tore
.
typ
))
return
;
break
;
default:
break
;
}
/* iterate */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
typ
))
{
case
k_type
:
{
ir_type
*
tp
=
(
ir_type
*
)
tore
;
ir_type
*
tp
=
tore
.
typ
;
mark_type_visited
(
tp
);
switch
(
get_type_tpop_code
(
tp
))
{
case
tpo_class
:
{
n
=
get_class_n_supertypes
(
tp
);
for
(
i
=
0
;
i
<
n
;
++
i
)
{
type_walk_s2s_2
((
type_or_ent
*
)
get_class_supertype
(
tp
,
i
),
pre
,
post
,
env
);
cont
.
typ
=
get_class_supertype
(
tp
,
i
);
type_walk_s2s_2
(
cont
,
pre
,
post
,
env
);
}
/* execute pre method */
if
(
pre
)
pre
(
tore
,
env
);
tp
=
skip_tid
(
(
ir_type
*
)
tore
);
tp
=
skip_tid
(
tp
);
n
=
get_class_n_subtypes
(
tp
);
for
(
i
=
0
;
i
<
n
;
++
i
)
{
type_walk_s2s_2
((
type_or_ent
*
)
get_class_subtype
(
tp
,
i
),
pre
,
post
,
env
);
cont
.
typ
=
get_class_subtype
(
tp
,
i
);
type_walk_s2s_2
(
cont
,
pre
,
post
,
env
);
}
/* execute post method */
...
...
@@ -368,7 +393,7 @@ static void type_walk_s2s_2(type_or_ent *tore,
}
}
break
;
/* end case k_type */
case
k_entity
:
/* dont care */
/* don
'
t care */
break
;
default:
printf
(
" *** Faulty type or entity!
\n
"
);
...
...
@@ -381,47 +406,52 @@ void type_walk_super2sub(type_walk_func *pre,
type_walk_func
*
post
,
void
*
env
)
{
int
i
,
n_types
=
get_irp_n_types
()
;
i
r_type
*
tp
;
type_or_ent
cont
;
i
nt
i
,
n_types
=
get_irp_n_types
()
;
inc_master_type_visited
();
type_walk_s2s_2
((
type_or_ent
*
)
get_glob_type
(),
pre
,
post
,
env
);
cont
.
typ
=
get_glob_type
();
type_walk_s2s_2
(
cont
,
pre
,
post
,
env
);
for
(
i
=
0
;
i
<
n_types
;
++
i
)
{
t
p
=
get_irp_type
(
i
);
type_walk_s2s_2
(
(
type_or_ent
*
)
tp
,
pre
,
post
,
env
);
cont
.
ty
p
=
get_irp_type
(
i
);
type_walk_s2s_2
(
cont
,
pre
,
post
,
env
);
}
}
/*****************************************************************************/
static
void
type_walk_super_2
(
type_or_ent
*
tore
,
type_walk_super_2
(
type_or_ent
tore
,
type_walk_func
*
pre
,
type_walk_func
*
post
,
void
*
env
)
{
int
i
,
n
;
type_or_ent
cont
;
int
i
,
n
;
/* marked? */
switch
(
get_kind
(
tore
))
{
switch
(
get_kind
(
tore
.
ent
))
{
case
k_entity
:
if
(
entity_visited
((
ir_entity
*
)
tore
))
return
;
if
(
entity_visited
(
tore
.
ent
))
return
;
break
;
case
k_type
:
if
(
type_id
==
get_type_tpop
((
ir_type
*
)
tore
))
{