Class CodeInstruction
An abstract wrapper around OpCode and their operands. Used by transpilers
Inheritance
Inherited Members
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public class CodeInstruction
Constructors
| Improve this Doc View SourceCodeInstruction(CodeInstruction)
Create a full copy (including labels and exception blocks) of a CodeInstruction
Declaration
public CodeInstruction(CodeInstruction instruction)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeInstruction | instruction | The CodeInstruction to copy |
CodeInstruction(OpCode, Object)
Creates a new CodeInstruction with a given opcode and optional operand
Declaration
public CodeInstruction(OpCode opcode, object operand = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.Emit.OpCode | opcode | The opcode |
| System.Object | operand | The operand |
Fields
| Improve this Doc View Sourceblocks
All exception block boundaries defined on this instruction
Declaration
public List<ExceptionBlock> blocks
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<ExceptionBlock> |
labels
All labels defined on this instruction
Declaration
public List<Label> labels
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Reflection.Emit.Label> |
opcode
The opcode
Declaration
public OpCode opcode
Field Value
| Type | Description |
|---|---|
| System.Reflection.Emit.OpCode |
operand
The operand
Declaration
public object operand
Field Value
| Type | Description |
|---|---|
| System.Object |
Methods
| Improve this Doc View SourceCall(Expression<Action>)
Creates a CodeInstruction calling a method (CALL)
Declaration
public static CodeInstruction Call(Expression<Action> expression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<System.Action> | expression | The lambda expression using the method |
Returns
| Type | Description |
|---|---|
| CodeInstruction |
Call(LambdaExpression)
Creates a CodeInstruction calling a method (CALL)
Declaration
public static CodeInstruction Call(LambdaExpression expression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.LambdaExpression | expression | The lambda expression using the method |
Returns
| Type | Description |
|---|---|
| CodeInstruction |
Call(String, Type[], Type[])
Creates a CodeInstruction calling a method (CALL)
Declaration
public static CodeInstruction Call(string typeColonMethodname, Type[] parameters = null, Type[] generics = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeColonMethodname | The full name like |
| 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 |
Returns
| Type | Description |
|---|---|
| CodeInstruction | A code instruction that calls the method matching the arguments |
Call(Type, String, Type[], Type[])
Creates a CodeInstruction calling a method (CALL)
Declaration
public static CodeInstruction Call(Type type, string name, Type[] parameters = null, Type[] generics = null)
Parameters
| 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 |
Returns
| Type | Description |
|---|---|
| CodeInstruction | A code instruction that calls the method matching the arguments |
Call<T>(Expression<Action<T>>)
Creates a CodeInstruction calling a method (CALL)
Declaration
public static CodeInstruction Call<T>(Expression<Action<T>> expression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<System.Action<T>> | expression | The lambda expression using the method |
Returns
| Type | Description |
|---|---|
| CodeInstruction |
Type Parameters
| Name | Description |
|---|---|
| T |
Call<T, TResult>(Expression<Func<T, TResult>>)
Creates a CodeInstruction calling a method (CALL)
Declaration
public static CodeInstruction Call<T, TResult>(Expression<Func<T, TResult>> expression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<System.Func<T, TResult>> | expression | The lambda expression using the method |
Returns
| Type | Description |
|---|---|
| CodeInstruction |
Type Parameters
| Name | Description |
|---|---|
| T | |
| TResult |
Clone()
Clones a CodeInstruction and resets its labels and exception blocks
Declaration
public CodeInstruction Clone()
Returns
| Type | Description |
|---|---|
| CodeInstruction | A lightweight copy of this code instruction |
Clone(Object)
Clones a CodeInstruction, resets labels and exception blocks and sets its operand
Declaration
public CodeInstruction Clone(object operand)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | operand | The operand |
Returns
| Type | Description |
|---|---|
| CodeInstruction | A copy of this CodeInstruction with a new operand |
Clone(OpCode)
Clones a CodeInstruction, resets labels and exception blocks and sets its opcode
Declaration
public CodeInstruction Clone(OpCode opcode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.Emit.OpCode | opcode | The opcode |
Returns
| Type | Description |
|---|---|
| CodeInstruction | A copy of this CodeInstruction with a new opcode |
LoadField(Type, String, Boolean)
Creates a CodeInstruction loading a field (LD[S]FLD[A])
Declaration
public static CodeInstruction LoadField(Type type, string name, bool useAddress = false)
Parameters
| 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 |
Returns
| Type | Description |
|---|---|
| CodeInstruction |
StoreField(Type, String)
Creates a CodeInstruction storing to a field (ST[S]FLD)
Declaration
public static CodeInstruction StoreField(Type type, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | The class/type where the field is defined |
| System.String | name | The name of the field (case sensitive) |
Returns
| Type | Description |
|---|---|
| CodeInstruction |
ToString()
Returns a string representation of the code instruction
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string representation of the code instruction |