C# Class Gendarme.Framework.Rocks.InstructionRocks

InstructionRocks contains extensions methods for Instruction and the related collection classes.
ファイルを表示 Open project: remobjects/mono-tools

Public Methods

Method Description
GetField ( this self ) : FieldDefinition

Get the FieldDefinition associated with the Instruction.

GetMethod ( this self ) : MethodReference

Get the MethodReference or MethodDefinition (but not a CallSite) associated with the Instruction

Older (pre 0.9) Cecil CallSite did not inherit from MethodReference so this was not an issue

GetOperand ( this self, Mono.Cecil.MethodDefinition method ) : object

Return the operand of the Instruction. For macro instruction the operand is constructed.

GetOperandType ( this self, Mono.Cecil.MethodDefinition method ) : TypeReference

Return the type associated with the instruction's operand (INCOMPLETE).

GetParameter ( this self, Mono.Cecil.MethodDefinition method ) : Mono.Cecil.ParameterDefinition

Get the ParameterDefinition associated with the Instruction.

GetPopCount ( this self, IMethodSignature method ) : int

Get the number of values removed on the stack for this instruction.

GetPushCount ( this self ) : int

Get the number of values placed on the stack by this instruction.

GetVariable ( this self, Mono.Cecil.MethodDefinition method ) : Mono.Cecil.Cil.VariableDefinition

Get the VariableDefinition associated with the Instruction.

Is ( this self, Code code ) : bool

Helper method to avoid patterns like "ins.Previous != null && ins.Previous.OpCode.Code == Code.Newobj" and replace it with a shorter "ins.Previous.Is (Code.Newobj)".

IsLoadArgument ( this self ) : bool

Return if the Instruction is a load of an argument (ldarg* family).

IsLoadElement ( this self ) : bool

Return if the Instruction is the load of an element (ldelem* family)

IsLoadIndirect ( this self ) : bool

Return if the Instruction is a load indirect (ldind* family)

IsLoadLocal ( this self ) : bool

Return if the Instruction is a load of a local variable (ldloc* family).

IsOperandZero ( this self ) : bool

Determine if the instruction operand contains the constant zero (0).

IsStoreArgument ( this self ) : bool

Return if the Instruction is a store of an argument (starg* family).

IsStoreLocal ( this self ) : bool

Return if the Instruction is a store of a local variable (stloc* family).

TraceBack ( this self, IMethodSignature method ) : Instruction

Return the instruction that match the current instruction. This is computed by substracting push and adding pop counts until the total becomes zero.

TraceBack ( this self, IMethodSignature method, int offset ) : Instruction

Return the instruction that match the current instruction. This is computed by substracting push and adding pop counts until the total becomes zero.

Method Details

GetField() public static method

Get the FieldDefinition associated with the Instruction.
public static GetField ( this self ) : FieldDefinition
self this The Instruction on which the extension method can be called.
return Mono.Cecil.FieldDefinition

GetMethod() public static method

Get the MethodReference or MethodDefinition (but not a CallSite) associated with the Instruction
Older (pre 0.9) Cecil CallSite did not inherit from MethodReference so this was not an issue
public static GetMethod ( this self ) : MethodReference
self this The Instruction on which the extension method can be called.
return Mono.Cecil.MethodReference

GetOperand() public static method

Return the operand of the Instruction. For macro instruction the operand is constructed.
public static GetOperand ( this self, Mono.Cecil.MethodDefinition method ) : object
self this The Instruction on which the extension method can be called.
method Mono.Cecil.MethodDefinition The method inside which the instruction comes from.
return object

GetOperandType() public static method

Return the type associated with the instruction's operand (INCOMPLETE).
public static GetOperandType ( this self, Mono.Cecil.MethodDefinition method ) : TypeReference
self this The Instruction on which the extension method can be called.
method Mono.Cecil.MethodDefinition The method inside which the instruction comes from.
return Mono.Cecil.TypeReference

GetParameter() public static method

Get the ParameterDefinition associated with the Instruction.
public static GetParameter ( this self, Mono.Cecil.MethodDefinition method ) : Mono.Cecil.ParameterDefinition
self this The Instruction on which the extension method can be called.
method Mono.Cecil.MethodDefinition The method inside which the instruction comes from. /// Needed for the macro instruction where only the variable index is available.
return Mono.Cecil.ParameterDefinition

GetPopCount() public static method

Get the number of values removed on the stack for this instruction.
public static GetPopCount ( this self, IMethodSignature method ) : int
self this The Instruction on which the extension method can be called.
method IMethodSignature The method inside which the instruction comes from /// (needed for StackBehaviour.Varpop).
return int

GetPushCount() public static method

Get the number of values placed on the stack by this instruction.
public static GetPushCount ( this self ) : int
self this The Instruction on which the extension method can be called.
return int

GetVariable() public static method

Get the VariableDefinition associated with the Instruction.
public static GetVariable ( this self, Mono.Cecil.MethodDefinition method ) : Mono.Cecil.Cil.VariableDefinition
self this The Instruction on which the extension method can be called.
method Mono.Cecil.MethodDefinition The method inside which the instruction comes from. /// Needed for the macro instruction where only the variable index is available.
return Mono.Cecil.Cil.VariableDefinition

Is() public static method

Helper method to avoid patterns like "ins.Previous != null && ins.Previous.OpCode.Code == Code.Newobj" and replace it with a shorter "ins.Previous.Is (Code.Newobj)".
public static Is ( this self, Code code ) : bool
self this The Instruction on which the extension method can be called.
code Code The Code to compare to.
return bool

IsLoadArgument() public static method

Return if the Instruction is a load of an argument (ldarg* family).
public static IsLoadArgument ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

IsLoadElement() public static method

Return if the Instruction is the load of an element (ldelem* family)
public static IsLoadElement ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

IsLoadIndirect() public static method

Return if the Instruction is a load indirect (ldind* family)
public static IsLoadIndirect ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

IsLoadLocal() public static method

Return if the Instruction is a load of a local variable (ldloc* family).
public static IsLoadLocal ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

IsOperandZero() public static method

Determine if the instruction operand contains the constant zero (0).
public static IsOperandZero ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

IsStoreArgument() public static method

Return if the Instruction is a store of an argument (starg* family).
public static IsStoreArgument ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

IsStoreLocal() public static method

Return if the Instruction is a store of a local variable (stloc* family).
public static IsStoreLocal ( this self ) : bool
self this The Instruction on which the extension method can be called.
return bool

TraceBack() public static method

Return the instruction that match the current instruction. This is computed by substracting push and adding pop counts until the total becomes zero.
public static TraceBack ( this self, IMethodSignature method ) : Instruction
self this The Instruction on which the extension method can be called.
method IMethodSignature The method from which the instruction was extracted.
return Mono.Cecil.Cil.Instruction

TraceBack() public static method

Return the instruction that match the current instruction. This is computed by substracting push and adding pop counts until the total becomes zero.
public static TraceBack ( this self, IMethodSignature method, int offset ) : Instruction
self this The Instruction on which the extension method can be called.
method IMethodSignature The method from which the instruction was extracted.
offset int Offset to add the the Pop count. Useful to track several parameters to a method.
return Mono.Cecil.Cil.Instruction