01: /*
02: * Bytecode Analysis Framework
03: * Copyright (C) 2003-2007 University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
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 ExceptionSet getEdgeExceptionSet(Edge edge) {
46: return getAnalysis().getEdgeExceptionSet(edge);
47: }
48:
49: public LocationAndFactPair getLocationAndFactForInstruction(int pc) {
50: Collection<Location> locations = getCFG()
51: .getLocationsContainingInstructionWithOffset(pc);
52:
53: LocationAndFactPair result = null;
54:
55: // Return the first valid frame at any of the returned Locations
56: for (Location location : locations) {
57: try {
58: TypeFrame frame = getFactAtLocation(location);
59: if (frame.isValid()) {
60: result = new LocationAndFactPair(location, frame);
61: break;
62: }
63: } catch (DataflowAnalysisException e) {
64: // Ignore
65: }
66: }
67:
68: return result;
69: }
70: }
71:
72: // vim:ts=4
|