Package serp.bytecode

Class StackInstruction

  • All Implemented Interfaces:
    BCEntity, VisitAcceptor

    public class StackInstruction
    extends TypedInstruction
    Represents an instruction that manipulates the stack of the current frame. Using the setType(java.lang.String) methods is a hint about the type being manipulated that might cause this instruction to use the wide version of the opcode it represents (if manipulating a long or double). This saves the developer from having to decide at compile time whether to use pop or pop2, etc.
    • Constructor Detail

      • StackInstruction

        StackInstruction​(Code owner,
                         int opcode)
    • Method Detail

      • getStackChange

        public int getStackChange()
        Description copied from class: Instruction
        Return the number of stack positions this instruction pushes or pops during its execution.
        Overrides:
        getStackChange in class Instruction
        Returns:
        0 if the stack is not affected by this instruction, a positive number if it pushes onto the stack, and a negative number if it pops from the stack
      • getTypeName

        public java.lang.String getTypeName()
        This method will always return null; use isWide() to determine if this is pop2, dup2, etc.
        Specified by:
        getTypeName in class TypedInstruction
      • setType

        public TypedInstruction setType​(java.lang.String type)
        Description copied from class: TypedInstruction
        Set the type of this instruction. Types that have no direct support will be converted accordingly.
        Specified by:
        setType in class TypedInstruction
        Returns:
        this instruction, for method chaining
      • isWide

        public boolean isWide()
        Return whether to use the wide form of the current opcode for operations on longs or doubles.
      • setWide

        public StackInstruction setWide​(boolean wide)
        Set whether to use the wide form of the current opcode for operations on longs or doubles.
        Returns:
        this instruction, for method chaining
      • acceptVisit

        public void acceptVisit​(BCVisitor visit)
        Description copied from interface: VisitAcceptor
        Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.
        Specified by:
        acceptVisit in interface VisitAcceptor
        Overrides:
        acceptVisit in class Instruction