Package edu.umd.cs.findbugs.ba.bcp
Class PatternMatcher
java.lang.Object
edu.umd.cs.findbugs.ba.bcp.PatternMatcher
- All Implemented Interfaces:
DFSEdgeTypes
,DFSEdgeTypes
Match a ByteCodePattern against the code of a method, represented by a CFG. Produces some number of ByteCodePatternMatch objects, which indicate how the pattern matched the bytecode instructions in the method.
This code is a hack and should probably be rewritten.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
Object representing the current state of the matching algorithm. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CFG
private final org.apache.bcel.generic.ConstantPoolGen
(package private) int
Match a sequence of pattern elements, starting at the given one.private final DepthFirstSearch
private final DominatorsAnalysis
private static final org.slf4j.Logger
private int
private final ByteCodePattern
private final LinkedList
<ByteCodePatternMatch> private static final boolean
private final IdentityHashMap
<BasicBlock, BasicBlock> private final ValueNumberDataflow
private final LinkedList
<BasicBlock> Fields inherited from interface edu.umd.cs.findbugs.graph.DFSEdgeTypes
BACK_EDGE, CROSS_EDGE, FORWARD_EDGE, TREE_EDGE, UNKNOWN_EDGE
-
Constructor Summary
ConstructorsConstructorDescriptionPatternMatcher
(ByteCodePattern pattern, ClassContext classContext, org.apache.bcel.classfile.Method method) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
attemptMatch
(BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator) Attempt to begin a match.Return an Iterator over the ByteCodePatternMatch objects representing successful matches of the ByteCodePattern.private void
execute()
Search for examples of the ByteCodePattern.private void
work
(PatternMatcher.State state)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
SHOW_WILD
private static final boolean SHOW_WILD -
pattern
-
cfg
-
cpg
private final org.apache.bcel.generic.ConstantPoolGen cpg -
dfs
-
vnaDataflow
-
domAnalysis
-
workList
-
visitedBlockMap
-
resultList
-
nextPath
private int nextPath -
depth
int depthMatch a sequence of pattern elements, starting at the given one. The InstructionIterator should generally be positioned just before the next instruction to be matched. However, it may be positioned at the end of a basic block, in which case nothing will happen except that we will try to continue the match in the non-backedge successors of the basic block.
-
-
Constructor Details
-
PatternMatcher
public PatternMatcher(ByteCodePattern pattern, ClassContext classContext, org.apache.bcel.classfile.Method method) throws CFGBuilderException, DataflowAnalysisException Constructor.- Parameters:
pattern
- the ByteCodePattern to look for examples ofclassContext
- ClassContext for the class to analyzemethod
- the Method to analyze- Throws:
CFGBuilderException
DataflowAnalysisException
-
-
Method Details
-
execute
Search for examples of the ByteCodePattern.- Returns:
- this object
- Throws:
DataflowAnalysisException
- if the ValueNumberAnalysis did not produce useful values for the method
-
byteCodePatternMatchIterator
Return an Iterator over the ByteCodePatternMatch objects representing successful matches of the ByteCodePattern. -
attemptMatch
private void attemptMatch(BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator) throws DataflowAnalysisException Attempt to begin a match.- Parameters:
basicBlock
- the basic blockinstructionIterator
- the instruction iterator positioned just before the first instruction to be matched- Throws:
DataflowAnalysisException
-
debug
-
work
- Throws:
DataflowAnalysisException
-