Table of Contents

Class IfInstruction

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

If statement / conditional expression. if (condition) trueExpr else falseExpr

public sealed class IfInstruction : ILInstruction
Inheritance
IfInstruction
Inherited Members

Remarks

The condition must return StackType.I4, use comparison instructions like Ceq to check if other types are non-zero.

If the condition evaluates to non-zero, the TrueInst is executed. If the condition evaluates to zero, the FalseInst is executed. The return value of the IfInstruction is the return value of the TrueInst or FalseInst.

IfInstruction is also used to represent logical operators: "a || b" ==> if (a) (ldc.i4 1) else (b) "a && b" ==> if (a) (b) else (ldc.i4 0) "a ? b : c" ==> if (a) (b) else (c)

Constructors

IfInstruction(ILInstruction, ILInstruction, ILInstruction?)

public IfInstruction(ILInstruction condition, ILInstruction trueInst, ILInstruction? falseInst = null)

Parameters

condition ILInstruction
trueInst ILInstruction
falseInst ILInstruction

Fields

ConditionSlot

public static readonly SlotInfo ConditionSlot

Field Value

SlotInfo

FalseInstSlot

public static readonly SlotInfo FalseInstSlot

Field Value

SlotInfo

TrueInstSlot

public static readonly SlotInfo TrueInstSlot

Field Value

SlotInfo

Properties

Condition

public ILInstruction Condition { get; set; }

Property Value

ILInstruction

DirectFlags

Gets the flags for this instruction only, without considering the child instructions.

public override InstructionFlags DirectFlags { get; }

Property Value

InstructionFlags

FalseInst

public ILInstruction FalseInst { get; set; }

Property Value

ILInstruction

ResultType

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

public override StackType ResultType { get; }

Property Value

StackType

TrueInst

public ILInstruction TrueInst { get; set; }

Property Value

ILInstruction

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

Clone()

public override sealed ILInstruction Clone()

Returns

ILInstruction

ComputeFlags()

protected override InstructionFlags ComputeFlags()

Returns

InstructionFlags

GetChild(int)

protected override sealed ILInstruction GetChild(int index)

Parameters

index int

Returns

ILInstruction

GetChildCount()

protected override sealed int GetChildCount()

Returns

int

GetChildSlot(int)

protected override sealed SlotInfo GetChildSlot(int index)

Parameters

index int

Returns

SlotInfo

LogicAnd(ILInstruction, ILInstruction)

public static IfInstruction LogicAnd(ILInstruction lhs, ILInstruction rhs)

Parameters

lhs ILInstruction
rhs ILInstruction

Returns

IfInstruction

LogicOr(ILInstruction, ILInstruction?)

public static IfInstruction LogicOr(ILInstruction lhs, ILInstruction? rhs)

Parameters

lhs ILInstruction
rhs ILInstruction

Returns

IfInstruction

PerformMatch(ILInstruction?, ref Match)

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

Parameters

other ILInstruction
match Match

Returns

bool

SetChild(int, ILInstruction)

protected override sealed void SetChild(int index, ILInstruction value)

Parameters

index int
value ILInstruction

WriteTo(ITextOutput, ILAstWritingOptions)

Writes the ILAst to the text output.

public override void WriteTo(ITextOutput output, ILAstWritingOptions options)

Parameters

output ITextOutput
options ILAstWritingOptions