Class ReachingConditionStructurer
- java.lang.Object
-
- com.tonic.analysis.source.recovery.rcs.ReachingConditionStructurer
-
public final class ReachingConditionStructurer extends Object
Reaching-condition control-flow structurer: the DREAM-style ("No More Gotos") replacement for schema-based structural analysis.
-
-
Constructor Summary
Constructors Constructor Description ReachingConditionStructurer(RegionRecoveryBridge bridge, ControlFlowContext context)Creates a structurer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanlastRegionContinuesInto(IRBlock bound)Whether the most recently probed region flows intoboundthrough a back edge - the region is an enclosing loop's body tail whose continuation is the loop header itself.Set<IRBlock>probeRegionExits(IRBlock entry, Set<IRBlock> stopBlocks)Side-effect-free preflight.Set<IRBlock>probeRegionExits(IRBlock entry, Set<IRBlock> stopBlocks, boolean allowTryNodes)As above; withallowTryNodesthe probe models each try in the region as an opaque node.voidsetBoundaryDuplicableTails(Set<IRBlock> tails)Names the stop blocks this offer may inline once at the region's convergence onto them.voidsetSuppressBoundaryTerminalAbsorption(boolean suppress)Tells the structurer to leave a boundary terminal past the stops to the host's continuation recovery instead of pulling it into the region.List<Statement>tryStructureRegion(IRBlock entry, Set<IRBlock> stopBlocks)Structures the single-entry region rooted atentryand bounded bystopBlocks, or returnsnullwhen the region is outside this stage's scope so the caller falls back to legacy recovery.List<Statement>tryStructureRegion(IRBlock entry, Set<IRBlock> stopBlocks, boolean allowTryNodes)AstryStructureRegion(IRBlock, Set); withallowTryNodeseach try in the region becomes an opaque composite node.
-
-
-
Constructor Detail
-
ReachingConditionStructurer
public ReachingConditionStructurer(RegionRecoveryBridge bridge, ControlFlowContext context)
Creates a structurer.- Parameters:
bridge- the host recovery this stage calls back into for block contentscontext- the enclosing loop and switch context breaks and continues resolve against
-
-
Method Detail
-
setSuppressBoundaryTerminalAbsorption
public void setSuppressBoundaryTerminalAbsorption(boolean suppress)
Tells the structurer to leave a boundary terminal past the stops to the host's continuation recovery instead of pulling it into the region.- Parameters:
suppress- true to decline the absorption
-
setBoundaryDuplicableTails
public void setBoundaryDuplicableTails(Set<IRBlock> tails)
Names the stop blocks this offer may inline once at the region's convergence onto them.- Parameters:
tails- the admitted tails, or null for none
-
tryStructureRegion
public List<Statement> tryStructureRegion(IRBlock entry, Set<IRBlock> stopBlocks)
Structures the single-entry region rooted atentryand bounded bystopBlocks, or returnsnullwhen the region is outside this stage's scope so the caller falls back to legacy recovery.- Parameters:
entry- the region's single entry blockstopBlocks- blocks that bound the region; flow into one of them ends it- Returns:
- the structured statements, or null when the region is declined
-
probeRegionExits
public Set<IRBlock> probeRegionExits(IRBlock entry, Set<IRBlock> stopBlocks)
Side-effect-free preflight.- Parameters:
entry- the region's single entry blockstopBlocks- blocks that bound the region- Returns:
- the stops the region's flow exits into, or null when the region is declined
-
probeRegionExits
public Set<IRBlock> probeRegionExits(IRBlock entry, Set<IRBlock> stopBlocks, boolean allowTryNodes)
As above; withallowTryNodesthe probe models each try in the region as an opaque node.- Parameters:
entry- the region's single entry blockstopBlocks- blocks that bound the regionallowTryNodes- model each try as one opaque node instead of declining the region- Returns:
- the stops the region's flow exits into, or null when the region is declined
-
lastRegionContinuesInto
public boolean lastRegionContinuesInto(IRBlock bound)
Whether the most recently probed region flows intoboundthrough a back edge - the region is an enclosing loop's body tail whose continuation is the loop header itself.- Parameters:
bound- the candidate continuation block- Returns:
- true when some region block reaches it over a back edge
-
tryStructureRegion
public List<Statement> tryStructureRegion(IRBlock entry, Set<IRBlock> stopBlocks, boolean allowTryNodes)
AstryStructureRegion(IRBlock, Set); withallowTryNodeseach try in the region becomes an opaque composite node.- Parameters:
entry- the region's single entry blockstopBlocks- blocks that bound the regionallowTryNodes- structure each try as one opaque node instead of declining the region- Returns:
- the structured statements, or null when the region is declined
-
-