|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.fub.bytecode.generic.InstructionFactory
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.
Constants
Inner classes inherited from class de.fub.bytecode.generic.InstructionConstants |
InstructionConstants.Clinit |
Field Summary | |
protected ClassGen |
cg
|
protected ConstantPoolGen |
cp
|
Fields inherited from interface de.fub.bytecode.generic.InstructionConstants |
AALOAD, AASTORE, ACONST_NULL, ALOAD_0, ALOAD_1, ALOAD_2, ARETURN, ARRAYLENGTH, ASTORE_0, ASTORE_1, ASTORE_2, ATHROW, BALOAD, BASTORE, bla, CALOAD, CASTORE, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DMUL, DNEG, DREM, DRETURN, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FMUL, FNEG, FREM, FRETURN, FSUB, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, ILOAD_0, ILOAD_1, ILOAD_2, IMUL, INEG, INSTRUCTIONS, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE_0, ISTORE_1, ISTORE_2, ISUB, IUSHR, IXOR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDIV, LMUL, LNEG, LOR, LREM, LRETURN, LSHL, LSHR, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, NOP, POP, POP2, RETURN, SALOAD, SASTORE, SWAP, THIS |
Constructor Summary | |
InstructionFactory(ClassGen cg)
Initialize with ClassGen object |
|
InstructionFactory(ClassGen cg,
ConstantPoolGen cp)
|
|
InstructionFactory(ConstantPoolGen cp)
Initialize just with ConstantPoolGen object |
Method Summary | |
Instruction |
createAppend(Type type)
|
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. |
static BranchInstruction |
createBranchInstruction(short opcode,
InstructionHandle target)
Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH. |
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)
|
FieldInstruction |
createFieldAccess(java.lang.String class_name,
java.lang.String name,
Type type,
short kind)
Create a field instruction. |
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)
|
AllocationInstruction |
createNewArray(Type t,
short dim)
Create new array of given size and type. |
static Instruction |
createNull(Type type)
Create "null" value for reference types, 0 for basic types like int |
static StackInstruction |
createPop(int size)
|
InstructionList |
createPrintln(java.lang.String s)
Create a call to the most popular System.out.println() method. |
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' |
ClassGen |
getClassGen()
|
ConstantPoolGen |
getConstantPool()
|
void |
setClassGen(ClassGen c)
|
void |
setConstantPool(ConstantPoolGen c)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ClassGen cg
protected ConstantPoolGen cp
Constructor Detail |
public InstructionFactory(ClassGen cg, ConstantPoolGen cp)
public InstructionFactory(ClassGen cg)
public InstructionFactory(ConstantPoolGen cp)
Method Detail |
public InvokeInstruction createInvoke(java.lang.String class_name, java.lang.String name, Type ret_type, Type[] arg_types, short kind)
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 INVOKESPECIALConstants
public InstructionList createPrintln(java.lang.String s)
s
- the string to printpublic Instruction createAppend(Type type)
public FieldInstruction createFieldAccess(java.lang.String class_name, java.lang.String name, Type type, short kind)
class_name
- name of the accessed classname
- name of the referenced fieldtype
- type of fieldkind
- how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATICConstants
public static Instruction createThis()
public static ReturnInstruction createReturn(Type type)
public static ArithmeticInstruction createBinaryOperation(java.lang.String op, Type type)
op
- operation, such as "+", "*", "<<", etc.public static StackInstruction createPop(int size)
size
- size of operand, either 1 (int, e.g.) or 2 (double)public static StackInstruction createDup(int size)
size
- size of operand, either 1 (int, e.g.) or 2 (double)public static StackInstruction createDup_2(int size)
size
- size of operand, either 1 (int, e.g.) or 2 (double)public static StackInstruction createDup_1(int size)
size
- size of operand, either 1 (int, e.g.) or 2 (double)public static LocalVariableInstruction createStore(Type type, int index)
index
- index of local variablepublic static LocalVariableInstruction createLoad(Type type, int index)
index
- index of local variablepublic static ArrayInstruction createArrayLoad(Type type)
type
- type of elements of array, i.e., array.getElementType()public static ArrayInstruction createArrayStore(Type type)
type
- type of elements of array, i.e., array.getElementType()public Instruction createCast(Type src_type, Type dest_type)
public GETFIELD createGetField(java.lang.String class_name, java.lang.String name, Type t)
public GETSTATIC createGetStatic(java.lang.String class_name, java.lang.String name, Type t)
public PUTFIELD createPutField(java.lang.String class_name, java.lang.String name, Type t)
public PUTSTATIC createPutStatic(java.lang.String class_name, java.lang.String name, Type t)
public CHECKCAST createCheckCast(ReferenceType t)
public NEW createNew(ObjectType t)
public NEW createNew(java.lang.String s)
public AllocationInstruction createNewArray(Type t, short dim)
public static Instruction createNull(Type type)
public static BranchInstruction createBranchInstruction(short opcode, InstructionHandle target)
public void setClassGen(ClassGen c)
public ClassGen getClassGen()
public void setConstantPool(ConstantPoolGen c)
public ConstantPoolGen getConstantPool()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |