mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added API to construct Addr64 from long
Change-Id: Iccb489f290711d806d499cfa763a06dab4e61f4d Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/38496 Tested-by: Hudson CI Reviewed-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
bcc3aad840
commit
5626442f0e
2 changed files with 21 additions and 0 deletions
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.utils;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IAddress;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
import org.eclipse.cdt.internal.core.Messages;
|
import org.eclipse.cdt.internal.core.Messages;
|
||||||
|
@ -51,6 +52,19 @@ public class Addr64 implements IAddress, Serializable {
|
||||||
this(addr, true);
|
this(addr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an address represented by long bits.
|
||||||
|
* Signed bit will be used as unsigned extension, if you don't want it mask it before passing here.
|
||||||
|
*
|
||||||
|
* @since 5.9
|
||||||
|
*/
|
||||||
|
public Addr64(long addr) {
|
||||||
|
if (addr < 0)
|
||||||
|
address = new BigInteger(1, ByteBuffer.allocate(8).putLong(addr).array());
|
||||||
|
else
|
||||||
|
address = BigInteger.valueOf(addr);
|
||||||
|
}
|
||||||
|
|
||||||
public Addr64(String addr, boolean truncate) {
|
public Addr64(String addr, boolean truncate) {
|
||||||
addr = addr.toLowerCase();
|
addr = addr.toLowerCase();
|
||||||
if (addr.startsWith("0x")) { //$NON-NLS-1$
|
if (addr.startsWith("0x")) { //$NON-NLS-1$
|
||||||
|
|
|
@ -80,4 +80,11 @@ public class Addr64Factory implements IAddressFactory2 {
|
||||||
public IAddress createAddress(BigInteger addr, boolean truncate) {
|
public IAddress createAddress(BigInteger addr, boolean truncate) {
|
||||||
return new Addr64(addr, truncate);
|
return new Addr64(addr, truncate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.9
|
||||||
|
*/
|
||||||
|
public IAddress createAddress(long addr) {
|
||||||
|
return new Addr64(addr);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue