Class CodeInstructionExtensions
Extensions for CodeInstruction
Inheritance
Inherited Members
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public static class CodeInstructionExtensions
Methods
| Improve this Doc View SourceBranches(CodeInstruction, out Nullable<Label>)
Tests if the code instruction branches
Declaration
public static bool Branches(this CodeInstruction code, out Label? label)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Nullable<System.Reflection.Emit.Label> | label | The label if the instruction is a branch operation or null if not |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction branches |
Calls(CodeInstruction, MethodInfo)
Tests if the code instruction calls the method/constructor
Declaration
public static bool Calls(this CodeInstruction code, MethodInfo method)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Reflection.MethodInfo | method | The method |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction calls the method or constructor |
IsLdarg(CodeInstruction, Nullable<Int32>)
Tests for any form of Ldarg*
Declaration
public static bool IsLdarg(this CodeInstruction code, int? n = default(int? ))
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Nullable<System.Int32> | n | The (optional) index |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it matches one of the variations |
IsLdarga(CodeInstruction, Nullable<Int32>)
Tests for Ldarga/Ldarga_S
Declaration
public static bool IsLdarga(this CodeInstruction code, int? n = default(int? ))
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Nullable<System.Int32> | n | The (optional) index |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it matches one of the variations |
IsLdloc(CodeInstruction, LocalBuilder)
Tests for any form of Ldloc*
Declaration
public static bool IsLdloc(this CodeInstruction code, LocalBuilder variable = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Reflection.Emit.LocalBuilder | variable | The optional local variable |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it matches one of the variations |
IsStarg(CodeInstruction, Nullable<Int32>)
Tests for Starg/Starg_S
Declaration
public static bool IsStarg(this CodeInstruction code, int? n = default(int? ))
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Nullable<System.Int32> | n | The (optional) index |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it matches one of the variations |
IsStloc(CodeInstruction, LocalBuilder)
Tests for any form of Stloc*
Declaration
public static bool IsStloc(this CodeInstruction code, LocalBuilder variable = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Reflection.Emit.LocalBuilder | variable | The optional local variable |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if it matches one of the variations |
LoadsConstant(CodeInstruction)
Tests if the code instruction loads a constant
Declaration
public static bool LoadsConstant(this CodeInstruction code)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction loads a constant |
LoadsConstant(CodeInstruction, Double)
Tests if the code instruction loads a floating point constant
Declaration
public static bool LoadsConstant(this CodeInstruction code, double number)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Double | number | The floating point constant |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction loads the constant |
LoadsConstant(CodeInstruction, Enum)
Tests if the code instruction loads an enum constant
Declaration
public static bool LoadsConstant(this CodeInstruction code, Enum e)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Enum | e | The enum |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction loads the constant |
LoadsConstant(CodeInstruction, Int64)
Tests if the code instruction loads an integer constant
Declaration
public static bool LoadsConstant(this CodeInstruction code, long number)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Int64 | number | The integer constant |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction loads the constant |
LoadsField(CodeInstruction, FieldInfo, Boolean)
Tests if the code instruction loads a field
Declaration
public static bool LoadsField(this CodeInstruction code, FieldInfo field, bool byAddress = false)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Reflection.FieldInfo | field | The field |
| System.Boolean | byAddress | Set to true if the address of the field is loaded |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction loads the field |
OperandIs(CodeInstruction, Object)
Shortcut for testing if the operand is equal to a non-null typed value
Declaration
public static bool OperandIs(this CodeInstruction code, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Object | value | The value |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the operand has the same type and is equal to the value |
StoresField(CodeInstruction, FieldInfo)
Tests if the code instruction stores a field
Declaration
public static bool StoresField(this CodeInstruction code, FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | code | The CodeInstruction |
| System.Reflection.FieldInfo | field | The field |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the instruction stores this field |