Class BranchLeaveMatching

java.lang.Object
net.covers1624.coffeegrinder.bytecode.matching.BranchLeaveMatching

public class BranchLeaveMatching extends Object
Created by covers1624 on 19/4/21.
  • Constructor Details

    • BranchLeaveMatching

      public BranchLeaveMatching()
  • Method Details

    • matchReturn

      @Nullable public static @Nullable Return matchReturn(@Nullable @Nullable Instruction insn, MethodDecl method)
    • matchLeave

      @Nullable public static @Nullable Leave matchLeave(@Nullable @Nullable Instruction insn, BlockContainer container)
      Attempts to match a leave instruction which leaves the specified BlockContainer.
      Parameters:
      insn - The instruction.
      container - The BlockContainer.
      Returns:
      The Leave instruction, otherwise empty.
    • matchBranch

      @Nullable public static @Nullable Branch matchBranch(@Nullable @Nullable Instruction insn, Block targetBlock)
      Attempts to match a branch instruction to a given block.
      Parameters:
      insn - The instruction.
      targetBlock - The target block.
      Returns:
      The Branch instruction, otherwise empty.
    • compatibleExitInstruction

      public static boolean compatibleExitInstruction(@Nullable @Nullable Instruction exit1, @Nullable @Nullable Instruction exit2)
      Returns true if exit1 and exit2 are both exit instructions (branch or leave) and both represent the same exit.
      Parameters:
      exit1 - The first exit point.
      exit2 - The second exit point.
      Returns:
      If they represent the same exit.
    • matchThrow

      @Nullable public static @Nullable Throw matchThrow(@Nullable @Nullable Instruction insn, LocalVariable variable)
      Attempts to match a Throw instruction, which loads the specified variable.
      Parameters:
      insn - The Instruction.
      variable - The variable.
      Returns:
      The Throw or null.
    • tryGetExit

      @Nullable public static @Nullable Instruction tryGetExit(@Nullable @Nullable Instruction insn)
      Determine if the specified instruction necessarily exits (END_POINT_UNREACHABLE) and if so, return last (or single) exit instruction.
      Parameters:
      insn - The instruction to check.
      Returns:
      The exit instruction, or null.
    • getExit

      public static Instruction getExit(Instruction insn)
      Gets the final instruction from a block (or a single instruction) assuming that all blocks or instructions in this position have unreachable endpoints.
      Parameters:
      insn - The insn or block to check.
      Returns:
      The exit insn.