org.apache.bcel.generic
public class InstructionFactory extends Object implements InstructionConstants, Serializable
See Also: Constants
Field Summary | |
---|---|
protected ClassGen | cg |
protected ConstantPoolGen | cp |
Constructor Summary | |
---|---|
InstructionFactory(ClassGen cg, ConstantPoolGen cp) | |
InstructionFactory(ClassGen cg) Initialize with ClassGen object | |
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(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) |
Instruction | createConstant(Object value) Uses PUSH to push a constant value onto the stack. |
static StackInstruction | createDup(int size) |
static StackInstruction | createDup_1(int size) |
static StackInstruction | createDup_2(int size) |
FieldInstruction | createFieldAccess(String class_name, String name, Type type, short kind) Create a field instruction.
|
GETFIELD | createGetField(String class_name, String name, Type t) |
GETSTATIC | createGetStatic(String class_name, String name, Type t) |
INSTANCEOF | createInstanceOf(ReferenceType t) |
InvokeInstruction | createInvoke(String class_name, 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(String s) |
Instruction | 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(String s) Create a call to the most popular System.out.println() method.
|
PUTFIELD | createPutField(String class_name, String name, Type t) |
PUTSTATIC | createPutStatic(String class_name, 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) |
Parameters: type type of elements of array, i.e., array.getElementType()
Parameters: type type of elements of array, i.e., array.getElementType()
Parameters: op operation, such as "+", "*", "<<", etc.
Parameters: value must be of type Number, Boolean, Character or String
Parameters: size size of operand, either 1 (int, e.g.) or 2 (double)
Parameters: size size of operand, either 1 (int, e.g.) or 2 (double)
Parameters: size size of operand, either 1 (int, e.g.) or 2 (double)
Parameters: class_name name of the accessed class name name of the referenced field type type of field kind how to access, i.e., GETFIELD, PUTFIELD, GETSTATIC, PUTSTATIC
See Also: Constants
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
See Also: Constants
Parameters: index index of local variable
Returns: an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction
Parameters: size size of operand, either 1 (int, e.g.) or 2 (double)
Parameters: s the string to print
Parameters: index index of local variable