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
Properties
Ancestors
Gets the ancestors of this node (including the node itself as first element).
public IEnumerable<ILInstruction> Ancestors { get; }
Property Value
ChildIndex
Gets the index of this node in the Parent.Children
collection.
public int ChildIndex { get; }
Property Value
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
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
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
EndILOffset
public int EndILOffset { get; }
Property Value
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
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
ILRanges
public IEnumerable<Interval> ILRanges { get; }
Property Value
IsConnected
Gets whether this ILInstruction is connected to the root node of the ILAst.
protected bool IsConnected { get; }
Property Value
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
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
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
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
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
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
Returns
ComputeFlags()
protected abstract InstructionFlags ComputeFlags()
Returns
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
GetChild(int)
protected abstract ILInstruction GetChild(int index)
Parameters
index
int
Returns
GetChildCount()
protected abstract int GetChildCount()
Returns
GetChildSlot(int)
protected abstract SlotInfo GetChildSlot(int index)
Parameters
index
int
Returns
GetCommonParent(ILInstruction)
public ILInstruction? GetCommonParent(ILInstruction other)
Parameters
other
ILInstruction
Returns
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
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
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
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
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
ILInstructionThe 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
ILInstructiontype
IType
Returns
MatchArglist()
public bool MatchArglist()
Returns
MatchAwait(out ILInstruction?)
public bool MatchAwait(out ILInstruction? value)
Parameters
value
ILInstruction
Returns
MatchBinaryNumericInstruction(BinaryNumericOperator)
public bool MatchBinaryNumericInstruction(BinaryNumericOperator @operator)
Parameters
operator
BinaryNumericOperator
Returns
MatchBinaryNumericInstruction(BinaryNumericOperator, out ILInstruction?, out ILInstruction?)
public bool MatchBinaryNumericInstruction(BinaryNumericOperator @operator, out ILInstruction? left, out ILInstruction? right)
Parameters
operator
BinaryNumericOperatorleft
ILInstructionright
ILInstruction
Returns
MatchBinaryNumericInstruction(out BinaryNumericOperator, out ILInstruction?, out ILInstruction?)
public bool MatchBinaryNumericInstruction(out BinaryNumericOperator @operator, out ILInstruction? left, out ILInstruction? right)
Parameters
operator
BinaryNumericOperatorleft
ILInstructionright
ILInstruction
Returns
MatchBox(out ILInstruction?, out IType?)
public bool MatchBox(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchBranch(Block?)
public bool MatchBranch(Block? targetBlock)
Parameters
targetBlock
Block
Returns
MatchBranch(out Block?)
public bool MatchBranch(out Block? targetBlock)
Parameters
targetBlock
Block
Returns
MatchCastClass(out ILInstruction?, out IType?)
public bool MatchCastClass(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchCkfinite(out ILInstruction?)
public bool MatchCkfinite(out ILInstruction? argument)
Parameters
argument
ILInstruction
Returns
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
ILInstructionright
ILInstruction
Returns
MatchCompEqualsNull(out ILInstruction?)
Matches 'comp(arg == ldnull)'
public bool MatchCompEqualsNull(out ILInstruction? arg)
Parameters
arg
ILInstruction
Returns
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
ILInstructionright
ILInstruction
Returns
MatchCompNotEqualsNull(out ILInstruction?)
Matches 'comp(arg != ldnull)'
public bool MatchCompNotEqualsNull(out ILInstruction? arg)
Parameters
arg
ILInstruction
Returns
MatchCpblk(out ILInstruction?, out ILInstruction?, out ILInstruction?)
public bool MatchCpblk(out ILInstruction? destAddress, out ILInstruction? sourceAddress, out ILInstruction? size)
Parameters
destAddress
ILInstructionsourceAddress
ILInstructionsize
ILInstruction
Returns
MatchDebugBreak()
public bool MatchDebugBreak()
Returns
MatchDefaultOrNullOrZero()
public bool MatchDefaultOrNullOrZero()
Returns
MatchDefaultValue(out IType?)
public bool MatchDefaultValue(out IType? type)
Parameters
type
IType
Returns
MatchGetPinnableReference(out ILInstruction?, out IMethod?)
public bool MatchGetPinnableReference(out ILInstruction? argument, out IMethod? method)
Parameters
argument
ILInstructionmethod
IMethod
Returns
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
ILInstructiontrueInst
ILInstruction
Returns
MatchIfInstruction(out ILInstruction?, out ILInstruction?, out ILInstruction?)
public bool MatchIfInstruction(out ILInstruction? condition, out ILInstruction? trueInst, out ILInstruction? falseInst)
Parameters
condition
ILInstructiontrueInst
ILInstructionfalseInst
ILInstruction
Returns
MatchIfInstructionPositiveCondition(out ILInstruction?, out ILInstruction?, out ILInstruction?)
public bool MatchIfInstructionPositiveCondition(out ILInstruction? condition, out ILInstruction? trueInst, out ILInstruction? falseInst)
Parameters
condition
ILInstructiontrueInst
ILInstructionfalseInst
ILInstruction
Returns
MatchInitblk(out ILInstruction?, out ILInstruction?, out ILInstruction?)
public bool MatchInitblk(out ILInstruction? address, out ILInstruction? value, out ILInstruction? size)
Parameters
address
ILInstructionvalue
ILInstructionsize
ILInstruction
Returns
MatchInvalidBranch()
public bool MatchInvalidBranch()
Returns
MatchInvalidExpression()
public bool MatchInvalidExpression()
Returns
MatchIsInst(out ILInstruction?, out IType?)
public bool MatchIsInst(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchLdElema(out IType?, out ILInstruction?)
public bool MatchLdElema(out IType? type, out ILInstruction? array)
Parameters
type
ITypearray
ILInstruction
Returns
MatchLdFld(out ILInstruction?, out IField?)
public bool MatchLdFld(out ILInstruction? target, out IField? field)
Parameters
target
ILInstructionfield
IField
Returns
MatchLdFlda(out ILInstruction?, out IField?)
public bool MatchLdFlda(out ILInstruction? target, out IField? field)
Parameters
target
ILInstructionfield
IField
Returns
MatchLdFtn(out IMethod?)
public bool MatchLdFtn(out IMethod? method)
Parameters
method
IMethod
Returns
MatchLdLen(StackType, out ILInstruction?)
public bool MatchLdLen(StackType type, out ILInstruction? array)
Parameters
type
StackTypearray
ILInstruction
Returns
MatchLdLoc(ILVariable?)
public bool MatchLdLoc(ILVariable? variable)
Parameters
variable
ILVariable
Returns
MatchLdLoc(out ILVariable?)
public bool MatchLdLoc(out ILVariable? variable)
Parameters
variable
ILVariable
Returns
MatchLdLocRef(ILVariable?)
Matches either ldloc (if the variable is a reference type), or ldloca (otherwise).
public bool MatchLdLocRef(ILVariable? variable)
Parameters
variable
ILVariable
Returns
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
MatchLdLoca(ILVariable?)
public bool MatchLdLoca(ILVariable? variable)
Parameters
variable
ILVariable
Returns
MatchLdLoca(out ILVariable?)
public bool MatchLdLoca(out ILVariable? variable)
Parameters
variable
ILVariable
Returns
MatchLdMemberToken(out IMember?)
public bool MatchLdMemberToken(out IMember? member)
Parameters
member
IMember
Returns
MatchLdNull()
public bool MatchLdNull()
Returns
MatchLdObj(out ILInstruction?, out IType?)
public bool MatchLdObj(out ILInstruction? target, out IType? type)
Parameters
target
ILInstructiontype
IType
Returns
MatchLdStr(out string?)
public bool MatchLdStr(out string? value)
Parameters
value
string
Returns
MatchLdStrUtf8(out string?)
public bool MatchLdStrUtf8(out string? value)
Parameters
value
string
Returns
MatchLdThis()
public bool MatchLdThis()
Returns
MatchLdTypeToken(out IType?)
public bool MatchLdTypeToken(out IType? type)
Parameters
type
IType
Returns
MatchLdVirtDelegate(out ILInstruction?, out IType?, out IMethod?)
public bool MatchLdVirtDelegate(out ILInstruction? argument, out IType? type, out IMethod? method)
Parameters
argument
ILInstructiontype
ITypemethod
IMethod
Returns
MatchLdVirtFtn(out ILInstruction?, out IMethod?)
public bool MatchLdVirtFtn(out ILInstruction? argument, out IMethod? method)
Parameters
argument
ILInstructionmethod
IMethod
Returns
MatchLdcDecimal(out decimal)
public bool MatchLdcDecimal(out decimal value)
Parameters
value
decimal
Returns
MatchLdcF4(float)
public bool MatchLdcF4(float value)
Parameters
value
float
Returns
MatchLdcF4(out float)
public bool MatchLdcF4(out float value)
Parameters
value
float
Returns
MatchLdcF8(double)
public bool MatchLdcF8(double value)
Parameters
value
double
Returns
MatchLdcF8(out double)
public bool MatchLdcF8(out double value)
Parameters
value
double
Returns
MatchLdcI(long)
public bool MatchLdcI(long val)
Parameters
val
long
Returns
MatchLdcI(out long)
Matches ldc.i4, ldc.i8, and extending conversions.
public bool MatchLdcI(out long val)
Parameters
val
long
Returns
MatchLdcI4(int)
public bool MatchLdcI4(int val)
Parameters
val
int
Returns
MatchLdcI4(out int)
public bool MatchLdcI4(out int value)
Parameters
value
int
Returns
MatchLdcI8(out long)
public bool MatchLdcI8(out long value)
Parameters
value
long
Returns
MatchLdsFld(IField?)
public bool MatchLdsFld(IField? field)
Parameters
field
IField
Returns
MatchLdsFld(out IField?)
public bool MatchLdsFld(out IField? field)
Parameters
field
IField
Returns
MatchLdsFlda(out IField?)
public bool MatchLdsFlda(out IField? field)
Parameters
field
IField
Returns
MatchLeave(BlockContainer?)
public bool MatchLeave(BlockContainer? targetContainer)
Parameters
targetContainer
BlockContainer
Returns
MatchLeave(BlockContainer?, out ILInstruction?)
public bool MatchLeave(BlockContainer? targetContainer, out ILInstruction? value)
Parameters
targetContainer
BlockContainervalue
ILInstruction
Returns
MatchLeave(out BlockContainer?)
public bool MatchLeave(out BlockContainer? targetContainer)
Parameters
targetContainer
BlockContainer
Returns
MatchLeave(out BlockContainer?, out ILInstruction?)
public bool MatchLeave(out BlockContainer? targetContainer, out ILInstruction? value)
Parameters
targetContainer
BlockContainervalue
ILInstruction
Returns
MatchLocAlloc(out ILInstruction?)
public bool MatchLocAlloc(out ILInstruction? argument)
Parameters
argument
ILInstruction
Returns
MatchLocAllocSpan(out ILInstruction?, out IType?)
public bool MatchLocAllocSpan(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchLockInstruction(out ILInstruction?, out ILInstruction?)
public bool MatchLockInstruction(out ILInstruction? onExpression, out ILInstruction? body)
Parameters
onExpression
ILInstructionbody
ILInstruction
Returns
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
ILInstructionrhs
ILInstruction
Returns
MatchLogicNot(out ILInstruction?)
Matches an logical negation.
public bool MatchLogicNot(out ILInstruction? arg)
Parameters
arg
ILInstruction
Returns
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
ILInstructionrhs
ILInstruction
Returns
MatchMakeRefAny(out ILInstruction?, out IType?)
public bool MatchMakeRefAny(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchMatchInstruction(out ILVariable?, out IMethod?, out ILInstruction?)
public bool MatchMatchInstruction(out ILVariable? variable, out IMethod? method, out ILInstruction? testedOperand)
Parameters
variable
ILVariablemethod
IMethodtestedOperand
ILInstruction
Returns
MatchNewArr(out IType?)
public bool MatchNewArr(out IType? type)
Parameters
type
IType
Returns
MatchNop()
public bool MatchNop()
Returns
MatchNullableRewrap(out ILInstruction?)
public bool MatchNullableRewrap(out ILInstruction? argument)
Parameters
argument
ILInstruction
Returns
MatchPinnedRegion(out ILVariable?, out ILInstruction?, out ILInstruction?)
public bool MatchPinnedRegion(out ILVariable? variable, out ILInstruction? init, out ILInstruction? body)
Parameters
variable
ILVariableinit
ILInstructionbody
ILInstruction
Returns
MatchRefAnyType(out ILInstruction?)
public bool MatchRefAnyType(out ILInstruction? argument)
Parameters
argument
ILInstruction
Returns
MatchRefAnyValue(out ILInstruction?, out IType?)
public bool MatchRefAnyValue(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchRethrow()
public bool MatchRethrow()
Returns
MatchReturn(out ILInstruction?)
public bool MatchReturn(out ILInstruction? value)
Parameters
value
ILInstruction
Returns
MatchSizeOf(out IType?)
public bool MatchSizeOf(out IType? type)
Parameters
type
IType
Returns
MatchStFld(out ILInstruction?, out IField?, out ILInstruction?)
public bool MatchStFld(out ILInstruction? target, out IField? field, out ILInstruction? value)
Parameters
target
ILInstructionfield
IFieldvalue
ILInstruction
Returns
MatchStLoc(ILVariable?, out ILInstruction?)
public bool MatchStLoc(ILVariable? variable, out ILInstruction? value)
Parameters
variable
ILVariablevalue
ILInstruction
Returns
MatchStLoc(out ILVariable?)
public bool MatchStLoc(out ILVariable? variable)
Parameters
variable
ILVariable
Returns
MatchStLoc(out ILVariable?, out ILInstruction?)
public bool MatchStLoc(out ILVariable? variable, out ILInstruction? value)
Parameters
variable
ILVariablevalue
ILInstruction
Returns
MatchStObj(out ILInstruction?, out ILInstruction?, out IType?)
public bool MatchStObj(out ILInstruction? target, out ILInstruction? value, out IType? type)
Parameters
target
ILInstructionvalue
ILInstructiontype
IType
Returns
MatchStsFld(out IField?, out ILInstruction?)
public bool MatchStsFld(out IField? field, out ILInstruction? value)
Parameters
field
IFieldvalue
ILInstruction
Returns
MatchThreeValuedBoolAnd(out ILInstruction?, out ILInstruction?)
public bool MatchThreeValuedBoolAnd(out ILInstruction? left, out ILInstruction? right)
Parameters
left
ILInstructionright
ILInstruction
Returns
MatchThreeValuedBoolOr(out ILInstruction?, out ILInstruction?)
public bool MatchThreeValuedBoolOr(out ILInstruction? left, out ILInstruction? right)
Parameters
left
ILInstructionright
ILInstruction
Returns
MatchThrow(out ILInstruction?)
public bool MatchThrow(out ILInstruction? argument)
Parameters
argument
ILInstruction
Returns
MatchTryCatchHandler(out ILInstruction?, out ILInstruction?, out ILVariable?)
public bool MatchTryCatchHandler(out ILInstruction? filter, out ILInstruction? body, out ILVariable? variable)
Parameters
filter
ILInstructionbody
ILInstructionvariable
ILVariable
Returns
MatchTryCatchHandler(out ILVariable?)
public bool MatchTryCatchHandler(out ILVariable? variable)
Parameters
variable
ILVariable
Returns
MatchUnbox(out ILInstruction?, out IType?)
public bool MatchUnbox(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchUnboxAny(out ILInstruction?, out IType?)
public bool MatchUnboxAny(out ILInstruction? argument, out IType? type)
Parameters
argument
ILInstructiontype
IType
Returns
MatchUserDefinedLogicOperator(out IMethod?, out ILInstruction?, out ILInstruction?)
public bool MatchUserDefinedLogicOperator(out IMethod? method, out ILInstruction? left, out ILInstruction? right)
Parameters
method
IMethodleft
ILInstructionright
ILInstruction
Returns
MatchUsingInstruction(out ILVariable?, out ILInstruction?, out ILInstruction?)
public bool MatchUsingInstruction(out ILVariable? variable, out ILInstruction? resourceExpression, out ILInstruction? body)
Parameters
variable
ILVariableresourceExpression
ILInstructionbody
ILInstruction
Returns
MatchYieldReturn(out ILInstruction?)
public bool MatchYieldReturn(out ILInstruction? value)
Parameters
value
ILInstruction
Returns
PerformMatch(ILInstruction?, ref Match)
Attempts matching this instruction against the other instruction.
protected abstract bool PerformMatch(ILInstruction? other, ref Match match)
Parameters
other
ILInstructionThe instruction to compare with.
match
MatchThe 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
ListMatchStores state about the current list match.
match
MatchThe 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
intvalue
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
TReference to the field holding the child
newValue
TNew child
index
intIndex 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
Remarks
Like MemberwiseClone(), except that the new instruction starts as disconnected.
ToString()
public override string ToString()
Returns
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
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
ITextOutputoptions
ILAstWritingOptions
WriteTo(ITextOutput, ILAstWritingOptions)
Writes the ILAst to the text output.
public abstract void WriteTo(ITextOutput output, ILAstWritingOptions options)
Parameters
output
ITextOutputoptions
ILAstWritingOptions