KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > ReverseDFSOrder


1 /*
2  * Bytecode Analysis Framework
3  * Copyright (C) 2003,2004 University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.ba;
21
22 import java.util.Comparator JavaDoc;
23
24 /**
25  * A BlockOrder for visiting the blocks of a CFG in
26  * the order they would be visited in a depth first search
27  * of the reversed CFG. This is the most efficient visitation
28  * order for backwards dataflow analyses.
29  *
30  * @see BlockOrder
31  * @see ReverseDepthFirstSearch
32  * @see CFG
33  * @see BasicBlock
34  */

35 public class ReverseDFSOrder extends AbstractBlockOrder {
36     public ReverseDepthFirstSearch rdfs;
37     public DepthFirstSearch dfs;
38     private static class ReverseDFSComparator implements Comparator JavaDoc<BasicBlock> {
39         public ReverseDepthFirstSearch rdfs;
40         public DepthFirstSearch dfs;
41         public ReverseDFSComparator(ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs) {
42             if (rdfs == null) throw new IllegalArgumentException JavaDoc();
43             this.rdfs = rdfs;
44             if (dfs == null) throw new IllegalArgumentException JavaDoc();
45             this.dfs = dfs;
46         }
47         public int compare(BasicBlock a, BasicBlock b) {
48             return dfs.getFinishTime(a) - dfs.getFinishTime(b);
49         }
50     }
51
52     /**
53      * Constructor.
54      *
55      * @param cfg the CFG
56      * @param rdfs the ReverseDepthFirstSearch of the CFG
57      * @param dfs TODO
58      */

59     public ReverseDFSOrder(CFG cfg, ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs) {
60         super(cfg, new ReverseDFSComparator(rdfs, dfs));
61         this.rdfs = rdfs;
62         this.dfs = dfs;
63     }
64 }
65
66 // vim:ts=4
67
Popular Tags