Table of Contents

Class ILInstruction

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

Represents a decoded IL instruction

public abstract class ILInstruction
Inheritance
ILInstruction
Derived
Inherited Members

Constructors

ILInstruction(OpCode)

protected ILInstruction(OpCode opCode)

Parameters

opCode OpCode

Fields

OpCode

public readonly OpCode OpCode

Field Value

OpCode

Properties

Ancestors

Gets the ancestors of this node (including the node itself as first element).

public IEnumerable<ILInstruction> Ancestors { get; }

Property Value

IEnumerable<ILInstruction>

ChildIndex

Gets the index of this node in the Parent.Children collection.

public int ChildIndex { get; }

Property Value

int

Remarks

It is temporarily possible for a node to be used in multiple places in the ILAst, this property returns the index of the primary position of this node (see remarks on Parent).

Children

Gets the child nodes of this instruction.

public ILInstruction.ChildrenCollection Children { get; }

Property Value

ILInstruction.ChildrenCollection

Remarks

The ChildrenCollection does not actually store the list of children, it merely allows accessing the children stored in the various slots.

Descendants

Returns all descendants of the ILInstruction in post-order. (including the ILInstruction itself)

public IEnumerable<ILInstruction> Descendants { get; }

Property Value

IEnumerable<ILInstruction>

Remarks

Within a loop 'foreach (var node in inst.Descendants)', it is illegal to add or remove from the child collections of node's ancestors, as those are currently being enumerated. Note that it is valid to modify node's children as those were already previously visited. As a special case, it is also allowed to replace node itself with another node.

DirectFlags

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

public abstract InstructionFlags DirectFlags { get; }

Property Value

InstructionFlags

EndILOffset

public int EndILOffset { get; }

Property Value

int

Flags

Gets the flags describing the behavior of this instruction. This property computes the flags on-demand and caches them until some change to the ILAst invalidates the cache.

public InstructionFlags Flags { get; }

Property Value

InstructionFlags

Remarks

Flag cache invalidation makes use of the Parent property, so it is possible for this property to return a stale value if the instruction contains "stale positions" (see remarks on Parent property).

ILRangeIsEmpty

public bool ILRangeIsEmpty { get; }

Property Value

bool

ILRanges

public IEnumerable<Interval> ILRanges { get; }

Property Value

IEnumerable<Interval>

IsConnected

Gets whether this ILInstruction is connected to the root node of the ILAst.

protected bool IsConnected { get; }

Property Value

bool

Remarks

This property returns true if the ILInstruction is reachable from the root node of the ILAst; it does not make use of the Parent field so the considerations about orphaned nodes and stale positions don't apply.

Parent

Gets the parent of this ILInstruction.

public ILInstruction? Parent { get; }

Property Value

ILInstruction

Remarks

It is temporarily possible for a node to be used in multiple places in the ILAst (making the ILAst a DAG instead of a tree). The Parent and ChildIndex properties are written whenever a node is stored in a slot. The node's occurrence in that slot is termed the "primary position" of the node, and all other (older) uses of the nodes are termed "stale positions".

A consistent ILAst must not contain any stale positions. Debug builds of ILSpy check the ILAst for consistency after every IL transform.

If a slot containing a node is overwritten with another node, the Parent and ChildIndex of the old node are not modified. This allows overwriting stale positions to restore consistency of the ILAst.

If a "primary position" is overwritten, the Parent of the old node also remains unmodified. This makes the old node an "orphaned node". Orphaned nodes may later be added back to the ILAst (or can just be garbage-collected).

Note that is it is possible (though unusual) for a stale position to reference an orphaned node.

ResultType

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

public abstract StackType ResultType { get; }

Property Value

StackType

SlotInfo

Gets information about the slot in which this instruction is stored. (i.e., the relation of this instruction to its parent instruction)

public SlotInfo? SlotInfo { get; }

Property Value

SlotInfo

Remarks

It is temporarily possible for a node to be used in multiple places in the ILAst, this property returns the slot of the primary position of this node (see remarks on Parent).

Precondition: this node must not be orphaned.

StartILOffset

public int StartILOffset { get; }

Property Value

int

Methods

AcceptVisitor(ILVisitor)

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

