1/*****************************************************************************
    2 * This file is part of the Prolog Development Tool (PDT)
    3 * 
    4 * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start
    5 * Mail: pdt@lists.iai.uni-bonn.de
    6 * Copyright (C): 2004-2012, CS Dept. III, University of Bonn
    7 * 
    8 * All rights reserved. This program is  made available under the terms
    9 * of the Eclipse Public License v1.0 which accompanies this distribution,
   10 * and is available at http://www.eclipse.org/legal/epl-v10.html
   11 * 
   12 ****************************************************************************/
   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,_))