Class BetterCFGBuilder2.Subroutine

java.lang.Object
edu.umd.cs.findbugs.ba.BetterCFGBuilder2.Subroutine
Enclosing class:
BetterCFGBuilder2

private class BetterCFGBuilder2.Subroutine extends Object
JSR subroutine. The top level subroutine is where execution starts. Each subroutine has its own CFG. Eventually, all JSR subroutines will be inlined into the top level subroutine, resulting in an accurate CFG for the overall method.
  • Field Details

  • Constructor Details

    • Subroutine

      public Subroutine(org.apache.bcel.generic.InstructionHandle start)
      Constructor.
      Parameters:
      start - the start instruction for the subroutine
  • Method Details

    • getStartInstruction

      public org.apache.bcel.generic.InstructionHandle getStartInstruction()
      Get the start instruction.
    • allocateBasicBlock

      public BasicBlock allocateBasicBlock()
      Allocate a new basic block in the subroutine.
    • addItem

      public void addItem(BetterCFGBuilder2.WorkListItem item)
      Add a work list item for a basic block to be constructed.
    • hasMoreWork

      public boolean hasMoreWork()
      Are there more work list items?
    • nextItem

      public BetterCFGBuilder2.WorkListItem nextItem()
      Get the next work list item.
    • getEntry

      public BasicBlock getEntry()
      Get the entry block for the subroutine's CFG.
    • getExit

      public BasicBlock getExit()
      Get the exit block for the subroutine's CFG.
    • getStartBlock

      public BasicBlock getStartBlock()
      Get the start block for the subroutine's CFG. (I.e., the block containing the start instruction.)
    • getCFG

      public CFG getCFG()
      Get the subroutine's CFG.
    • addInstruction

      public void addInstruction(org.apache.bcel.generic.InstructionHandle handle) throws CFGBuilderException
      Add an instruction to the subroutine. We keep track of which instructions are part of which subroutines. No instruction may be part of more than one subroutine.
      Parameters:
      handle - the instruction to be added to the subroutine
      Throws:
      CFGBuilderException
    • containsInstruction

      public boolean containsInstruction(org.apache.bcel.generic.InstructionHandle handle)
      Is the given instruction part of this subroutine?
    • getBlock

      public BasicBlock getBlock(org.apache.bcel.generic.InstructionHandle start)
      Get the basic block in the subroutine for the given instruction. If the block doesn't exist yet, it is created, and a work list item is added which will populate it. Note that if start is an exception thrower, the block returned will be its ETB.
      Parameters:
      start - the start instruction for the block
      Returns:
      the basic block for the instruction
    • setReturnBlock

      public void setReturnBlock(BasicBlock block)
      Indicate that the method returns at the end of the given block.
      Parameters:
      block - the returning block
    • isReturnBlock

      public boolean isReturnBlock(BasicBlock block)
      Does the method return at the end of this block?
    • setExitBlock

      public void setExitBlock(BasicBlock block)
      Indicate that System.exit() is called at the end of the given block.
      Parameters:
      block - the exiting block
    • isExitBlock

      public boolean isExitBlock(BasicBlock block)
      Is System.exit() called at the end of this block?
    • setUnhandledExceptionBlock

      public void setUnhandledExceptionBlock(BasicBlock block)
      Indicate that an unhandled exception may be thrown by the given block.
      Parameters:
      block - the block throwing an unhandled exception
    • isUnhandledExceptionBlock

      public boolean isUnhandledExceptionBlock(BasicBlock block)
      Does this block throw an unhandled exception?
    • addEdgeAndExplore

      public void addEdgeAndExplore(BasicBlock sourceBlock, org.apache.bcel.generic.InstructionHandle target, @Type int edgeType)
      Add a control flow edge to the subroutine. If the control target has not yet been added to the subroutine, a new work list item is added. If the control target is in another subroutine, an EscapeTarget is added.
      Parameters:
      sourceBlock - the source basic block
      target - the control target
      edgeType - the type of control edge
    • addEdge

      public void addEdge(BasicBlock sourceBlock, BasicBlock destBlock, @Type int edgeType)
      Add an edge to the subroutine's CFG.
      Parameters:
      sourceBlock - the source basic block
      destBlock - the destination basic block
      edgeType - the type of edge
    • escapeTargetIterator

      public Iterator<BetterCFGBuilder2.EscapeTarget> escapeTargetIterator(BasicBlock sourceBlock)
      Get an Iterator over the EscapeTargets of given basic block.
      Parameters:
      sourceBlock - the basic block
      Returns:
      an Iterator over the EscapeTargets