public abstract 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 abstract 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 abstract T AcceptVisitor<C, T>(ILVisitor<C, T> visitor, C context)

Parameters

visitor ILVisitor<C, T>
context C

Returns

T

Type Parameters

C
T

AddILRange(ILInstruction)

public void AddILRange(ILInstruction sourceInstruction)

Parameters

sourceInstruction ILInstruction

AddILRange(Interval)

public void AddILRange(Interval newRange)

Parameters

newRange Interval

Clone()

Creates a deep clone of the ILInstruction.

public abstract ILInstruction Clone()

Returns

ILInstruction

Remarks

It is valid to clone nodes with stale positions (see remarks on Parent); the result of such a clone will not contain any stale positions (nodes at multiple positions will be cloned once per position).

CombineILRange(Interval, Interval)

protected static Interval CombineILRange(Interval oldRange, Interval newRange)

Parameters

oldRange Interval
newRange Interval

Returns

Interval

ComputeFlags()

protected abstract InstructionFlags ComputeFlags()

Returns

InstructionFlags

Connected()

Called after the ILInstruction was connected to the root node of the ILAst.

protected virtual void Connected()

Disconnected()

Called after the ILInstruction was disconnected from the root node of the ILAst.

protected virtual void Disconnected()

Extract(ILTransformContext)

Extracts the this instruction. The instruction is replaced with a load of a new temporary variable; and the instruction is moved to a store to said variable at block-level. Returns the new variable.

If extraction is not possible, the ILAst is left unmodified and the function returns null. May return null if extraction is not possible.

public ILVariable Extract(ILTransformContext context)

Parameters

context ILTransformContext

Returns

ILVariable

GetChild(int)

protected abstract ILInstruction GetChild(int index)

Parameters

index int

Returns

ILInstruction

GetChildCount()

protected abstract int GetChildCount()

Returns

int

GetChildSlot(int)

protected abstract SlotInfo GetChildSlot(int index)

Parameters

index int

Returns

SlotInfo

GetCommonParent(ILInstruction)

public ILInstruction? GetCommonParent(ILInstruction other)

Parameters

other ILInstruction

Returns

ILInstruction

HasDirectFlag(InstructionFlags)

Returns whether the instruction (without considering child instructions) has at least one of the specified flags.

public bool HasDirectFlag(InstructionFlags flags)

Parameters

flags InstructionFlags

Returns

bool

HasFlag(InstructionFlags)

Returns whether the instruction (or one of its child instructions) has at least one of the specified flags.

public bool HasFlag(InstructionFlags flags)

Parameters

flags InstructionFlags

Returns

bool

InstructionCollectionAdded(ILInstruction)

Called when a new child is added to a InstructionCollection.

protected void InstructionCollectionAdded(ILInstruction newChild)

Parameters

newChild ILInstruction

InstructionCollectionRemoved(ILInstruction)

Called when a child is removed from a InstructionCollection.

protected void InstructionCollectionRemoved(ILInstruction oldChild)

Parameters

oldChild ILInstruction

InstructionCollectionUpdateComplete()

Called when a series of add/remove operations on the InstructionCollection is complete.

protected virtual void InstructionCollectionUpdateComplete()

InvalidateFlags()

protected void InvalidateFlags()

IsBefore(ILInstruction)

Returns whether this appears before other in a post-order walk of the whole tree.

public bool IsBefore(ILInstruction other)

Parameters

other ILInstruction

Returns

bool

IsDescendantOf(ILInstruction)

Gets whether this node is a descendant of possibleAncestor. Also returns true if this==possibleAncestor.

public bool IsDescendantOf(ILInstruction possibleAncestor)

Parameters

possibleAncestor ILInstruction

Returns

bool

Remarks

This method uses the Parent property, so it may produce surprising results when called on orphaned nodes or with a possibleAncestor that contains stale positions (see remarks on Parent property).

Match(ILInstruction)

Attempts to match the specified node against the pattern.

public Match Match(ILInstruction node)

Parameters

node ILInstruction

The syntax node to test against the pattern.

Returns

Match

Returns a match object describing the result of the matching operation. Check the Success property to see whether the match was successful. For successful matches, the match object allows retrieving the nodes that were matched with the captured groups.

MatchAddressOf(out ILInstruction?, out IType?)

