KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > type > TypeDataflow


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.type;
21
22 import java.util.Collection JavaDoc;
23
24 import edu.umd.cs.findbugs.ba.CFG;
25 import edu.umd.cs.findbugs.ba.Dataflow;
26 import edu.umd.cs.findbugs.ba.DataflowAnalysisException;
27 import edu.umd.cs.findbugs.ba.Edge;
28 import edu.umd.cs.findbugs.ba.Location;
29
30 public class TypeDataflow extends Dataflow<TypeFrame, TypeAnalysis> {
31     public static class LocationAndFactPair {
32         public final Location location;
33         public final TypeFrame frame;
34         
35         LocationAndFactPair(Location location, TypeFrame frame) {
36             this.location = location;
37             this.frame = frame;
38         }
39     }
40     
41     public TypeDataflow(CFG cfg, TypeAnalysis analysis) {
42         super(cfg, analysis);
43     }
44
45     public TypeFrame getFactAtLocation(Location loc) throws DataflowAnalysisException {
46         return getAnalysis().getFactAtLocation(loc);
47     }
48
49     public TypeFrame getFactAfterLocation(Location loc) throws DataflowAnalysisException {
50         return getAnalysis().getFactAfterLocation(loc);
51     }
52
53     public ExceptionSet getEdgeExceptionSet(Edge edge) {
54         return getAnalysis().getEdgeExceptionSet(edge);
55     }
56     
57     public LocationAndFactPair getLocationAndFactForInstruction(int pc) {
58         Collection JavaDoc<Location> locations = getCFG().getLocationsContainingInstructionWithOffset(pc);
59         
60         LocationAndFactPair result = null;
61         
62         // Return the first valid frame at any of the returned Locations
63
for (Location location : locations) {
64             try {
65                 TypeFrame frame = getFactAtLocation(location);
66                 if (frame.isValid()) {
67                     result = new LocationAndFactPair(location, frame);
68                     break;
69                 }
70             } catch (DataflowAnalysisException e) {
71                 // Ignore
72
}
73         }
74         
75         return result;
76     }
77 }
78
79 // vim:ts=4
80
Popular Tags