Show / Hide Table of Contents

Class CodeMatch

A CodeInstruction match

Inheritance
System.Object
CodeInstruction
CodeMatch
Inherited Members
CodeInstruction.opcode
CodeInstruction.operand
CodeInstruction.labels
CodeInstruction.blocks
CodeInstruction.Clone()
CodeInstruction.Clone(OpCode)
CodeInstruction.Clone(Object)
CodeInstruction.Call(Type, String, Type[], Type[])
CodeInstruction.Call(String, Type[], Type[])
CodeInstruction.Call(Expression<Action>)
CodeInstruction.Call<T>(Expression<Action<T>>)
CodeInstruction.Call<T, TResult>(Expression<Func<T, TResult>>)
CodeInstruction.Call(LambdaExpression)
CodeInstruction.CallClosure<T>(T)
CodeInstruction.LoadField(Type, String, Boolean)
CodeInstruction.StoreField(Type, String)
CodeInstruction.LoadLocal(Int32, Boolean)
CodeInstruction.StoreLocal(Int32)
CodeInstruction.LoadArgument(Int32, Boolean)
CodeInstruction.StoreArgument(Int32)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public class CodeMatch : CodeInstruction

Constructors

| Improve this Doc View Source

CodeMatch(CodeInstruction, String)

Creates a code match

Declaration
public CodeMatch(CodeInstruction instruction, string name = null)
Parameters
Type Name Description
CodeInstruction instruction

The CodeInstruction

System.String name

An optional name

| Improve this Doc View Source

CodeMatch(Func<CodeInstruction, Boolean>, String)

Creates a code match

Declaration
public CodeMatch(Func<CodeInstruction, bool> predicate, string name = null)
Parameters
Type Name Description
System.Func<CodeInstruction, System.Boolean> predicate

The predicate

System.String name

An optional name

| Improve this Doc View Source

CodeMatch(Expression<Action>, String)

Creates a code match that calls a method

Declaration
public CodeMatch(Expression<Action> expression, string name = null)
Parameters
Type Name Description
System.Linq.Expressions.Expression<System.Action> expression

The lambda expression using the method

System.String name

The optional name

| Improve this Doc View Source

CodeMatch(LambdaExpression, String)

Creates a code match that calls a method

Declaration
public CodeMatch(LambdaExpression expression, string name = null)
Parameters
Type Name Description
System.Linq.Expressions.LambdaExpression expression

The lambda expression using the method

System.String name

The optional name

| Improve this Doc View Source

CodeMatch(Nullable<OpCode>, Object, String)

Creates a code match

Declaration
public CodeMatch(OpCode? opcode = null, object operand = null, string name = null)
Parameters
Type Name Description
System.Nullable<System.Reflection.Emit.OpCode> opcode

The optional opcode

System.Object operand

The optional operand

System.String name

The optional name

Fields

| Improve this Doc View Source

jumpsFrom

The jumps from the match

Declaration
public List<int> jumpsFrom
Field Value
Type Description
System.Collections.Generic.List<System.Int32>
| Improve this Doc View Source

jumpsTo

The jumps to the match

Declaration
public List<int> jumpsTo
Field Value
Type Description
System.Collections.Generic.List<System.Int32>
| Improve this Doc View Source

name

The name of the match

Declaration
public string name
Field Value
Type Description
System.String
| Improve this Doc View Source

opcodeSet

The matched opcodes

Declaration
public HashSet<OpCode> opcodeSet
Field Value
Type Description
System.Collections.Generic.HashSet<System.Reflection.Emit.OpCode>
| Improve this Doc View Source

operands

The matched operands

Declaration
public List<object> operands
Field Value
Type Description
System.Collections.Generic.List<System.Object>
| Improve this Doc View Source

predicate

The match predicate

Declaration
public Func<CodeInstruction, bool> predicate
Field Value
Type Description
System.Func<CodeInstruction, System.Boolean>

Properties

| Improve this Doc View Source

opcodes

The matched opcodes

Declaration
[Obsolete("Use opcodeSet instead")]
public List<OpCode> opcodes { get; set; }
Property Value
Type Description
System.Collections.Generic.List<System.Reflection.Emit.OpCode>

Methods

| Improve this Doc View Source

Branches(String)

Creates a code match for branching

Declaration
public static CodeMatch Branches(string name = null)
Parameters
Type Name Description
System.String name

An optional name

Returns
Type Description
CodeMatch
| Improve this Doc View Source

LoadsArgument(Boolean, String)

Creates a code match for argument loads

Declaration
public static CodeMatch LoadsArgument(bool useAddress = false, string name = null)
Parameters
Type Name Description
System.Boolean useAddress

Whether to match for address loads

System.String name

An optional name

Returns
Type Description
CodeMatch
| Improve this Doc View Source

LoadsLocal(Boolean, String)

Creates a code match for local loads

Declaration
public static CodeMatch LoadsLocal(bool useAddress = false, string name = null)
Parameters
Type Name Description
System.Boolean useAddress

Whether to match for address loads

System.String name

An optional name

Returns
Type Description
CodeMatch
| Improve this Doc View Source

StoresArgument(String)

Creates a code match for argument stores

Declaration
public static CodeMatch StoresArgument(string name = null)
Parameters
Type Name Description
System.String name

An optional name

Returns
Type Description
CodeMatch
| Improve this Doc View Source

StoresLocal(String)

Creates a code match for local stores

Declaration
public static CodeMatch StoresLocal(string name = null)
Parameters
Type Name Description
System.String name

An optional name

Returns
Type Description
CodeMatch
| Improve this Doc View Source

ToString()

Returns a string that represents the match

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation

Overrides
CodeInstruction.ToString()
| Improve this Doc View Source

WithOpcodes(HashSet<OpCode>, Object, String)

Creates a code match

Declaration
public static CodeMatch WithOpcodes(HashSet<OpCode> opcodes, object operand = null, string name = null)
Parameters
Type Name Description
System.Collections.Generic.HashSet<System.Reflection.Emit.OpCode> opcodes

The opcodes

System.Object operand

The optional operand

System.String name

The optional name

Returns
Type Description
CodeMatch

Extension Methods

CodeInstructionExtensions.OperandIs(CodeInstruction, Object)
CodeInstructionExtensions.Is(CodeInstruction, OpCode, Object)
CodeInstructionExtensions.IsLdarg(CodeInstruction, Nullable<Int32>)
CodeInstructionExtensions.IsLdarga(CodeInstruction, Nullable<Int32>)
CodeInstructionExtensions.IsStarg(CodeInstruction, Nullable<Int32>)
CodeInstructionExtensions.IsLdloc(CodeInstruction, LocalBuilder)
CodeInstructionExtensions.IsStloc(CodeInstruction, LocalBuilder)
CodeInstructionExtensions.Branches(CodeInstruction, out Nullable<Label>)
CodeInstructionExtensions.Calls(CodeInstruction, MethodInfo)
CodeInstructionExtensions.LoadsConstant(CodeInstruction)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, Int64)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, Double)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, Enum)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, String)
CodeInstructionExtensions.LoadsField(CodeInstruction, FieldInfo, Boolean)
CodeInstructionExtensions.StoresField(CodeInstruction, FieldInfo)
CodeInstructionExtensions.LocalIndex(CodeInstruction)
CodeInstructionExtensions.ArgumentIndex(CodeInstruction)
CodeInstructionExtensions.WithLabels(CodeInstruction, Label[])
CodeInstructionExtensions.WithLabels(CodeInstruction, IEnumerable<Label>)
CodeInstructionExtensions.ExtractLabels(CodeInstruction)
CodeInstructionExtensions.MoveLabelsTo(CodeInstruction, CodeInstruction)
CodeInstructionExtensions.MoveLabelsFrom(CodeInstruction, CodeInstruction)
CodeInstructionExtensions.WithBlocks(CodeInstruction, ExceptionBlock[])
CodeInstructionExtensions.WithBlocks(CodeInstruction, IEnumerable<ExceptionBlock>)
CodeInstructionExtensions.ExtractBlocks(CodeInstruction)
CodeInstructionExtensions.MoveBlocksTo(CodeInstruction, CodeInstruction)
CodeInstructionExtensions.MoveBlocksFrom(CodeInstruction, CodeInstruction)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX