From 9678044b11e6bc5bd2a7143c71e3355d807368af Mon Sep 17 00:00:00 2001 From: Ken Ryall Date: Fri, 30 Oct 2009 20:56:12 +0000 Subject: [PATCH] Fixed issues with intermixing Addr32 and Add64's. --- .../utils/org/eclipse/cdt/utils/Addr32.java | 20 ++++++------------- .../utils/org/eclipse/cdt/utils/Addr64.java | 15 +++++++------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java index fc9eb96aac7..4137dbcad4f 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr32.java @@ -93,23 +93,15 @@ public class Addr32 implements IAddress { } 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 class Addr32 implements IAddress { 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 diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java index a1e4776db6a..f0e3ffe5ee6 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java @@ -93,10 +93,7 @@ public class Addr64 implements IAddress { } 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 class Addr64 implements IAddress { } 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