Table of Contents

Class Conv

Namespace
ICSharpCode.Decompiler.IL
Assembly
ICSharpCode.Decompiler.dll

Numeric cast.

public sealed class Conv : UnaryInstruction, ILiftableInstruction
Inheritance
Conv
Implements
Inherited Members

Constructors

Conv(ILInstruction, PrimitiveType, bool, Sign)

public Conv(ILInstruction argument, PrimitiveType targetType, bool checkForOverflow, Sign inputSign)

Parameters

argument ILInstruction
targetType PrimitiveType
checkForOverflow bool
inputSign Sign

Conv(ILInstruction, StackType, Sign, PrimitiveType, bool, bool)

public Conv(ILInstruction argument, StackType inputType, Sign inputSign, PrimitiveType targetType, bool checkForOverflow, bool isLifted = false)

Parameters

argument ILInstruction
inputType StackType
inputSign Sign
targetType PrimitiveType
checkForOverflow bool
isLifted bool

Fields

CheckForOverflow

Gets whether the conversion performs overflow-checking.

public readonly bool CheckForOverflow

Field Value

bool

InputSign

Gets the sign of the input type.

For conversions to integer types, the input Sign is set iff overflow-checking is enabled. For conversions to floating-point types, the input sign is always set.

public readonly Sign InputSign

Field Value

Sign

Remarks

The input sign does not have any effect on whether the conversion zero-extends or sign-extends; that is purely determined by the TargetType.

InputType

Gets the stack type of the input type.

public readonly StackType InputType

Field Value

StackType

Remarks

For non-lifted conversions, this is equal to Argument.ResultType. For lifted conversions, corresponds to the underlying type of the argument.

Kind

Gets the conversion kind.

public readonly ConversionKind Kind

Field Value

ConversionKind

TargetType

The target type of the conversion.

public readonly PrimitiveType TargetType

Field Value

PrimitiveType

Remarks

For lifted conversions, corresponds to the underlying target type.

Target type == PrimitiveType.None can happen for implicit conversions to O in invalid IL.

Properties

IsLifted

Gets whether this conversion is a lifted nullable conversion.

public bool IsLifted { get; }

Property Value

bool

Remarks

A lifted conversion expects its argument to be a value of type Nullable{T}, where T.GetStackType() == conv.InputType. If the value is non-null:

  • it is sign/zero-extended to InputType (based on T's sign)
  • the underlying conversion is performed
  • the result is wrapped in a Nullable{TargetType}. If the value is null, the conversion evaluates to default(TargetType?). (this result type is underspecified, since there may be multiple C# types for the TargetType)

ResultType

Gets the stack type of the value produced by this instruction.

public override StackType ResultType { get; }

Property Value

StackType

UnderlyingResultType

If the instruction is lifted and returns a nullable result, gets the underlying result type.

Note that not all lifted instructions return a nullable result: C# comparisons always return a bool!

public StackType UnderlyingResultType { get; }

Property Value

StackType

Methods

AcceptVisitor(ILVisitor)

Calls the Visit*-method on the visitor corresponding to the concrete type of this instruction.

public override void AcceptVisitor(ILVisitor visitor)

Parameters

visitor ILVisitor

AcceptVisitor<T>(ILVisitor<T>)

Calls the Visit*-method on the visitor corresponding to the concrete type of this instruction.

public override T AcceptVisitor<T>(ILVisitor<T> visitor)

Parameters

visitor ILVisitor<T>

Returns

T

Type Parameters

T

AcceptVisitor<C, T>(ILVisitor<C, T>, C)

Calls the Visit*-method on the visitor corresponding to the concrete type of this instruction.

public override T AcceptVisitor<C, T>(ILVisitor<C, T> visitor, C context)

Parameters

visitor ILVisitor<C, T>
context C

Returns

T

Type Parameters

C
T

ComputeFlags()

protected override InstructionFlags ComputeFlags()

Returns

InstructionFlags

PerformMatch(ILInstruction?, ref Match)

protected override bool PerformMatch(ILInstruction? other, ref Match match)

Parameters

other ILInstruction
match Match

Returns

bool

UnwrapConv(ConversionKind)

public override ILInstruction UnwrapConv(ConversionKind kind)

Parameters

kind ConversionKind

Returns

ILInstruction

WriteTo(ITextOutput, ILAstWritingOptions)

Writes the ILAst to the text output.

public override void WriteTo(ITextOutput output, ILAstWritingOptions options)

Parameters

output ITextOutput
options ILAstWritingOptions