Klasse InstructionFactory

java.lang.Object
org.aspectj.apache.bcel.generic.InstructionFactory
Alle implementierten Schnittstellen:
InstructionConstants

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.7 2010/08/23 20:44:10 aclement Exp $
Autor:
M. Dahm
Siehe auch:
  • Felddetails

  • Konstruktordetails

    • InstructionFactory

      public InstructionFactory(ClassGen cg, ConstantPool cp)
    • InstructionFactory

      public InstructionFactory(ClassGen cg)
    • InstructionFactory

      public InstructionFactory(ConstantPool cp)
  • Methodendetails

    • createInvoke

      public InvokeInstruction createInvoke(String class_name, String name, Type ret_type, Type[] arg_types, short kind)
    • createInvoke

      public InvokeInstruction createInvoke(String class_name, String name, Type ret_type, Type[] arg_types, short kind, boolean isInterface)
      Create an invoke instruction.
      Parameter:
      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
      isInterface - for an invokestatic on an interface allows us to tell this method the target is an interface
      Siehe auch:
    • createInvoke

      public InvokeInstruction createInvoke(String class_name, String name, String signature, short kind)
    • createALOAD

      public static Instruction createALOAD(int n)
    • createASTORE

      public static Instruction createASTORE(int n)
    • createConstant

      public Instruction createConstant(Object value)
      Uses PUSH to push a constant value onto the stack.
      Parameter:
      value - must be of type Number, Boolean, Character or String
    • createFieldAccess

      public FieldInstruction createFieldAccess(String class_name, String name, Type type, short kind)
      Create a field instruction.
      Parameter:
      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
      Siehe auch:
    • createThis

      public static Instruction createThis()
      Create reference to `this'
    • createReturn

      public static Instruction createReturn(Type type)
      Create typed return
    • createPop

      public static Instruction createPop(int size)
      Parameter:
      size - size of operand, either 1 (int, e.g.) or 2 (double)
    • createDup

      public static Instruction createDup(int size)
      Parameter:
      size - size of operand, either 1 (int, e.g.) or 2 (double)
    • createDup_2

      public static Instruction createDup_2(int size)
      Parameter:
      size - size of operand, either 1 (int, e.g.) or 2 (double)
    • createDup_1

      public static Instruction createDup_1(int size)
      Parameter:
      size - size of operand, either 1 (int, e.g.) or 2 (double)
    • createStore

      public static InstructionLV createStore(Type type, int index)
      Parameter:
      index - index of local variable
    • createLoad

      public static InstructionLV createLoad(Type type, int index)
      Parameter:
      index - index of local variable
    • createArrayLoad

      public static Instruction createArrayLoad(Type type)
      Parameter:
      type - type of elements of array, i.e., array.getElementType()
    • createArrayStore

      public static Instruction createArrayStore(Type type)
      Parameter:
      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 FieldInstruction createGetField(String class_name, String name, Type t)
    • createGetStatic

      public FieldInstruction createGetStatic(String class_name, String name, Type t)
    • createPutField

      public FieldInstruction createPutField(String class_name, String name, Type t)
    • createPutStatic

      public FieldInstruction createPutStatic(String class_name, String name, Type t)
    • createCheckCast

      public Instruction createCheckCast(ReferenceType t)
    • createInstanceOf

      public Instruction createInstanceOf(ReferenceType t)
    • createNew

      public Instruction createNew(ObjectType t)
    • createNew

      public Instruction createNew(String s)
    • createNewArray

      public Instruction createNewArray(Type t, short dim)
      Create new array of given size and type.
      Gibt zurück:
      an instruction that creates the corresponding array at runtime, i.e. is an AllocationInstruction
    • createNull

      public static Instruction createNull(Type type)
      Create "null" value for reference types, 0 for basic types like int
    • createBranchInstruction

      public static InstructionBranch createBranchInstruction(short opcode, InstructionHandle target)
      Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH. For those you should use the SWITCH compound instruction.
    • setClassGen

      public void setClassGen(ClassGen c)
    • getClassGen

      public ClassGen getClassGen()
    • setConstantPool

      public void setConstantPool(ConstantPool c)
    • getConstantPool

      public ConstantPool getConstantPool()
    • PUSH

      public static Instruction PUSH(ConstantPool cp, int value)
      Returns the right instruction for putting whatever you want onto the stack
    • PUSH

      public static Instruction PUSH(ConstantPool cp, ObjectType t)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, boolean value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, float value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, long value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, double value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, String value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, Number value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, Character value)
    • PUSH

      public static Instruction PUSH(ConstantPool cp, Boolean value)
    • PUSHCLASS

      public InstructionList PUSHCLASS(ConstantPool cp, String className)
      Return a list that will load the Class object - on 1.5 or later use the class variant of ldc, whilst on earlier JVMs use the regular Class.forName.