Package edu.umd.cs.findbugs.ba.bcp
Class PatternMatcher.State
java.lang.Object
edu.umd.cs.findbugs.ba.bcp.PatternMatcher.State
- Enclosing class:
PatternMatcher
Object representing the current state of the matching algorithm. Provides
convenient methods to implement the various steps of the algorithm.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BasicBlock
private BindingSet
private boolean
private PatternElementMatch
private final BasicBlock.InstructionIterator
private int
private final int
private final int
private final PatternElement
-
Constructor Summary
ConstructorsConstructorDescriptionState
(BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator, PatternElement patternElement) Constructor.State
(PatternMatcher.State parent, BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator, PatternElement patternElement, int matchCount, PatternElementMatch currentMatch, BindingSet bindingSet, boolean canFork) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionTry to produce a new state that will finish matching the current element and start matching the next element.advanceToSuccessor
(Edge edge, MatchResult matchResult) Return a new State for continuing the overall pattern match in a successor basic block.boolean
Determine if it is possible to continue matching in a successor basic block.boolean
Determine if the current pattern element can continue to match instructions.Return Iterator over states representing dominated instructions that continue the match.Make an exact copy of this object.Get basic block.Get current pattern element match.org.apache.bcel.generic.InstructionHandle
Get most recently matched instruction.Get current pattern element.Get a ByteCodePatternMatch representing the complete match.boolean
Determine if the match is complete.boolean
Determine if we need to look for a dominated instruction at this point in the search.private MatchResult
matchLocation
(Location location) Match current pattern element with next instruction in basic block.boolean
Determine if there are more instructions in the same basic block.toString()
-
Field Details
-
basicBlock
-
instructionIterator
-
patternElement
-
matchCount
private int matchCount -
currentMatch
-
bindingSet
-
canFork
private boolean canFork -
parentPath
private final int parentPath -
path
private final int path
-
-
Constructor Details
-
State
public State(BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator, PatternElement patternElement) Constructor. Builds the start state.- Parameters:
basicBlock
- the initial basic blockinstructionIterator
- the instructionIterator indicating where to start matchingpatternElement
- the first PatternElement of the pattern
-
State
public State(@Nullable PatternMatcher.State parent, BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator, PatternElement patternElement, int matchCount, @Nullable PatternElementMatch currentMatch, @Nullable BindingSet bindingSet, boolean canFork) Constructor.
-
-
Method Details
-
toString
-
duplicate
Make an exact copy of this object. -
getBasicBlock
Get basic block. -
getPatternElement
Get current pattern element. -
getCurrentMatch
Get current pattern element match. -
isComplete
public boolean isComplete()Determine if the match is complete. -
getResult
Get a ByteCodePatternMatch representing the complete match. -
advanceToNextElement
Try to produce a new state that will finish matching the current element and start matching the next element. Returns null if the current element is not complete. -
currentElementCanContinue
public boolean currentElementCanContinue()Determine if the current pattern element can continue to match instructions. -
moreInstructionsInBasicBlock
public boolean moreInstructionsInBasicBlock()Determine if there are more instructions in the same basic block. -
matchNextInBasicBlock
Match current pattern element with next instruction in basic block. Returns MatchResult if match succeeds, null otherwise.- Throws:
DataflowAnalysisException
-
canAdvanceToNextBasicBlock
public boolean canAdvanceToNextBasicBlock()Determine if it is possible to continue matching in a successor basic block. -
getLastMatchedInstruction
public org.apache.bcel.generic.InstructionHandle getLastMatchedInstruction()Get most recently matched instruction. -
advanceToSuccessor
Return a new State for continuing the overall pattern match in a successor basic block.- Parameters:
edge
- the Edge leading to the successor basic blockmatchResult
- a MatchResult representing the match of the last instruction in the predecessor block; null if none
-
lookForDominatedInstruction
public boolean lookForDominatedInstruction()Determine if we need to look for a dominated instruction at this point in the search. -
dominatedInstructionStateIterable
public Iterable<PatternMatcher.State> dominatedInstructionStateIterable() throws DataflowAnalysisExceptionReturn Iterator over states representing dominated instructions that continue the match.- Throws:
DataflowAnalysisException
-
matchLocation
- Throws:
DataflowAnalysisException
-