Class StructuralAnalyzer
- java.lang.Object
-
- com.tonic.analysis.source.recovery.StructuralAnalyzer
-
public class StructuralAnalyzer extends Object
CFG structural analysis identifying if-then-else, while, do-while, for and switch regions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStructuralAnalyzer.RegionInfoInformation about a structured region.
-
Constructor Summary
Constructors Constructor Description StructuralAnalyzer(IRMethod method, DominatorTree dominatorTree, LoopAnalysis loopAnalysis)Creates an analyzer; the post-dominator tree is built by analyze().
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalyze()Analyzes the method and identifies structured regions.DominatorTreegetDominatorTree()List<StructuralAnalyzer.RegionInfo>getForLoopRegions()LoopAnalysisgetLoopAnalysis()IRMethodgetMethod()PostDominatorTreegetPostDominatorTree()Map<IRBlock,Set<IRBlock>>getReachabilityCache()StructuralAnalyzer.RegionInfogetRegionInfo(IRBlock block)Map<IRBlock,StructuralAnalyzer.RegionInfo>getRegionInfos()booleanisPureExitBlock(IRBlock block)Checks if a block is a PURE exit: a throw, a void return, or a trivial goto to such a block.
-
-
-
Constructor Detail
-
StructuralAnalyzer
public StructuralAnalyzer(IRMethod method, DominatorTree dominatorTree, LoopAnalysis loopAnalysis)
Creates an analyzer; the post-dominator tree is built by analyze().- Parameters:
method- SSA method to analyzedominatorTree- dominator tree over the same methodloopAnalysis- natural loops of the same method
-
-
Method Detail
-
getMethod
public IRMethod getMethod()
- Returns:
- the method
-
getDominatorTree
public DominatorTree getDominatorTree()
- Returns:
- the dominator tree
-
getLoopAnalysis
public LoopAnalysis getLoopAnalysis()
- Returns:
- the loop analysis
-
getPostDominatorTree
public PostDominatorTree getPostDominatorTree()
- Returns:
- the post dominator tree
-
getReachabilityCache
public Map<IRBlock,Set<IRBlock>> getReachabilityCache()
- Returns:
- the reachability cache
-
getRegionInfos
public Map<IRBlock,StructuralAnalyzer.RegionInfo> getRegionInfos()
- Returns:
- the structured region identified for each block
-
analyze
public void analyze()
Analyzes the method and identifies structured regions.
-
isPureExitBlock
public boolean isPureExitBlock(IRBlock block)
Checks if a block is a PURE exit: a throw, a void return, or a trivial goto to such a block.- Parameters:
block- block to test- Returns:
- true if the block is a pure exit
-
getRegionInfo
public StructuralAnalyzer.RegionInfo getRegionInfo(IRBlock block)
- Parameters:
block- block to look up- Returns:
- the region recorded for the block, or null when analysis identified none
-
getForLoopRegions
public List<StructuralAnalyzer.RegionInfo> getForLoopRegions()
- Returns:
- every FOR_LOOP region identified in the method
-
-