Class SimpleInstruction


  • public class SimpleInstruction
    extends Instruction
    This Instruction represents a simple instruction without variable arguments or constant pool references.
    • Field Detail

      • constant

        public int constant
    • Constructor Detail

      • SimpleInstruction

        public SimpleInstruction()
        Creates an uninitialized SimpleInstruction.
      • SimpleInstruction

        public SimpleInstruction​(byte opcode)
        Creates a new SimpleInstruction with the given opcode. Automatically extracts any embedded constant.
      • SimpleInstruction

        public SimpleInstruction​(byte opcode,
                                 int constant)
        Creates a new SimpleInstruction with the given opcode and constant. Automatically adapts the opcode if it has an embedded constant and the constant lies within the supported range. If the constant doesn't lie within the supported range, it must be adapted before the instruction can be written out.
    • Method Detail

      • copy

        public SimpleInstruction copy​(SimpleInstruction simpleInstruction)
        Copies the given instruction into this instruction.
        Parameters:
        simpleInstruction - the instruction to be copied.
        Returns:
        this instruction.
      • canonicalOpcode

        public byte canonicalOpcode()
        Description copied from class: Instruction
        Returns the canonical opcode of this instruction, i.e. typically the opcode whose extension has been removed.
        Overrides:
        canonicalOpcode in class Instruction
      • shrink

        public Instruction shrink()
        Description copied from class: Instruction
        Shrinks this instruction to its shortest possible form.
        Specified by:
        shrink in class Instruction
        Returns:
        this instruction.
      • readInfo

        protected void readInfo​(byte[] code,
                                int offset)
        Description copied from class: Instruction
        Reads the data following the instruction opcode.
        Specified by:
        readInfo in class Instruction
      • writeInfo

        protected void writeInfo​(byte[] code,
                                 int offset)
        Description copied from class: Instruction
        Writes data following the instruction opcode.
        Specified by:
        writeInfo in class Instruction
      • length

        public int length​(int offset)
        Description copied from class: Instruction
        Returns the length in bytes of the instruction.
        Specified by:
        length in class Instruction
      • stackEntryIndexBefore

        public int stackEntryIndexBefore​(Clazz clazz,
                                         int stackEntryIndexAfter)
        Description copied from class: Instruction
        Returns the stack entry index from which the specified stack entry is copied by a dup/swap/checkcast instruction, or -1 otherwise. Stack entry indices are counted from the top of the stack.
        • checkcast: after: 0 (before: 0 ) -- not anymore
        • dup: after: 0 0 (before: 0 )
        • dup_x1: after: 0 1 0 (before: 1 0 )
        • dup_x2: after: 0 2 1 0 (before: 2 1 0 )
        • dup2: after: 1 0 1 0 (before: 1 0 )
        • dup2_x1: after: 1 0 2 1 0 (before: 2 1 0 )
        • dup2_x2: after: 1 0 3 2 1 0 (before: 3 2 1 0)
        Overrides:
        stackEntryIndexBefore in class Instruction
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in class Instruction