C# Class ICSharpCode.Decompiler.ILAst.TypeAnalysis

Assigns C# types to IL expressions.
Types are inferred in a bidirectional manner: The expected type flows from the outside to the inside, the actual inferred type flows from the inside to the outside.
ファイルを表示 Open project: sq/ILSpy-JSIL Class Usage Examples

Public Methods

Method Description
GetEnumUnderlyingType ( TypeReference enumType ) : TypeReference

Gets the underlying type, if the specified type is an enum. Otherwise, returns null.

GetFieldType ( FieldReference fieldReference ) : TypeReference
GetInformationAmount ( TypeReference type ) : int
GetTypeCode ( TypeReference type ) : TypeCode
IsBoolean ( TypeReference type ) : bool
IsEnum ( TypeReference type ) : bool
IsIntegerOrEnum ( TypeReference type ) : bool
IsSameType ( TypeReference type1, TypeReference type2 ) : bool
Reset ( ILBlock method ) : void

Clears the type inference data on the method.

Run ( DecompilerContext context, ILBlock method ) : void
SubstituteTypeArgs ( TypeReference type, MemberReference member ) : TypeReference

Private Methods

Method Description
CreateDependencyGraph ( ILNode node ) : void

Creates the "ExpressionToInfer" instances (=nodes in dependency graph)

We are using a dependency graph to ensure that expressions are analyzed in the correct order.

CreateNullableType ( TypeReference type ) : GenericInstanceType
DoInferTypeForExpression ( ILExpression expr, TypeReference expectedType, bool forceInferChildren = false ) : TypeReference
FindNestedAssignments ( ILExpression expr, ExpressionToInfer parent ) : void
GetNullableTypeArgument ( TypeReference type ) : TypeReference
HandleConversion ( int targetBitSize, bool targetSigned, ILExpression arg, TypeReference expectedType, TypeReference targetType ) : TypeReference
IdentifySingleLoadVariables ( ) : void
InferArgumentsInAddition ( ILExpression expr, bool isSigned, TypeReference expectedType ) : TypeReference
InferArgumentsInBinaryOperator ( ILExpression expr, bool isSigned, TypeReference expectedType ) : TypeReference
InferArgumentsInSubtraction ( ILExpression expr, bool isSigned, TypeReference expectedType ) : TypeReference
InferBinaryArguments ( ILExpression left, ILExpression right, TypeReference expectedType, bool forceInferChildren = false, TypeReference leftPreferred = null, TypeReference rightPreferred = null ) : TypeReference
InferTypeForExpression ( ILExpression expr, TypeReference expectedType, bool forceInferChildren = false ) : TypeReference

Infers the C# type of expr.

IsArrayPointerOrReference ( TypeReference type ) : bool
IsNullableType ( TypeReference type ) : bool
IsSigned ( TypeReference type ) : bool?
MakeRefIfValueType ( TypeReference type, ILExpressionPrefix constrainedPrefix ) : TypeReference

Wraps 'type' in a ByReferenceType if it is a value type. If a constrained prefix is specified, returns the constrained type wrapped in a ByReferenceType.

NumericPromotion ( TypeReference type ) : TypeReference

Promotes primitive types smaller than int32 to int32.

Always promotes to signed int32.

OperandFitsInType ( TypeReference type, int num ) : bool
RunInference ( ) : void
RunInference ( ILExpression expr ) : void
TypeWithMoreInformation ( TypeReference leftPreferred, TypeReference rightPreferred ) : TypeReference
UnpackModifiers ( TypeReference type ) : TypeReference
UnpackPointer ( TypeReference pointerOrManagedReference ) : TypeReference

Method Details

GetEnumUnderlyingType() public static method

Gets the underlying type, if the specified type is an enum. Otherwise, returns null.
public static GetEnumUnderlyingType ( TypeReference enumType ) : TypeReference
enumType TypeReference
return TypeReference

GetFieldType() public static method

public static GetFieldType ( FieldReference fieldReference ) : TypeReference
fieldReference FieldReference
return TypeReference

GetInformationAmount() public static method

public static GetInformationAmount ( TypeReference type ) : int
type TypeReference
return int

GetTypeCode() public static method

public static GetTypeCode ( TypeReference type ) : TypeCode
type TypeReference
return TypeCode

IsBoolean() public static method

public static IsBoolean ( TypeReference type ) : bool
type TypeReference
return bool

IsEnum() public static method

public static IsEnum ( TypeReference type ) : bool
type TypeReference
return bool

IsIntegerOrEnum() public static method

public static IsIntegerOrEnum ( TypeReference type ) : bool
type TypeReference
return bool

IsSameType() public static method

public static IsSameType ( TypeReference type1, TypeReference type2 ) : bool
type1 TypeReference
type2 TypeReference
return bool

Reset() public static method

Clears the type inference data on the method.
public static Reset ( ILBlock method ) : void
method ILBlock
return void

Run() public static method

public static Run ( DecompilerContext context, ILBlock method ) : void
context DecompilerContext
method ILBlock
return void

SubstituteTypeArgs() public static method

public static SubstituteTypeArgs ( TypeReference type, MemberReference member ) : TypeReference
type TypeReference
member MemberReference
return TypeReference