1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 21:25:58 +02:00

added createAddress(BigInteger)

This commit is contained in:
David Inglis 2004-09-29 13:13:59 +00:00
parent 045dc8071e
commit ca097f54d7
3 changed files with 133 additions and 66 deletions

View file

@ -10,8 +10,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core; package org.eclipse.cdt.core;
import java.math.BigInteger;
/* /**
* This inteface serves as an address factory. If you need to * This inteface serves as an address factory. If you need to
* implement your own addresses, you should extend this. * implement your own addresses, you should extend this.
* *
@ -19,15 +20,19 @@ package org.eclipse.cdt.core;
*/ */
public interface IAddressFactory public interface IAddressFactory
{ {
/* /**
* Returns zero address, i.e. minimal possible address * Returns zero address, i.e. minimal possible address
* @return
*/ */
IAddress getZero(); IAddress getZero();
/*
/**
* Returns maximal address. * Returns maximal address.
* @return
*/ */
IAddress getMax(); IAddress getMax();
/*
/**
* Creates address from string representation. * Creates address from string representation.
* *
* 1. This method should be able to create address from hex * 1. This method should be able to create address from hex
@ -38,14 +43,30 @@ public interface IAddressFactory
* representation * representation
* *
* Please see Addr32Factory.createAddress() for reference implementation. * Please see Addr32Factory.createAddress() for reference implementation.
*
* @param addr
* @return
*/ */
IAddress createAddress(String addr); IAddress createAddress(String addr);
/*
/**
* Creates address from string with given radix. * Creates address from string with given radix.
* *
* Given string should not contain any prefixes or sign numbers. * Given string should not contain any prefixes or sign numbers.
* *
* Method should be case insensetive * Method should be case insensetive
*
* @param addr
* @param radix
* @return
*/ */
IAddress createAddress(String addr, int radix); IAddress createAddress(String addr, int radix);
/**
* Create address from a BigInteger
*
* @param addr
* @return
*/
IAddress createAddress(BigInteger addr);
} }

View file

@ -1,44 +1,66 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004 Intel Corporation and others. * Copyright (c) 2004 Intel Corporation and others. All rights reserved. This
* All rights reserved. This program and the accompanying materials * program and the accompanying materials are made available under the terms of
* are made available under the terms of the Common Public License v1.0 * the Common Public License v1.0 which accompanies this distribution, and is
* which accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: Intel Corporation - Initial API and implementation
* Intel Corporation - Initial API and implementation ******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.utils; package org.eclipse.cdt.utils;
import java.math.BigInteger;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IAddressFactory;
public class Addr32Factory implements IAddressFactory {
/* /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IAddressFactory#getZero()
*/ */
final public class Addr32Factory implements IAddressFactory public IAddress getZero() {
{
final public IAddress getZero()
{
return Addr32.ZERO; return Addr32.ZERO;
} }
final public IAddress getMax() /*
{ * (non-Javadoc)
*
* @see org.eclipse.cdt.core.IAddressFactory#getMax()
*/
public IAddress getMax() {
return Addr32.MAX; return Addr32.MAX;
} }
final public IAddress createAddress(String addr) /*
{ * (non-Javadoc)
IAddress address=new Addr32(addr); *
* @see org.eclipse.cdt.core.IAddressFactory#createAddress(java.lang.String)
*/
public IAddress createAddress(String addr) {
IAddress address = new Addr32(addr);
return address; return address;
} }
final public IAddress createAddress(String addr, int radix) /*
{ * (non-Javadoc)
IAddress address=new Addr32(addr, radix); *
* @see org.eclipse.cdt.core.IAddressFactory#createAddress(java.lang.String,
* int)
*/
public IAddress createAddress(String addr, int radix) {
IAddress address = new Addr32(addr, radix);
return address; return address;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IAddressFactory#createAddress(java.math.BigInteger)
*/
public IAddress createAddress(BigInteger addr) {
IAddress address = new Addr32(addr.longValue());
return address;
}
} }

View file

@ -1,42 +1,66 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004 Intel Corporation and others. * Copyright (c) 2004 Intel Corporation and others. All rights reserved. This
* All rights reserved. This program and the accompanying materials * program and the accompanying materials are made available under the terms of
* are made available under the terms of the Common Public License v1.0 * the Common Public License v1.0 which accompanies this distribution, and is
* which accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v10.html
* http://www.eclipse.org/legal/cpl-v10.html
* *
* Contributors: * Contributors: Intel Corporation - Initial API and implementation
* Intel Corporation - Initial API and implementation ******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.utils; package org.eclipse.cdt.utils;
import java.math.BigInteger;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IAddressFactory;
public class Addr64Factory implements IAddressFactory {
/* /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IAddressFactory#getZero()
*/ */
final public class Addr64Factory implements IAddressFactory{ public IAddress getZero() {
final public IAddress getZero()
{
return Addr64.ZERO; return Addr64.ZERO;
} }
final public IAddress getMax() /*
{ * (non-Javadoc)
*
* @see org.eclipse.cdt.core.IAddressFactory#getMax()
*/
public IAddress getMax() {
return Addr64.MAX; return Addr64.MAX;
} }
final public IAddress createAddress(String addr) /*
{ * (non-Javadoc)
IAddress address=new Addr64(addr); *
* @see org.eclipse.cdt.core.IAddressFactory#createAddress(java.lang.String)
*/
public IAddress createAddress(String addr) {
IAddress address = new Addr64(addr);
return address; return address;
} }
final public IAddress createAddress(String addr, int radix) /*
{ * (non-Javadoc)
IAddress address=new Addr64(addr, radix); *
* @see org.eclipse.cdt.core.IAddressFactory#createAddress(java.lang.String,
* int)
*/
public IAddress createAddress(String addr, int radix) {
IAddress address = new Addr64(addr, radix);
return address;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.IAddressFactory#createAddress(java.math.BigInteger)
*/
public IAddress createAddress(BigInteger addr) {
IAddress address = new Addr64(addr);
return address; return address;
} }
} }