Class BranchTargetFinder

java.lang.Object
proguard.classfile.util.BranchTargetFinder
All Implemented Interfaces:
AttributeVisitor, ExceptionInfoVisitor, ConstantVisitor, InstructionVisitor

public class BranchTargetFinder extends Object implements AttributeVisitor, InstructionVisitor, ExceptionInfoVisitor, ConstantVisitor
This AttributeVisitor finds all instruction offsets, branch targets, and exception targets in the CodeAttribute instances that it visits.
  • Field Details

  • Constructor Details

    • BranchTargetFinder

      public BranchTargetFinder()
  • Method Details

    • isInstruction

      public boolean isInstruction(int offset)
      Returns whether there is an instruction at the given offset in the CodeAttribute that was visited most recently.
    • isCreation

      public boolean isCreation(int offset)
      Returns whether the instruction at the given offset creates a new, uninitialized object instance, in the CodeAttribute that was visited most recently.
    • isInitializer

      public boolean isInitializer(int offset)
      Returns whether the instruction at the given offset is the special invocation of an instance initializer, in the CodeAttribute that was visited most recently.
    • isTarget

      public boolean isTarget(int offset)
      Returns whether the instruction at the given offset is the target of any kind in the CodeAttribute that was visited most recently.
    • isBranchOrigin

      public boolean isBranchOrigin(int offset)
      Returns whether the instruction at the given offset is the origin of a branch instruction in the CodeAttribute that was visited most recently.
    • isBranchTarget

      public boolean isBranchTarget(int offset)
      Returns whether the instruction at the given offset is the target of a branch instruction in the CodeAttribute that was visited most recently.
    • isAfterBranch

      public boolean isAfterBranch(int offset)
      Returns whether the instruction at the given offset comes right after a definite branch instruction in the CodeAttribute that was visited most recently.
    • isExceptionStart

      public boolean isExceptionStart(int offset)
      Returns whether the instruction at the given offset is the start of an exception try block in the CodeAttribute that was visited most recently.
    • isExceptionEnd

      public boolean isExceptionEnd(int offset)
      Returns whether the instruction at the given offset is the end of an exception try block in the CodeAttribute that was visited most recently.
    • isExceptionHandler

      public boolean isExceptionHandler(int offset)
      Returns whether the instruction at the given offset is the start of an exception handler in the CodeAttribute that was visited most recently.
    • isSubroutineInvocation

      public boolean isSubroutineInvocation(int offset)
      Returns whether the instruction at the given offset is a subroutine invocation in the CodeAttribute that was visited most recently.
    • isSubroutineStart

      public boolean isSubroutineStart(int offset)
      Returns whether the instruction at the given offset is the start of a subroutine in the CodeAttribute that was visited most recently.
    • isSubroutine

      public boolean isSubroutine(int offset)
      Returns whether the instruction at the given offset is part of a subroutine in the CodeAttribute that was visited most recently.
    • isSubroutineReturning

      public boolean isSubroutineReturning(int offset)
      Returns whether the subroutine at the given offset is ever returning by means of a regular 'ret' instruction.
    • subroutineStart

      public int subroutineStart(int offset)
      Returns the start offset of the subroutine at the given offset, in the CodeAttribute that was visited most recently.
    • subroutineEnd

      public int subroutineEnd(int offset)
      Returns the offset after the subroutine at the given offset, in the CodeAttribute that was visited most recently.
    • containsSubroutines

      public boolean containsSubroutines()
      Returns whether the method contains subroutines, in the CodeAttribute that was visited most recently.
    • isBranchFallThrough

      public boolean isBranchFallThrough(int offset)
      Return whether the instruction at the given offset is a conditional branch fall-through.
    • isLeader

      public boolean isLeader(int offset)
      Return whether the instruction at the given offset is a leader.
    • visitAnyAttribute

      public void visitAnyAttribute(Clazz clazz, Attribute attribute)
      Description copied from interface: AttributeVisitor
      Visits any Attribute instance. The more specific default implementations of this interface delegate to this method.
      Specified by:
      visitAnyAttribute in interface AttributeVisitor
    • visitCodeAttribute

      public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
      Specified by:
      visitCodeAttribute in interface AttributeVisitor
    • visitSimpleInstruction

      public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
      Specified by:
      visitSimpleInstruction in interface InstructionVisitor
    • visitConstantInstruction

      public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
      Specified by:
      visitConstantInstruction in interface InstructionVisitor
    • visitVariableInstruction

      public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
      Specified by:
      visitVariableInstruction in interface InstructionVisitor
    • visitBranchInstruction

      public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
      Specified by:
      visitBranchInstruction in interface InstructionVisitor
    • visitAnySwitchInstruction

      public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction)
      Description copied from interface: InstructionVisitor
      Visits any SwitchInstruction instance. The more specific default implementations of this interface delegate to this method.
      Specified by:
      visitAnySwitchInstruction in interface InstructionVisitor
    • visitAnyConstant

      public void visitAnyConstant(Clazz clazz, Constant constant)
      Description copied from interface: ConstantVisitor
      Visits any Constant instance. The more specific default implementations of this interface delegate to this method.
      Specified by:
      visitAnyConstant in interface ConstantVisitor
    • visitMethodrefConstant

      public void visitMethodrefConstant(Clazz clazz, MethodrefConstant methodrefConstant)
      Specified by:
      visitMethodrefConstant in interface ConstantVisitor
    • visitExceptionInfo

      public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
      Specified by:
      visitExceptionInfo in interface ExceptionInfoVisitor