1
0
Fork 0
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:
Alena Laskavaia 2014-12-18 11:00:13 -05:00 committed by Elena Laskavaia
parent bcc3aad840
commit 5626442f0e
2 changed files with 21 additions and 0 deletions

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.utils;
import java.io.Serializable;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.internal.core.Messages;
@ -51,6 +52,19 @@ public class Addr64 implements IAddress, Serializable {
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) {
addr = addr.toLowerCase();
if (addr.startsWith("0x")) { //$NON-NLS-1$

View file

@ -80,4 +80,11 @@ public class Addr64Factory implements IAddressFactory2 {
public IAddress createAddress(BigInteger addr, boolean truncate) {
return new Addr64(addr, truncate);
}
/**
* @since 5.9
*/
public IAddress createAddress(long addr) {
return new Addr64(addr);
}
}