01: /*
02: * Bytecode Analysis Framework
03: * Copyright (C) 2003-2005 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: package edu.umd.cs.findbugs.ba.npe;
20:
21: import edu.umd.cs.findbugs.ba.Edge;
22: import edu.umd.cs.findbugs.ba.Location;
23:
24: /**
25: * An instruction recorded as a redundant reference comparison. We keep track of
26: * the line number, in order to ensure that if the branch was duplicated, all
27: * duplicates are determined in the same way. (If they aren't, then we don't
28: * report it.)
29: */
30: public class RedundantBranch {
31: public final Location location;
32:
33: public final int lineNumber;
34:
35: public final IsNullValue firstValue, secondValue;
36:
37: public Edge infeasibleEdge;
38:
39: /**
40: * Constructor.
41: *
42: * @param location
43: * Location of ref comparison
44: * @param lineNumber
45: * line number of ref comparison
46: * @param firstValue
47: * first value compared
48: * @param secondValue
49: * second value compared
50: */
51: public RedundantBranch(Location location, int lineNumber,
52: IsNullValue firstValue, IsNullValue secondValue) {
53: this .location = location;
54: this .lineNumber = lineNumber;
55: this .firstValue = firstValue;
56: this .secondValue = secondValue;
57: }
58:
59: /**
60: * Constructor.
61: *
62: * @param location
63: * Location of ref comparison
64: * @param lineNumber
65: * line number of ref comparison
66: * @param firstValue
67: * first value compared
68: */
69: public RedundantBranch(Location location, int lineNumber,
70: IsNullValue firstValue) {
71: this .location = location;
72: this .lineNumber = lineNumber;
73: this .firstValue = firstValue;
74: this .secondValue = null;
75: }
76:
77: /**
78: * Set the edge which has been determined to be infeasible.
79: *
80: * @param infeasibleEdge The infeasibleEdge to set.
81: */
82: public void setInfeasibleEdge(Edge infeasibleEdge) {
83: this .infeasibleEdge = infeasibleEdge;
84: }
85:
86: @Override
87: public String toString() {
88: return location.toString() + ": line " + lineNumber;
89: }
90: }
|