docs/api/HarmonyLib.CodeInstruction.html
An abstract wrapper around OpCode and their operands. Used by transpilers
System.Object
CodeInstruction
public class CodeInstruction
Create a full copy (including labels and exception blocks) of a CodeInstruction
public CodeInstruction(CodeInstruction instruction)
| Type | Name | Description |
|---|---|---|
| CodeInstruction | instruction |
The CodeInstruction to copy
|
Creates a new CodeInstruction with a given opcode and optional operand
public CodeInstruction(OpCode opcode, object operand = null)
| Type | Name | Description |
|---|---|---|
| System.Reflection.Emit.OpCode | opcode |
The opcode
| | System.Object | operand |
The operand
|
All exception block boundaries defined on this instruction
public List<ExceptionBlock> blocks
| Type | Description |
|---|---|
| System.Collections.Generic.List<ExceptionBlock> |
All labels defined on this instruction
public List<Label> labels
| Type | Description |
|---|---|
| System.Collections.Generic.List\ |
The opcode
public OpCode opcode
| Type | Description |
|---|---|
| System.Reflection.Emit.OpCode |
The operand
public object operand
| Type | Description |
|---|---|
| System.Object |
Creates a CodeInstruction calling a method (CALL)
public static CodeInstruction Call(Expression<Action> expression)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression\ | expression |
The lambda expression using the method
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
Creates a CodeInstruction calling a method (CALL)
public static CodeInstruction Call(LambdaExpression expression)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.LambdaExpression | expression |
The lambda expression using the method
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
Creates a CodeInstruction calling a method (CALL)
public static CodeInstruction Call(string typeColonMethodname, Type[] parameters = null, Type[] generics = null)
| Type | Name | Description |
|---|---|---|
| System.String | typeColonMethodname |
The target method in the form TypeFullName:MethodName, where the type name matches a form recognized by Type.GetType like Some.Namespace.Type.
| | System.Type[] | parameters |
Optional parameters to target a specific overload of the method
| | System.Type[] | generics |
Optional list of types that define the generic version of the method
|
| Type | Description |
|---|---|
| CodeInstruction |
A code instruction that calls the method matching the arguments
|
Creates a CodeInstruction calling a method (CALL)
public static CodeInstruction Call(Type type, string name, Type[] parameters = null, Type[] generics = null)
| Type | Name | Description |
|---|---|---|
| System.Type | type |
The class/type where the method is declared
| | System.String | name |
The name of the method (case sensitive)
| | System.Type[] | parameters |
Optional parameters to target a specific overload of the method
| | System.Type[] | generics |
Optional list of types that define the generic version of the method
|
| Type | Description |
|---|---|
| CodeInstruction |
A code instruction that calls the method matching the arguments
|
Creates a CodeInstruction calling a method (CALL)
public static CodeInstruction Call<T>(Expression<Action<T>> expression)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression\> | expression |
The lambda expression using the method
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
| Name | Description |
|---|---|
| T |
Creates a CodeInstruction calling a method (CALL)
public static CodeInstruction Call<T, TResult>(Expression<Func<T, TResult>> expression)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression\> | expression |
The lambda expression using the method
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
| Name | Description |
|---|---|
| T | |
| TResult |
Returns an instruction to call the specified closure
public static CodeInstruction CallClosure<T>(T closure)
where T : Delegate
| Type | Name | Description |
|---|---|---|
| T | closure |
The closure that defines the method to call
|
| Type | Description |
|---|---|
| CodeInstruction |
A CodeInstruction that calls the closure as a method
|
| Name | Description |
|---|---|
| T |
The delegate type to emit
|
Clones a CodeInstruction and resets its labels and exception blocks
public CodeInstruction Clone()
| Type | Description |
|---|---|
| CodeInstruction |
A lightweight copy of this code instruction
|
Clones a CodeInstruction, resets labels and exception blocks and sets its operand
public CodeInstruction Clone(object operand)
| Type | Name | Description |
|---|---|---|
| System.Object | operand |
The operand
|
| Type | Description |
|---|---|
| CodeInstruction |
A copy of this CodeInstruction with a new operand
|
Clones a CodeInstruction, resets labels and exception blocks and sets its opcode
public CodeInstruction Clone(OpCode opcode)
| Type | Name | Description |
|---|---|---|
| System.Reflection.Emit.OpCode | opcode |
The opcode
|
| Type | Description |
|---|---|
| CodeInstruction |
A copy of this CodeInstruction with a new opcode
|
Checks if a CodeInstruction contains a given exception block type
public bool HasBlock(ExceptionBlockType type)
| Type | Name | Description |
|---|---|---|
| ExceptionBlockType | type |
Type of the exception block to check for
|
| Type | Description |
|---|---|
| System.Boolean |
True if the instruction contains the exception block type, false otherwise
|
Creates a CodeInstruction loading an argument with the given index, using the shorter forms when possible
public static CodeInstruction LoadArgument(int index, bool useAddress = false)
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
The index of the argument
| | System.Boolean | useAddress |
Use address of argument
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
ArgumentIndex(CodeInstruction)
Creates a CodeInstruction loading a field (LD[S]FLD[A])
public static CodeInstruction LoadField(Type type, string name, bool useAddress = false)
| Type | Name | Description |
|---|---|---|
| System.Type | type |
The class/type where the field is defined
| | System.String | name |
The name of the field (case sensitive)
| | System.Boolean | useAddress |
Use address of field
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
Creates a CodeInstruction loading a local with the given index, using the shorter forms when possible
public static CodeInstruction LoadLocal(int index, bool useAddress = false)
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
The index where the local is stored
| | System.Boolean | useAddress |
Use address of local
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
Creates a CodeInstruction storing to an argument with the given index, using the shorter forms when possible
public static CodeInstruction StoreArgument(int index)
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
The index of the argument
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
ArgumentIndex(CodeInstruction)
Creates a CodeInstruction storing to a field (ST[S]FLD)
public static CodeInstruction StoreField(Type type, string name)
| Type | Name | Description |
|---|---|---|
| System.Type | type |
The class/type where the field is defined
| | System.String | name |
The name of the field (case sensitive)
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
Creates a CodeInstruction storing to a local with the given index, using the shorter forms when possible
public static CodeInstruction StoreLocal(int index)
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
The index where the local is stored
|
| Type | Description |
|---|---|
| CodeInstruction |
A new Codeinstruction
|
Returns a string representation of the code instruction
public override string ToString()
| Type | Description |
|---|---|
| System.String |
A string representation of the code instruction
|
System.Object.ToString()
CodeInstructionExtensions.OperandIs(CodeInstruction, Object)
CodeInstructionExtensions.OperandIs(CodeInstruction, MemberInfo)
CodeInstructionExtensions.Is(CodeInstruction, OpCode, Object)
CodeInstructionExtensions.Is(CodeInstruction, OpCode, MemberInfo)
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)