From c66aa5c696a110293418c02d496dbecf22e0f52e Mon Sep 17 00:00:00 2001 From: msridhar1 Date: Tue, 3 Feb 2009 19:22:34 +0000 Subject: [PATCH] implement equals() and hashCode() git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3204 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../ibm/wala/demandpa/util/MemoryAccess.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/com.ibm.wala.core/src/com/ibm/wala/demandpa/util/MemoryAccess.java b/com.ibm.wala.core/src/com/ibm/wala/demandpa/util/MemoryAccess.java index 6d5617407..60cc308b2 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/demandpa/util/MemoryAccess.java +++ b/com.ibm.wala.core/src/com/ibm/wala/demandpa/util/MemoryAccess.java @@ -27,7 +27,7 @@ public class MemoryAccess { * index of the field access instruction in a shrikeBt or SSA instruction * array */ - final int instructionIndex; + final private int instructionIndex; public MemoryAccess(int index, CGNode node) { super(); @@ -53,5 +53,35 @@ public class MemoryAccess { public CGNode getNode() { return node; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + instructionIndex; + result = prime * result + ((node == null) ? 0 : node.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MemoryAccess other = (MemoryAccess) obj; + if (instructionIndex != other.instructionIndex) + return false; + if (node == null) { + if (other.node != null) + return false; + } else if (!node.equals(other.node)) + return false; + return true; + } + + }