mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
Fixed issues with intermixing Addr32 and Add64's.
This commit is contained in:
parent
1cfc169c04
commit
9678044b11
2 changed files with 14 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue