Class InstructionBuilder


  • public class InstructionBuilder
    extends InstructionFactory
    Instruction builder. Extends the basic instruction construction tools in BCEL with some convenience methods.
    Version:
    1.0
    Author:
    Dennis M. Sosnoski
    • Constructor Summary

      Constructors 
      Constructor Description
      InstructionBuilder​(ClassGen cg, ConstantPoolGen cp)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      InvokeInstruction createCallInit​(java.lang.String name, java.lang.String signature)
      Create invoke initializer instruction from signature.
      InvokeInstruction createCallInterface​(java.lang.String method, java.lang.String signature)
      Create invoke interface method instruction from signature.
      InvokeInstruction createCallInterface​(ClassItem item)
      Create invoke instruction for interface method.
      InvokeInstruction createCallStatic​(java.lang.String method, java.lang.String signature)
      Create invoke static method instruction from signature.
      InvokeInstruction createCallStatic​(ClassItem item)
      Create invoke instruction for static method.
      InvokeInstruction createCallVirtual​(java.lang.String method, java.lang.String signature)
      Create invoke virtual method instruction from signature.
      InvokeInstruction createCallVirtual​(ClassItem item)
      Create invoke instruction for virtual method.
      FieldInstruction createGetField​(ClassItem item)
      Create getfield instruction.
      FieldInstruction createGetStatic​(ClassItem item)
      Create getstatic instruction.
      CompoundInstruction createLoadConstant​(int value)
      Create load constant instruction.
      CompoundInstruction createLoadConstant​(java.lang.Object value)
      Create load constant instruction.
      CompoundInstruction createLoadConstant​(java.lang.String value)
      Create load constant instruction.
      FieldInstruction createPutField​(ClassItem item)
      Create putfield instruction.
      FieldInstruction createPutStatic​(ClassItem item)
      Create putstatic instruction.
      ConstantPoolGen getConstantPoolGen()
      Get constant pool generator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InstructionBuilder

        public InstructionBuilder​(ClassGen cg,
                                  ConstantPoolGen cp)
        Constructor.
        Parameters:
        cg - class generation information
        cp - constant pool generator
    • Method Detail

      • getConstantPoolGen

        public ConstantPoolGen getConstantPoolGen()
        Get constant pool generator.
        Returns:
        constant pool generator for class
      • createLoadConstant

        public CompoundInstruction createLoadConstant​(int value)
        Create load constant instruction. Builds the most appropriate type of instruction for the value.
        Parameters:
        value - constant value to be loaded
        Returns:
        generated instruction information
      • createLoadConstant

        public CompoundInstruction createLoadConstant​(java.lang.String value)
        Create load constant instruction. Loads a String reference from the constant pool.
        Parameters:
        value - constant value to be loaded
        Returns:
        generated instruction information
      • createLoadConstant

        public CompoundInstruction createLoadConstant​(java.lang.Object value)
        Create load constant instruction. Loads an unwrapped primitive value or String from the constant pool.
        Parameters:
        value - constant value to be loaded
        Returns:
        generated instruction information
      • createGetField

        public FieldInstruction createGetField​(ClassItem item)
        Create getfield instruction. Uses the field information to generate the instruction.
        Parameters:
        item - information for field to be set
        Returns:
        generated instruction information
      • createPutField

        public FieldInstruction createPutField​(ClassItem item)
        Create putfield instruction. Uses the field information to generate the instruction.
        Parameters:
        item - information for field to be set
        Returns:
        generated instruction information
      • createGetStatic

        public FieldInstruction createGetStatic​(ClassItem item)
        Create getstatic instruction. Uses the field information to generate the instruction.
        Parameters:
        item - information for field to be set
        Returns:
        generated instruction information
      • createPutStatic

        public FieldInstruction createPutStatic​(ClassItem item)
        Create putstatic instruction. Uses the field information to generate the instruction.
        Parameters:
        item - information for field to be set
        Returns:
        generated instruction information
      • createCallStatic

        public InvokeInstruction createCallStatic​(ClassItem item)
        Create invoke instruction for static method. Uses the method information to generate the instruction.
        Parameters:
        item - information for method to be called
        Returns:
        generated instruction information
      • createCallVirtual

        public InvokeInstruction createCallVirtual​(ClassItem item)
        Create invoke instruction for virtual method. Uses the method information to generate the instruction.
        Parameters:
        item - information for method to be called
        Returns:
        generated instruction information
      • createCallInterface

        public InvokeInstruction createCallInterface​(ClassItem item)
        Create invoke instruction for interface method. Uses the method information to generate the instruction.
        Parameters:
        item - information for method to be called
        Returns:
        generated instruction information
      • createCallStatic

        public InvokeInstruction createCallStatic​(java.lang.String method,
                                                  java.lang.String signature)
        Create invoke static method instruction from signature.
        Parameters:
        method - fully qualified class and method name
        signature - method signature in standard form
        Returns:
        generated instruction information
      • createCallVirtual

        public InvokeInstruction createCallVirtual​(java.lang.String method,
                                                   java.lang.String signature)
        Create invoke virtual method instruction from signature.
        Parameters:
        method - fully qualified class and method name
        signature - method signature in standard form
        Returns:
        generated instruction information
      • createCallInterface

        public InvokeInstruction createCallInterface​(java.lang.String method,
                                                     java.lang.String signature)
        Create invoke interface method instruction from signature.
        Parameters:
        method - fully qualified interface and method name
        signature - method signature in standard form
        Returns:
        generated instruction information
      • createCallInit

        public InvokeInstruction createCallInit​(java.lang.String name,
                                                java.lang.String signature)
        Create invoke initializer instruction from signature.
        Parameters:
        name - fully qualified class name
        signature - method signature in standard form
        Returns:
        generated instruction information