Class SwitchDescriptor
- java.lang.Object
-
- com.tonic.analysis.source.recovery.rcs.SwitchDescriptor
-
public final class SwitchDescriptor extends Object
A decoded, structuring-ready view of a native int/enumswitch.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSwitchDescriptor.CaseSpecOne case of a decoded switch.
-
Constructor Summary
Constructors Constructor Description SwitchDescriptor(IRBlock header, Expression selector, IRBlock merge, List<SwitchDescriptor.CaseSpec> cases, Set<IRBlock> caseHeaders)Creates a descriptor whose header successors are the case bodies.SwitchDescriptor(IRBlock header, Expression selector, IRBlock merge, List<SwitchDescriptor.CaseSpec> cases, Set<IRBlock> caseHeaders, boolean desugaredSelector)Creates a descriptor, stating whether the header's successors are dispatch scaffolding rather than case bodies.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<IRBlock>caseHeaders()List<SwitchDescriptor.CaseSpec>cases()booleandesugaredSelector()IRBlockheader()IRBlockmerge()Expressionselector()
-
-
-
Constructor Detail
-
SwitchDescriptor
public SwitchDescriptor(IRBlock header, Expression selector, IRBlock merge, List<SwitchDescriptor.CaseSpec> cases, Set<IRBlock> caseHeaders)
Creates a descriptor whose header successors are the case bodies.- Parameters:
header- the switch blockselector- the recovered selector expressionmerge- where control resumes after the switch, or null if every case exitscases- the cases in source order, default lastcaseHeaders- every distinct case-body entry block
-
SwitchDescriptor
public SwitchDescriptor(IRBlock header, Expression selector, IRBlock merge, List<SwitchDescriptor.CaseSpec> cases, Set<IRBlock> caseHeaders, boolean desugaredSelector)
Creates a descriptor, stating whether the header's successors are dispatch scaffolding rather than case bodies.- Parameters:
header- the switch blockselector- the recovered selector expressionmerge- where control resumes after the switch, or null if every case exitscases- the cases in source order, default lastcaseHeaders- every distinct case-body entry blockdesugaredSelector- true when the raw successors are a desugared dispatch chain
-
-
Method Detail
-
desugaredSelector
public boolean desugaredSelector()
- Returns:
- true when the raw CFG edges out of the header are a desugared dispatch scaffold - a string switch's hashCode/equals chains - rather than the case bodies, so the model must follow this descriptor's case headers and merge instead of the raw successors
-
header
public IRBlock header()
- Returns:
- the switch block itself
-
selector
public Expression selector()
- Returns:
- the recovered selector expression - an enum variable,
e.ordinal(), or the raw key
-
merge
public IRBlock merge()
- Returns:
- the block where control resumes after the switch, or null when every case exits
-
cases
public List<SwitchDescriptor.CaseSpec> cases()
- Returns:
- the cases in source order, with the default, if any, last
-
-