fixed issues with intermixing Addr32 and Add64's.
authorwpaul
Thu, 27 Aug 2009 11:35:06 -0500
changeset 76 458fc5858693
parent 75 689d22da9f18
child 78 f17d142f8a47
fixed issues with intermixing Addr32 and Add64's.
cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java
cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java	Mon Aug 24 10:17:24 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java	Thu Aug 27 11:35:06 2009 -0500
@@ -93,23 +93,15 @@
 	}
 
 	public BigInteger distanceTo(IAddress other) {
-		if (!(other instanceof Addr32)) {
-			throw new IllegalArgumentException();
-		}
-		return BigInteger.valueOf(((Addr32)other).address - address);
+		return other.getValue().subtract(getValue());
 	}
 
 	public int compareTo(Object other) {
-		if (!(other instanceof Addr32)) {
+		if (!(other instanceof IAddress)) {
 			throw new IllegalArgumentException();
 		}
-		if (address > ((Addr32)other).address) {
-			return 1;
-		}
-		if (address < ((Addr32)other).address) {
-			return -1;
-		}
-		return 0;
+		
+		return getValue().compareTo(((IAddress)other).getValue());
 	}
 
 	public boolean isMax() {
@@ -133,9 +125,9 @@
 	public boolean equals(Object x) {
 		if (x == this)
 			return true;
-		if (!(x instanceof Addr32))
+		if (!(x instanceof IAddress))
 			return false;
-		return this.address == ((Addr32)x).address;
+		return getValue().equals(((IAddress)x).getValue());
 	}
 
 	@Override
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java	Mon Aug 24 10:17:24 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java	Thu Aug 27 11:35:06 2009 -0500
@@ -93,10 +93,7 @@
 	}
 
 	public BigInteger distanceTo(IAddress other) {
-		if (! (other instanceof Addr64)) {
-			throw new IllegalArgumentException();
-		}
-		return ((Addr64)other).address.add(address.negate());
+		return other.getValue().subtract(getValue());
 	}
 
 	public boolean isMax() {
@@ -112,16 +109,20 @@
 	}
 
 	public int compareTo(Object other) {
-		return this.address.compareTo(((Addr64)other).address);
+		if (!(other instanceof IAddress)) {
+			throw new IllegalArgumentException();
+		}
+		
+		return getValue().compareTo(((IAddress)other).getValue());
 	}
 
 	@Override
 	public boolean equals(Object x) {
 		if (x == this)
 			return true;
-		if (! (x instanceof Addr64))
+		if (!(x instanceof IAddress))
 			return false;
-		return this.address.equals(((Addr64)x).address);
+		return getValue().equals(((IAddress)x).getValue());
 	}
 
 	@Override