01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 1997-1999 Raja Vallee-Rai
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: */
19:
20: /*
21: * Modified by the Sable Research Group and others 1997-1999.
22: * See the 'credits' file distributed with Soot for the complete list of
23: * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24: */
25:
26: package soot.toolkits.scalar;
27:
28: import soot.*;
29:
30: /**
31: * Utility class used to package a Unit and a ValueBox together.
32: */
33: public class UnitValueBoxPair {
34: public Unit unit;
35: public ValueBox valueBox;
36:
37: /**
38: * Constructs a UnitValueBoxPair form a Unit object and a ValueBox object.
39: * @param local some Local
40: * @param unit some Unit.
41: */
42: public UnitValueBoxPair(Unit unit, ValueBox valueBox) {
43: this .unit = unit;
44: this .valueBox = valueBox;
45: }
46:
47: /**
48: * Two UnitValueBoxPairs are equal iff they the Unit they hold are 'equal' and
49: * the ValueBoxes they hold are 'equal'.
50: * @param other another UnitValueBoxPair
51: * @return true if equal.
52: */
53: public boolean equals(Object other) {
54: if (other instanceof UnitValueBoxPair) {
55: UnitValueBoxPair otherPair = (UnitValueBoxPair) other;
56:
57: if (unit.equals(otherPair.unit)
58: && valueBox.equals(otherPair.valueBox))
59: return true;
60: }
61:
62: return false;
63: }
64:
65: public int hashCode() {
66: return unit.hashCode() + valueBox.hashCode();
67: }
68:
69: public String toString() {
70: return valueBox + " in " + unit;
71: }
72:
73: public Unit getUnit() {
74: return unit;
75: }
76:
77: public ValueBox getValueBox() {
78: return valueBox;
79: }
80:
81: }
|