Class TypeRecoverer
- java.lang.Object
-
- com.tonic.analysis.source.recovery.TypeRecoverer
-
public class TypeRecoverer extends Object
Recovers source types from IR types.
-
-
Constructor Summary
Constructors Constructor Description TypeRecoverer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SourceTypecomputeCommonType(Collection<SourceType> types)Computes a common supertype for a collection of types.StringrecoverFormalTypeParameters(String signature)Renders a class/method signature's formal type parameters, e.g.SourceTyperecoverGenericType(String signature)Recovers a source type from a JVM generic signature.SourceTyperecoverType(IRType irType)Recovers a source type from an IR type.SourceTyperecoverType(SSAValue value)Recovers a source type from an SSA value.SourceTyperecoverType(Value value)Recovers a source type from any Value (SSAValue or Constant).SourceTyperecoverType(String descriptor)Recovers a source type from a JVM type descriptor.SourceTyperecoverTypeWithInstructionContext(SSAValue ssa)Recovers a source type from an SSAValue, considering its defining instruction.
-
-
-
Method Detail
-
recoverType
public SourceType recoverType(SSAValue value)
Recovers a source type from an SSA value.- Parameters:
value- the SSA value, may be null or untyped- Returns:
- the recovered type, void when there is nothing to recover from
-
recoverType
public SourceType recoverType(Value value)
Recovers a source type from any Value (SSAValue or Constant).- Parameters:
value- the value, may be null- Returns:
- the recovered type, void for null values and unrecognized value kinds
-
recoverTypeWithInstructionContext
public SourceType recoverTypeWithInstructionContext(SSAValue ssa)
Recovers a source type from an SSAValue, considering its defining instruction.- Parameters:
ssa- the SSA value, may be null or untyped- Returns:
- the recovered type, void when there is nothing to recover from
-
computeCommonType
public SourceType computeCommonType(Collection<SourceType> types)
Computes a common supertype for a collection of types.- Parameters:
types- the collection of types to unify- Returns:
- the common supertype
-
recoverType
public SourceType recoverType(IRType irType)
Recovers a source type from an IR type.- Parameters:
irType- the IR type to convert- Returns:
- the equivalent source type
-
recoverType
public SourceType recoverType(String descriptor)
Recovers a source type from a JVM type descriptor.- Parameters:
descriptor- a field descriptor, may be null or empty- Returns:
- the parsed type, void for an empty or unrecognized descriptor
-
recoverGenericType
public SourceType recoverGenericType(String signature)
Recovers a source type from a JVM generic signature.- Parameters:
signature- the signature to parse, may be null or empty- Returns:
- the parsed type, void when the signature is empty
-
recoverFormalTypeParameters
public String recoverFormalTypeParameters(String signature)
Renders a class/method signature's formal type parameters, e.g."<T extends Comparable<T>>", else "".- Parameters:
signature- the class or method signature, may be null- Returns:
- the rendered parameter list, or "" when the signature declares none
-
-