Class MethodRecoverer
- java.lang.Object
-
- com.tonic.analysis.source.recovery.MethodRecoverer
-
public class MethodRecoverer extends Object
Facade that recovers a source-level method body from an IR method, wiring together name, expression, structural, and statement recovery.
-
-
Constructor Summary
Constructors Constructor Description MethodRecoverer(IRMethod irMethod, MethodEntry sourceMethod)Creates a recoverer that prefers names from debug info.MethodRecoverer(IRMethod irMethod, MethodEntry sourceMethod, NameRecoveryStrategy nameStrategy)Creates a recoverer with an explicit naming strategy.
-
Method Summary
-
-
-
Constructor Detail
-
MethodRecoverer
public MethodRecoverer(IRMethod irMethod, MethodEntry sourceMethod)
Creates a recoverer that prefers names from debug info.- Parameters:
irMethod- the lifted methodsourceMethod- the method the IR came from
-
MethodRecoverer
public MethodRecoverer(IRMethod irMethod, MethodEntry sourceMethod, NameRecoveryStrategy nameStrategy)
Creates a recoverer with an explicit naming strategy.- Parameters:
irMethod- the lifted methodsourceMethod- the method the IR came fromnameStrategy- how local names are chosen
-
-
Method Detail
-
getIrMethod
public IRMethod getIrMethod()
- Returns:
- the ir method
-
getSourceMethod
public MethodEntry getSourceMethod()
- Returns:
- the source method
-
getNameStrategy
public NameRecoveryStrategy getNameStrategy()
- Returns:
- the name strategy
-
getReservedNames
public Set<String> getReservedNames()
- Returns:
- the names reserved by the caller (e.g. captured outer variables), which
baseNameForSlotskips
-
getRecordDeconstructionTemps
public Set<SSAValue> getRecordDeconstructionTemps()
- Returns:
- the cast results that are a record deconstruction's synthetic temp (the
(T) selector)
-
getDominatorTree
public DominatorTree getDominatorTree()
- Returns:
- the dominator tree
-
getLoopAnalysis
public LoopAnalysis getLoopAnalysis()
- Returns:
- the loop analysis
-
getDefUseChains
public DefUseChains getDefUseChains()
- Returns:
- the def use chains
-
getRecoveryContext
public RecoveryContext getRecoveryContext()
- Returns:
- the recovery context
-
getControlFlowContext
public ControlFlowContext getControlFlowContext()
- Returns:
- the control flow context
-
getNameRecoverer
public NameRecoverer getNameRecoverer()
- Returns:
- the name recoverer
-
getExpressionRecoverer
public ExpressionRecoverer getExpressionRecoverer()
- Returns:
- the expression recoverer
-
getStructuralAnalyzer
public StructuralAnalyzer getStructuralAnalyzer()
- Returns:
- the structural analyzer
-
getStatementRecoverer
public StatementRecoverer getStatementRecoverer()
- Returns:
- the statement recoverer
-
reserveNames
public void reserveNames(Set<String> names)
Reservesnamesso thatbaseNameForSlot(int)never returns them.- Parameters:
names- the names to reserve
-
analyze
public void analyze()
Performs all analysis passes needed for recovery.
-
initializeRecovery
public void initializeRecovery()
Initializes all recovery components.
-
recover
public BlockStmt recover()
Recovers the method body as a block statement, running the analysis and initialization passes first if they have not run yet.- Returns:
- the recovered body, re-recovered as a dispatch loop if the structured pass dropped operations
- Throws:
StatementRecoverer.RetiredSchemaRecoveryException- if no route owned a region and the dispatch fallback is unavailable (the method has exception handlers, or dispatch is disabled)
-
recoverMethod
public static BlockStmt recoverMethod(IRMethod irMethod, MethodEntry sourceMethod)
Full recovery pipeline: analyze, initialize, and recover.- Parameters:
irMethod- the method to recoversourceMethod- the method entry the IR was lifted from- Returns:
- the recovered body
-
recoverMethod
public static BlockStmt recoverMethod(IRMethod irMethod, MethodEntry sourceMethod, NameRecoveryStrategy nameStrategy)
Full recovery pipeline with custom name strategy.- Parameters:
irMethod- the method to recoversourceMethod- the method entry the IR was lifted fromnameStrategy- the strategy that names recovered locals- Returns:
- the recovered body
-
-