public bool MatchAddressOf(out ILInstruction? value, out IType? type)

Parameters

value ILInstruction
type IType

Returns

bool

MatchArglist()

public bool MatchArglist()

Returns

bool

MatchAwait(out ILInstruction?)

public bool MatchAwait(out ILInstruction? value)

Parameters

value ILInstruction

Returns

bool

MatchBinaryNumericInstruction(BinaryNumericOperator)

public bool MatchBinaryNumericInstruction(BinaryNumericOperator @operator)

Parameters

operator BinaryNumericOperator

Returns

bool

MatchBinaryNumericInstruction(BinaryNumericOperator, out ILInstruction?, out ILInstruction?)

public bool MatchBinaryNumericInstruction(BinaryNumericOperator @operator, out ILInstruction? left, out ILInstruction? right)

Parameters

operator BinaryNumericOperator
left ILInstruction
right ILInstruction

Returns

bool

MatchBinaryNumericInstruction(out BinaryNumericOperator, out ILInstruction?, out ILInstruction?)

public bool MatchBinaryNumericInstruction(out BinaryNumericOperator @operator, out ILInstruction? left, out ILInstruction? right)

Parameters

operator BinaryNumericOperator
left ILInstruction
right ILInstruction

Returns

bool

MatchBox(out ILInstruction?, out IType?)

