de.fub.bytecode.generic
Class InstructionFactory
java.lang.Object
|
+--de.fub.bytecode.generic.InstructionFactory
- public class InstructionFactory
- extends java.lang.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.4 1999/09/09 07:42:53 dahm Exp $
- Author:
- M. Dahm
Method Summary |
static ArrayInstruction |
createArrayLoad(Type type)
|
static ArrayInstruction |
createArrayStore(Type type)
|
static ArithmeticInstruction |
createBinaryOperation(java.lang.String op,
Type type)
Create binary operation for simple basic types, such as int and float. |
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. |
CHECKCAST |
createCheckCast(ReferenceType t)
|
static StackInstruction |
createDup_1(int size)
|
static StackInstruction |
createDup_2(int size)
|
static StackInstruction |
createDup(int size)
|
GETFIELD |
createGetField(java.lang.String class_name,
java.lang.String name,
Type t)
|
GETSTATIC |
createGetStatic(java.lang.String class_name,
java.lang.String name,
Type t)
|
InvokeInstruction |
createInvoke(java.lang.String class_name,
java.lang.String name,
Type ret_type,
Type[] arg_types,
short kind)
Create an invoke instruction. |
static LocalVariableInstruction |
createLoad(Type type,
int index)
|
NEW |
createNew(ObjectType t)
|
NEW |
createNew(java.lang.String s)
|
CPInstruction |
createNewArray(ArrayType t,
short dim)
Create new array. |
static StackInstruction |
createPop(int size)
|
PUTFIELD |
createPutField(java.lang.String class_name,
java.lang.String name,
Type t)
|
PUTSTATIC |
createPutStatic(java.lang.String class_name,
java.lang.String name,
Type t)
|
static ReturnInstruction |
createReturn(Type type)
Create typed return |
static LocalVariableInstruction |
createStore(Type type,
int index)
|
static Instruction |
createThis()
Create reference to `this' |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
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(java.lang.String class_name,
java.lang.String name,
Type ret_type,
Type[] arg_types,
short kind)
- Create an invoke instruction.
- Parameters:
class_name
- name of the called classname
- name of the called methodret_type
- return type of methodarg_types
- argument types of methodkind
- 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(java.lang.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(java.lang.String class_name,
java.lang.String name,
Type t)
createGetStatic
public GETSTATIC createGetStatic(java.lang.String class_name,
java.lang.String name,
Type t)
createPutField
public PUTFIELD createPutField(java.lang.String class_name,
java.lang.String name,
Type t)
createPutStatic
public PUTSTATIC createPutStatic(java.lang.String class_name,
java.lang.String name,
Type t)
createCheckCast
public CHECKCAST createCheckCast(ReferenceType t)
createNew
public NEW createNew(ObjectType t)
createNew
public NEW createNew(java.lang.String s)
createNewArray
public CPInstruction createNewArray(ArrayType t,
short dim)
- Create new array.