All Packages Class Hierarchy This Package Previous Next Index
Class de.fub.bytecode.generic.ConstantPoolGen
java.lang.Object
|
+----de.fub.bytecode.generic.ConstantPoolGen
- public class ConstantPoolGen
- extends Object
- implements Constants
This class is used to build up a constant pool. The user adds
constants via `addXXX' methods, `addString', `addClass',
etc.. These methods return an index into the constant
pool. Finally, `getFinalConstantPool()' returns the constant pool
built up. Intermediate versions of the constant pool can be
obtained with `getConstantPool()'. A constant pool has capacity for
Constants.MAX_SHORT entries. Note that the first (0) is used by the
JVM and that Double and Long constants need two slots.
- Version:
- $Id: ConstantPoolGen.java,v 1.15 1999/12/03 14:31:03 dahm Exp $
- Author:
- M. Dahm
- See Also:
- Constant
-
constants
-
-
index
-
-
size
-
-
ConstantPoolGen()
- Create empty constant pool.
-
ConstantPoolGen(Constant[])
- Initialize with given array of constants.
-
ConstantPoolGen(ConstantPool)
- Initialize with given constant pool.
-
addArrayClass(ArrayType)
- Add a reference to an array class (e.g.
-
addClass(ObjectType)
- Add a new Class reference to the ConstantPool for a given type.
-
addClass(String)
- Add a new Class reference to the ConstantPool, if it is not already in there.
-
addDouble(double)
- Add a new double constant to the ConstantPool, if it is not already in there.
-
addFieldref(String, String, String)
- Add a new Fieldref constant to the ConstantPool, if it is not already
in there.
-
addFloat(float)
- Add a new Float constant to the ConstantPool, if it is not already in there.
-
addInteger(int)
- Add a new Integer constant to the ConstantPool, if it is not already in there.
-
addInterfaceMethodref(MethodGen)
-
-
addInterfaceMethodref(String, String, String)
- Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
in there.
-
addLong(long)
- Add a new long constant to the ConstantPool, if it is not already in there.
-
addMethodref(MethodGen)
-
-
addMethodref(String, String, String)
- Add a new Methodref constant to the ConstantPool, if it is not already
in there.
-
addNameAndType(String, String)
- Add a new NameAndType constant to the ConstantPool if it is not already
in there.
-
addString(String)
- Add a new String constant to the ConstantPool, if it is not already in there.
-
addUtf8(String)
- Add a new Utf8 constant to the ConstantPool, if it is not already in there.
-
adjustSize()
- Resize internal array of constants.
-
getConstant(int)
-
-
getConstantPool()
-
-
getFinalConstantPool()
-
-
getSize()
-
-
lookupClass(String)
- Look for ConstantClass in ConstantPool named `str'.
-
lookupDouble(double)
-
Look for ConstantDouble in ConstantPool.
-
lookupFieldref(String, String, String)
-
Look for ConstantFieldref in ConstantPool.
-
lookupFloat(float)
-
Look for ConstantFloat in ConstantPool.
-
lookupInteger(int)
-
Look for ConstantInteger in ConstantPool.
-
lookupInterfaceMethodref(MethodGen)
-
-
lookupInterfaceMethodref(String, String, String)
-
Look for ConstantInterfaceMethodref in ConstantPool.
-
lookupLong(long)
-
Look for ConstantLong in ConstantPool.
-
lookupMethodref(MethodGen)
-
-
lookupMethodref(String, String, String)
-
Look for ConstantMethodref in ConstantPool.
-
lookupNameAndType(String, String)
-
Look for ConstantNameAndType in ConstantPool.
-
lookupString(String)
-
Look for ConstantString in ConstantPool containing String `str'.
-
lookupUtf8(String)
-
Look for ConstantUtf8 in ConstantPool.
-
setConstant(int, Constant)
- Use with care!
-
toString()
-
size
protected int size
constants
protected Constant constants[]
index
protected int index
ConstantPoolGen
public ConstantPoolGen(Constant cs[])
- Initialize with given array of constants.
- Parameters:
- c - array of given constants, new ones will be appended
ConstantPoolGen
public ConstantPoolGen(ConstantPool cp)
- Initialize with given constant pool.
ConstantPoolGen
public ConstantPoolGen()
- Create empty constant pool.
adjustSize
protected void adjustSize()
- Resize internal array of constants.
lookupString
public int lookupString(String str)
- Look for ConstantString in ConstantPool containing String `str'.
- Parameters:
- str - String to search for
- Returns:
- index on success, -1 otherwise
addString
public int addString(String str)
- Add a new String constant to the ConstantPool, if it is not already in there.
- Parameters:
- str - String to add
- Returns:
- index of entry
lookupClass
public int lookupClass(String str)
- Look for ConstantClass in ConstantPool named `str'.
- Parameters:
- str - String to search for
- Returns:
- index on success, -1 otherwise
addClass
public int addClass(String str)
- Add a new Class reference to the ConstantPool, if it is not already in there.
- Parameters:
- str - Class to add
- Returns:
- index of entry
addClass
public int addClass(ObjectType type)
- Add a new Class reference to the ConstantPool for a given type.
- Parameters:
- str - Class to add
- Returns:
- index of entry
addArrayClass
public int addArrayClass(ArrayType type)
- Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY
instruction, e.g. to the ConstantPool.
- Parameters:
- type - type of array class
- Returns:
- index of entry
lookupInteger
public int lookupInteger(int n)
- Look for ConstantInteger in ConstantPool.
- Parameters:
- n - integer number to look for
- Returns:
- index on success, -1 otherwise
addInteger
public int addInteger(int n)
- Add a new Integer constant to the ConstantPool, if it is not already in there.
- Parameters:
- n - integer number to add
- Returns:
- index of entry
lookupFloat
public int lookupFloat(float n)
- Look for ConstantFloat in ConstantPool.
- Parameters:
- n - Float number to look for
- Returns:
- index on success, -1 otherwise
addFloat
public int addFloat(float n)
- Add a new Float constant to the ConstantPool, if it is not already in there.
- Parameters:
- n - Float number to add
- Returns:
- index of entry
lookupUtf8
public int lookupUtf8(String n)
- Look for ConstantUtf8 in ConstantPool.
- Parameters:
- n - Utf8 string to look for
- Returns:
- index on success, -1 otherwise
addUtf8
public int addUtf8(String n)
- Add a new Utf8 constant to the ConstantPool, if it is not already in there.
- Parameters:
- n - Utf8 string to add
- Returns:
- index of entry
lookupLong
public int lookupLong(long n)
- Look for ConstantLong in ConstantPool.
- Parameters:
- n - Long number to look for
- Returns:
- index on success, -1 otherwise
addLong
public int addLong(long n)
- Add a new long constant to the ConstantPool, if it is not already in there.
- Parameters:
- n - Long number to add
- Returns:
- index of entry
lookupDouble
public int lookupDouble(double n)
- Look for ConstantDouble in ConstantPool.
- Parameters:
- n - Double number to look for
- Returns:
- index on success, -1 otherwise
addDouble
public int addDouble(double n)
- Add a new double constant to the ConstantPool, if it is not already in there.
- Parameters:
- n - Double number to add
- Returns:
- index of entry
lookupNameAndType
public int lookupNameAndType(String name,
String signature)
- Look for ConstantNameAndType in ConstantPool.
- Parameters:
- name - of variable/method
- signature - of variable/method
- Returns:
- index on success, -1 otherwise
addNameAndType
public int addNameAndType(String name,
String signature)
- Add a new NameAndType constant to the ConstantPool if it is not already
in there.
- Parameters:
- n - NameAndType string to add
- Returns:
- index of entry
lookupMethodref
public int lookupMethodref(String class_name,
String method_name,
String signature)
- Look for ConstantMethodref in ConstantPool.
- Parameters:
- class_name - Where to find method
- method_name - Guess what
- signature - return and argument types
- Returns:
- index on success, -1 otherwise
lookupMethodref
public int lookupMethodref(MethodGen method)
addMethodref
public int addMethodref(String class_name,
String method_name,
String signature)
- Add a new Methodref constant to the ConstantPool, if it is not already
in there.
- Parameters:
- n - Methodref string to add
- Returns:
- index of entry
addMethodref
public int addMethodref(MethodGen method)
lookupInterfaceMethodref
public int lookupInterfaceMethodref(String class_name,
String method_name,
String signature)
- Look for ConstantInterfaceMethodref in ConstantPool.
- Parameters:
- class_name - Where to find method
- method_name - Guess what
- signature - return and argument types
- Returns:
- index on success, -1 otherwise
lookupInterfaceMethodref
public int lookupInterfaceMethodref(MethodGen method)
addInterfaceMethodref
public int addInterfaceMethodref(String class_name,
String method_name,
String signature)
- Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
in there.
- Parameters:
- n - InterfaceMethodref string to add
- Returns:
- index of entry
addInterfaceMethodref
public int addInterfaceMethodref(MethodGen method)
lookupFieldref
public int lookupFieldref(String class_name,
String field_name,
String signature)
- Look for ConstantFieldref in ConstantPool.
- Parameters:
- class_name - Where to find method
- field_name - Guess what
- signature - return and argument types
- Returns:
- index on success, -1 otherwise
addFieldref
public int addFieldref(String class_name,
String field_name,
String signature)
- Add a new Fieldref constant to the ConstantPool, if it is not already
in there.
- Parameters:
- n - Fieldref string to add
- Returns:
- index of entry
getConstant
public Constant getConstant(int i)
- Parameters:
- i - index in constant pool
- Returns:
- constant pool entry at index i
setConstant
public void setConstant(int i,
Constant c)
- Use with care!
- Parameters:
- i - index in constant pool
- c - new constant pool entry at index i
getConstantPool
public ConstantPool getConstantPool()
- Returns:
- intermediate constant pool
getSize
public int getSize()
- Returns:
- current size of constant pool
getFinalConstantPool
public ConstantPool getFinalConstantPool()
- Returns:
- constant pool with proper length
toString
public String toString()
- Returns:
- String representation.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index