13
14:- module(dead_predicate_finder,[ uncalled_predicate/1,
15 uncalled_local_predicate/1,
16 locally_dead_predicate/1]). 17
18:- ensure_loaded('../pdt_factbase'). 19:- use_module('../modules_and_visibility'). 20:- use_module('edge_counter'). 21
22
23locally_dead_predicate(Dead) :-
24 locally_dead_predicate(Dead, [Dead]).
25
26locally_dead_predicate(Dead, _Visited):-
27 uncalled_local_predicate(Dead).
28locally_dead_predicate(Dead, Visited):-
29 forall(
30 (call_edges_for_predicates(Caller,Dead,_), Caller \== Dead, not(member(Caller, Visited))),
31 locally_dead_predicate(Caller, [Caller | Visited])
32 ),
33 \+(exporting(_,Dead,_)).
34
35
36
37
38
39uncalled_local_predicate(Uncalled):-
40 uncalled_predicate(Uncalled),
41 \+(exporting(_,Uncalled,_)).
42
43
44uncalled_predicate(Uncalled):-
45 predicateT(Uncalled,_,_,_,_),
46 \+(call_edges_for_predicates(_,Uncalled,_))