public bool MatchBox(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchBranch(Block?)

public bool MatchBranch(Block? targetBlock)

Parameters

targetBlock Block

Returns

bool

MatchBranch(out Block?)

public bool MatchBranch(out Block? targetBlock)

Parameters

targetBlock Block

Returns

bool

MatchCastClass(out ILInstruction?, out IType?)

public bool MatchCastClass(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchCkfinite(out ILInstruction?)

public bool MatchCkfinite(out ILInstruction? argument)

Parameters

argument ILInstruction

Returns

bool

MatchCompEquals(out ILInstruction?, out ILInstruction?)

Matches comp(left == right) or logic.not(comp(left != right)).

public bool MatchCompEquals(out ILInstruction? left, out ILInstruction? right)

Parameters

left ILInstruction
right ILInstruction

Returns

bool

MatchCompEqualsNull(out ILInstruction?)

Matches 'comp(arg == ldnull)'

public bool MatchCompEqualsNull(out ILInstruction? arg)

Parameters

arg ILInstruction

Returns

bool

MatchCompNotEquals(out ILInstruction?, out ILInstruction?)

Matches comp(left != right) or logic.not(comp(left == right)).

public bool MatchCompNotEquals(out ILInstruction? left, out ILInstruction? right)

Parameters

left ILInstruction
right ILInstruction

Returns

bool

MatchCompNotEqualsNull(out ILInstruction?)

Matches 'comp(arg != ldnull)'

public bool MatchCompNotEqualsNull(out ILInstruction? arg)

Parameters

arg ILInstruction

Returns

bool

MatchCpblk(out ILInstruction?, out ILInstruction?, out ILInstruction?)

public bool MatchCpblk(out ILInstruction? destAddress, out ILInstruction? sourceAddress, out ILInstruction? size)

Parameters

destAddress ILInstruction
sourceAddress ILInstruction
size ILInstruction

Returns

bool

MatchDebugBreak()

public bool MatchDebugBreak()

Returns

bool

MatchDefaultOrNullOrZero()

public bool MatchDefaultOrNullOrZero()

Returns

bool

MatchDefaultValue(out IType?)

public bool MatchDefaultValue(out IType? type)

Parameters

type IType

Returns

bool

MatchGetPinnableReference(out ILInstruction?, out IMethod?)

public bool MatchGetPinnableReference(out ILInstruction? argument, out IMethod? method)

Parameters

argument ILInstruction
method IMethod

Returns

bool

MatchIfInstruction(out ILInstruction?, out ILInstruction?)

Matches an if instruction where the false instruction is a nop.

public bool MatchIfInstruction(out ILInstruction? condition, out ILInstruction? trueInst)

Parameters

condition ILInstruction
trueInst ILInstruction

Returns

bool

MatchIfInstruction(out ILInstruction?, out ILInstruction?, out ILInstruction?)

public bool MatchIfInstruction(out ILInstruction? condition, out ILInstruction? trueInst, out ILInstruction? falseInst)

Parameters

condition ILInstruction
trueInst ILInstruction
falseInst ILInstruction

Returns

bool

MatchIfInstructionPositiveCondition(out ILInstruction?, out ILInstruction?, out ILInstruction?)

public bool MatchIfInstructionPositiveCondition(out ILInstruction? condition, out ILInstruction? trueInst, out ILInstruction? falseInst)

Parameters

condition ILInstruction
trueInst ILInstruction
falseInst ILInstruction

Returns

bool

MatchInitblk(out ILInstruction?, out ILInstruction?, out ILInstruction?)

public bool MatchInitblk(out ILInstruction? address, out ILInstruction? value, out ILInstruction? size)

Parameters

address ILInstruction
value ILInstruction
size ILInstruction

Returns

bool

MatchInvalidBranch()

public bool MatchInvalidBranch()

Returns

bool

MatchInvalidExpression()

public bool MatchInvalidExpression()

Returns

bool

MatchIsInst(out ILInstruction?, out IType?)

public bool MatchIsInst(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchLdElema(out IType?, out ILInstruction?)

public bool MatchLdElema(out IType? type, out ILInstruction? array)

Parameters

type IType
array ILInstruction

Returns

bool

MatchLdFld(out ILInstruction?, out IField?)

public bool MatchLdFld(out ILInstruction? target, out IField? field)

Parameters

target ILInstruction
field IField

Returns

bool

MatchLdFlda(out ILInstruction?, out IField?)

public bool MatchLdFlda(out ILInstruction? target, out IField? field)

Parameters

target ILInstruction
field IField

Returns

bool

MatchLdFtn(out IMethod?)

public bool MatchLdFtn(out IMethod? method)

Parameters

method IMethod

Returns

bool

MatchLdLen(StackType, out ILInstruction?)

public bool MatchLdLen(StackType type, out ILInstruction? array)

Parameters

type StackType
array ILInstruction

Returns

bool

MatchLdLoc(ILVariable?)

public bool MatchLdLoc(ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchLdLoc(out ILVariable?)

public bool MatchLdLoc(out ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchLdLocRef(ILVariable?)

Matches either ldloc (if the variable is a reference type), or ldloca (otherwise).

public bool MatchLdLocRef(ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchLdLocRef(out ILVariable?)

Matches either ldloc (if the variable is a reference type), or ldloca (otherwise).

public bool MatchLdLocRef(out ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchLdLoca(ILVariable?)

public bool MatchLdLoca(ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchLdLoca(out ILVariable?)

public bool MatchLdLoca(out ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchLdMemberToken(out IMember?)

public bool MatchLdMemberToken(out IMember? member)

Parameters

member IMember

Returns

bool

MatchLdNull()

public bool MatchLdNull()

Returns

bool

MatchLdObj(out ILInstruction?, out IType?)

public bool MatchLdObj(out ILInstruction? target, out IType? type)

Parameters

target ILInstruction
type IType

Returns

bool

MatchLdStr(out string?)

public bool MatchLdStr(out string? value)

Parameters

value string

Returns

bool

MatchLdStrUtf8(out string?)

public bool MatchLdStrUtf8(out string? value)

Parameters

value string

Returns

bool

MatchLdThis()

public bool MatchLdThis()

Returns

bool

MatchLdTypeToken(out IType?)

public bool MatchLdTypeToken(out IType? type)

Parameters

type IType

Returns

bool

MatchLdVirtDelegate(out ILInstruction?, out IType?, out IMethod?)

public bool MatchLdVirtDelegate(out ILInstruction? argument, out IType? type, out IMethod? method)

Parameters

argument ILInstruction
type IType
method IMethod

Returns

bool

MatchLdVirtFtn(out ILInstruction?, out IMethod?)

public bool MatchLdVirtFtn(out ILInstruction? argument, out IMethod? method)

Parameters

argument ILInstruction
method IMethod

Returns

bool

MatchLdcDecimal(out decimal)

public bool MatchLdcDecimal(out decimal value)

Parameters

value decimal

Returns

bool

MatchLdcF4(float)

public bool MatchLdcF4(float value)

Parameters

value float

Returns

bool

MatchLdcF4(out float)

public bool MatchLdcF4(out float value)

Parameters

value float

Returns

bool

MatchLdcF8(double)

public bool MatchLdcF8(double value)

Parameters

value double

Returns

bool

MatchLdcF8(out double)

public bool MatchLdcF8(out double value)

Parameters

value double

Returns

bool

MatchLdcI(long)

public bool MatchLdcI(long val)

Parameters

val long

Returns

bool

MatchLdcI(out long)

Matches ldc.i4, ldc.i8, and extending conversions.

public bool MatchLdcI(out long val)

Parameters

val long

Returns

bool

MatchLdcI4(int)

public bool MatchLdcI4(int val)

Parameters

val int

Returns

bool

MatchLdcI4(out int)

public bool MatchLdcI4(out int value)

Parameters

value int

Returns

bool

MatchLdcI8(out long)

public bool MatchLdcI8(out long value)

Parameters

value long

Returns

bool

MatchLdsFld(IField?)

public bool MatchLdsFld(IField? field)

Parameters

field IField

Returns

bool

MatchLdsFld(out IField?)

public bool MatchLdsFld(out IField? field)

Parameters

field IField

Returns

bool

MatchLdsFlda(out IField?)

public bool MatchLdsFlda(out IField? field)

Parameters

field IField

Returns

bool

MatchLeave(BlockContainer?)

public bool MatchLeave(BlockContainer? targetContainer)

Parameters

targetContainer BlockContainer

Returns

bool

MatchLeave(BlockContainer?, out ILInstruction?)

public bool MatchLeave(BlockContainer? targetContainer, out ILInstruction? value)

Parameters

targetContainer BlockContainer
value ILInstruction

Returns

bool

MatchLeave(out BlockContainer?)

public bool MatchLeave(out BlockContainer? targetContainer)

Parameters

targetContainer BlockContainer

Returns

bool

MatchLeave(out BlockContainer?, out ILInstruction?)

public bool MatchLeave(out BlockContainer? targetContainer, out ILInstruction? value)

Parameters

targetContainer BlockContainer
value ILInstruction

Returns

bool

MatchLocAlloc(out ILInstruction?)

public bool MatchLocAlloc(out ILInstruction? argument)

Parameters

argument ILInstruction

Returns

bool

MatchLocAllocSpan(out ILInstruction?, out IType?)

public bool MatchLocAllocSpan(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchLockInstruction(out ILInstruction?, out ILInstruction?)

public bool MatchLockInstruction(out ILInstruction? onExpression, out ILInstruction? body)

Parameters

onExpression ILInstruction
body ILInstruction

Returns

bool

MatchLogicAnd(out ILInstruction?, out ILInstruction?)

Matches a 'logic and' instruction ("if (a) b else ldc.i4 0"). Note: unlike C# '&&', this instruction is not limited to booleans, but allows passing through arbitrary I4 values on the rhs (but not on the lhs).

public bool MatchLogicAnd(out ILInstruction? lhs, out ILInstruction? rhs)

Parameters

lhs ILInstruction
rhs ILInstruction

Returns

bool

MatchLogicNot(out ILInstruction?)

Matches an logical negation.

public bool MatchLogicNot(out ILInstruction? arg)

Parameters

arg ILInstruction

Returns

bool

MatchLogicOr(out ILInstruction?, out ILInstruction?)

Matches a 'logic or' instruction ("if (a) ldc.i4 1 else b"). Note: unlike C# '||', this instruction is not limited to booleans, but allows passing through arbitrary I4 values on the rhs (but not on the lhs).

public bool MatchLogicOr(out ILInstruction? lhs, out ILInstruction? rhs)

Parameters

lhs ILInstruction
rhs ILInstruction

Returns

bool

MatchMakeRefAny(out ILInstruction?, out IType?)

public bool MatchMakeRefAny(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchMatchInstruction(out ILVariable?, out IMethod?, out ILInstruction?)

public bool MatchMatchInstruction(out ILVariable? variable, out IMethod? method, out ILInstruction? testedOperand)

Parameters

variable ILVariable
method IMethod
testedOperand ILInstruction

Returns

bool

MatchNewArr(out IType?)

public bool MatchNewArr(out IType? type)

Parameters

type IType

Returns

bool

MatchNop()

public bool MatchNop()

Returns

bool

MatchNullableRewrap(out ILInstruction?)

public bool MatchNullableRewrap(out ILInstruction? argument)

Parameters

argument ILInstruction

Returns

bool

MatchPinnedRegion(out ILVariable?, out ILInstruction?, out ILInstruction?)

public bool MatchPinnedRegion(out ILVariable? variable, out ILInstruction? init, out ILInstruction? body)

Parameters

variable ILVariable
init ILInstruction
body ILInstruction

Returns

bool

MatchRefAnyType(out ILInstruction?)

public bool MatchRefAnyType(out ILInstruction? argument)

Parameters

argument ILInstruction

Returns

bool

MatchRefAnyValue(out ILInstruction?, out IType?)

public bool MatchRefAnyValue(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchRethrow()

public bool MatchRethrow()

Returns

bool

MatchReturn(out ILInstruction?)

public bool MatchReturn(out ILInstruction? value)

Parameters

value ILInstruction

Returns

bool

MatchSizeOf(out IType?)

public bool MatchSizeOf(out IType? type)

Parameters

type IType

Returns

bool

MatchStFld(out ILInstruction?, out IField?, out ILInstruction?)

public bool MatchStFld(out ILInstruction? target, out IField? field, out ILInstruction? value)

Parameters

target ILInstruction
field IField
value ILInstruction

Returns

bool

MatchStLoc(ILVariable?, out ILInstruction?)

public bool MatchStLoc(ILVariable? variable, out ILInstruction? value)

Parameters

variable ILVariable
value ILInstruction

Returns

bool

MatchStLoc(out ILVariable?)

public bool MatchStLoc(out ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchStLoc(out ILVariable?, out ILInstruction?)

public bool MatchStLoc(out ILVariable? variable, out ILInstruction? value)

Parameters

variable ILVariable
value ILInstruction

Returns

bool

MatchStObj(out ILInstruction?, out ILInstruction?, out IType?)

public bool MatchStObj(out ILInstruction? target, out ILInstruction? value, out IType? type)

Parameters

target ILInstruction
value ILInstruction
type IType

Returns

bool

MatchStsFld(out IField?, out ILInstruction?)

public bool MatchStsFld(out IField? field, out ILInstruction? value)

Parameters

field IField
value ILInstruction

Returns

bool

MatchThreeValuedBoolAnd(out ILInstruction?, out ILInstruction?)

public bool MatchThreeValuedBoolAnd(out ILInstruction? left, out ILInstruction? right)

Parameters

left ILInstruction
right ILInstruction

Returns

bool

MatchThreeValuedBoolOr(out ILInstruction?, out ILInstruction?)

public bool MatchThreeValuedBoolOr(out ILInstruction? left, out ILInstruction? right)

Parameters

left ILInstruction
right ILInstruction

Returns

bool

MatchThrow(out ILInstruction?)

public bool MatchThrow(out ILInstruction? argument)

Parameters

argument ILInstruction

Returns

bool

MatchTryCatchHandler(out ILInstruction?, out ILInstruction?, out ILVariable?)

public bool MatchTryCatchHandler(out ILInstruction? filter, out ILInstruction? body, out ILVariable? variable)

Parameters

filter ILInstruction
body ILInstruction
variable ILVariable

Returns

bool

MatchTryCatchHandler(out ILVariable?)

public bool MatchTryCatchHandler(out ILVariable? variable)

Parameters

variable ILVariable

Returns

bool

MatchUnbox(out ILInstruction?, out IType?)

public bool MatchUnbox(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchUnboxAny(out ILInstruction?, out IType?)

public bool MatchUnboxAny(out ILInstruction? argument, out IType? type)

Parameters

argument ILInstruction
type IType

Returns

bool

MatchUserDefinedLogicOperator(out IMethod?, out ILInstruction?, out ILInstruction?)

public bool MatchUserDefinedLogicOperator(out IMethod? method, out ILInstruction? left, out ILInstruction? right)

Parameters

method IMethod
left ILInstruction
right ILInstruction

Returns

bool

MatchUsingInstruction(out ILVariable?, out ILInstruction?, out ILInstruction?)

public bool MatchUsingInstruction(out ILVariable? variable, out ILInstruction? resourceExpression, out ILInstruction? body)

Parameters

variable ILVariable
resourceExpression ILInstruction
body ILInstruction

Returns

bool

MatchYieldReturn(out ILInstruction?)

public bool MatchYieldReturn(out ILInstruction? value)

Parameters

value ILInstruction

Returns

bool

PerformMatch(ILInstruction?, ref Match)

Attempts matching this instruction against the other instruction.

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

Parameters

other ILInstruction

The instruction to compare with.

match Match

The match object, used to store global state during the match (such as the results of capture groups).

Returns

bool

Returns whether the (partial) match was successful. If the method returns true, it adds the capture groups (if any) to the match. If the method returns false, the match object may remain in a partially-updated state and needs to be restored before it can be reused.

PerformMatch(ref ListMatch, ref Match)

Attempts matching this instruction against a list of other instructions (or a part of said list).

protected virtual bool PerformMatch(ref ListMatch listMatch, ref Match match)

Parameters

listMatch ListMatch

Stores state about the current list match.

match Match

The match object, used to store global state during the match (such as the results of capture groups).

Returns

bool

Returns whether the (partial) match was successful. If the method returns true, it updates listMatch.SyntaxIndex to point to the next node that was not part of the match, and adds the capture groups (if any) to the match. If the method returns false, the listMatch and match objects remain in a partially-updated state and need to be restored before they can be reused.

ReplaceWith(ILInstruction)

Replaces this ILInstruction with the given replacement instruction.

public void ReplaceWith(ILInstruction replacement)

Parameters

replacement ILInstruction

Remarks

It is temporarily possible for a node to be used in multiple places in the ILAst, this method only replaces this node at its primary position (see remarks on Parent).

This means you cannot use ReplaceWith() to wrap an instruction in another node. For example, node.ReplaceWith(new BitNot(node)) will first call the BitNot constructor, which sets node.Parent to the BitNot instance. The ReplaceWith() call then attempts to set BitNot.Argument to the BitNot instance, which creates a cyclic ILAst. Meanwhile, node's original parent remains unmodified.

The solution in this case is to avoid using ReplaceWith. If the parent node is unknown, the following trick can be used:

node.Parent.Children[node.ChildIndex] = new BitNot(node);

Unlike the ReplaceWith() call, this will evaluate node.Parent and node.ChildIndex before the BitNot constructor is called, thus modifying the expected position in the ILAst.

SetChild(int, ILInstruction)

protected abstract void SetChild(int index, ILInstruction value)

Parameters

index int
value ILInstruction

SetChildInstruction<T>(ref T, T, int)

Replaces a child of this ILInstruction.

protected void SetChildInstruction<T>(ref T childPointer, T newValue, int index) where T : ILInstruction?

Parameters

childPointer T

Reference to the field holding the child

newValue T

New child

index int

Index of the field in the Children collection

Type Parameters

T

SetILRange(ILInstruction)

public void SetILRange(ILInstruction sourceInstruction)

Parameters

sourceInstruction ILInstruction

SetILRange(Interval)

public void SetILRange(Interval range)

Parameters

range Interval

ShallowClone()

Creates a shallow clone of the ILInstruction.

protected ILInstruction ShallowClone()

Returns

ILInstruction

Remarks

Like MemberwiseClone(), except that the new instruction starts as disconnected.

ToString()

public override string ToString()

Returns

string

UnwrapConv(ConversionKind)

If this instruction is a conversion of the specified kind, return its argument. Otherwise, return the instruction itself.

public virtual ILInstruction UnwrapConv(ConversionKind kind)

Parameters

kind ConversionKind

Returns

ILInstruction

Remarks

Does not unwrap lifted conversions.

ValidateChild(ILInstruction?)

protected void ValidateChild(ILInstruction? inst)

Parameters

inst ILInstruction

WriteILRange(ITextOutput, ILAstWritingOptions)

public void WriteILRange(ITextOutput output, ILAstWritingOptions options)

Parameters

output ITextOutput
options ILAstWritingOptions

WriteTo(ITextOutput, ILAstWritingOptions)

Writes the ILAst to the text output.

public abstract void WriteTo(ITextOutput output, ILAstWritingOptions options)

Parameters

output ITextOutput
options ILAstWritingOptions