C# Class Gendarme.Framework.Rocks.InstructionRocks

InstructionRocks contains extensions methods for Instruction and the related collection classes.
Afficher le fichier Open project: remobjects/mono-tools

Méthodes publiques

Méthode 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 méthode

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.
Résultat Mono.Cecil.FieldDefinition

GetMethod() public static méthode

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.
Résultat Mono.Cecil.MethodReference

GetOperand() public static méthode

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.
Résultat object

GetOperandType() public static méthode

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.
Résultat Mono.Cecil.TypeReference

GetParameter() public static méthode

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.
Résultat Mono.Cecil.ParameterDefinition

GetPopCount() public static méthode

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).
Résultat int

GetPushCount() public static méthode

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.
Résultat int

GetVariable() public static méthode

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.
Résultat Mono.Cecil.Cil.VariableDefinition

Is() public static méthode

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.
Résultat bool

IsLoadArgument() public static méthode

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.
Résultat bool

IsLoadElement() public static méthode

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.
Résultat bool

IsLoadIndirect() public static méthode

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.
Résultat bool

IsLoadLocal() public static méthode

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.
Résultat bool

IsOperandZero() public static méthode

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.
Résultat bool

IsStoreArgument() public static méthode

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.
Résultat bool

IsStoreLocal() public static méthode

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.
Résultat bool

TraceBack() public static méthode

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.
Résultat Mono.Cecil.Cil.Instruction

TraceBack() public static méthode

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.
Résultat Mono.Cecil.Cil.Instruction