All Packages Class Hierarchy This Package Previous Next Index
Class de.fub.bytecode.generic.InstructionFactory
java.lang.Object
|
+----de.fub.bytecode.generic.InstructionFactory
- public class InstructionFactory
- extends Object
- implements InstructionConstants
Instances of this class may be used, e.g., to generate typed
versions of instructions. Its main purpose is to be used as the
byte code generating backend of a compiler. You can subclass it to
add your own create methods.
- Version:
- $Id: InstructionFactory.java,v 1.5 2000/02/22 09:34:47 dahm Exp $
- Author:
- M. Dahm
-
cg
-
-
cp
-
-
InstructionFactory(ClassGen)
- Need a ClassGen object to obtain a constant pool, e.g.
-
createArrayLoad(Type)
-
-
createArrayStore(Type)
-
-
createBinaryOperation(String, Type)
- Create binary operation for simple basic types, such as int and float.
-
createCast(Type, Type)
- Create conversion operation for two stack operands, this may be an I2C, instruction, e.g.,
if the operands are basic types and CHECKCAST if they are reference types.
-
createCheckCast(ReferenceType)
-
-
createDup(int)
-
-
createDup_1(int)
-
-
createDup_2(int)
-
-
createGetField(String, String, Type)
-
-
createGetStatic(String, String, Type)
-
-
createInvoke(String, String, Type, Type[], short)
- Create an invoke instruction.
-
createLoad(Type, int)
-
-
createNew(ObjectType)
-
-
createNew(String)
-
-
createNewArray(Type, short)
- Create new array of given size and type.
-
createNull(Type)
- Create "null" value for reference types, 0 for basic types like int
-
createPop(int)
-
-
createPutField(String, String, Type)
-
-
createPutStatic(String, String, Type)
-
-
createReturn(Type)
- Create typed return
-
createStore(Type, int)
-
-
createThis()
- Create reference to `this'
cg
protected ClassGen cg
cp
protected ConstantPoolGen cp
InstructionFactory
public InstructionFactory(ClassGen cg)
- Need a ClassGen object to obtain a constant pool, e.g.
createInvoke
public InvokeInstruction createInvoke(String class_name,
String name,
Type ret_type,
Type arg_types[],
short kind)
- Create an invoke instruction.
- Parameters:
- class_name - name of the called class
- name - name of the called method
- ret_type - return type of method
- arg_types - argument types of method
- kind - how to invoke, i.e. INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL,
or INVOKESPECIAL
createThis
public static Instruction createThis()
- Create reference to `this'
createReturn
public static ReturnInstruction createReturn(Type type)
- Create typed return
createBinaryOperation
public static ArithmeticInstruction createBinaryOperation(String op,
Type type)
- Create binary operation for simple basic types, such as int and float.
- Parameters:
- op - operation, such as "+", "*", "<<", etc.
createPop
public static StackInstruction createPop(int size)
- Parameters:
- size - size of operand, either 1 (int, e.g.) or 2 (double)
createDup
public static StackInstruction createDup(int size)
- Parameters:
- size - size of operand, either 1 (int, e.g.) or 2 (double)
createDup_2
public static StackInstruction createDup_2(int size)
- Parameters:
- size - size of operand, either 1 (int, e.g.) or 2 (double)
createDup_1
public static StackInstruction createDup_1(int size)
- Parameters:
- size - size of operand, either 1 (int, e.g.) or 2 (double)
createStore
public static LocalVariableInstruction createStore(Type type,
int index)
- Parameters:
- index - index of local variable
createLoad
public static LocalVariableInstruction createLoad(Type type,
int index)
- Parameters:
- index - index of local variable
createArrayLoad
public static ArrayInstruction createArrayLoad(Type type)
- Parameters:
- type - type of elements of array, i.e. array.getElementType()
createArrayStore
public static ArrayInstruction createArrayStore(Type type)
- Parameters:
- type - type of elements of array, i.e. array.getElementType()
createCast
public Instruction createCast(Type src_type,
Type dest_type)
- Create conversion operation for two stack operands, this may be an I2C, instruction, e.g.,
if the operands are basic types and CHECKCAST if they are reference types.
createGetField
public GETFIELD createGetField(String class_name,
String name,
Type t)
createGetStatic
public GETSTATIC createGetStatic(String class_name,
String name,
Type t)
createPutField
public PUTFIELD createPutField(String class_name,
String name,
Type t)
createPutStatic
public PUTSTATIC createPutStatic(String class_name,
String name,
Type t)
createCheckCast
public CHECKCAST createCheckCast(ReferenceType t)
createNew
public NEW createNew(ObjectType t)
createNew
public NEW createNew(String s)
createNewArray
public AllocationInstruction createNewArray(Type t,
short dim)
- Create new array of given size and type.
createNull
public static Instruction createNull(Type type)
- Create "null" value for reference types, 0 for basic types like int
All Packages Class Hierarchy This Package Previous Next Index