Class CodeInstruction
- Namespace
- Concord
- Assembly
- Concord.Emit.dll
One IL instruction in an author-facing transpiler stream. Member names are lowercase to match Harmony so migrating transpiler bodies compile unchanged; do not rename them to house style.
public sealed class CodeInstruction
- Inheritance
-
CodeInstruction
- Inherited Members
Constructors
CodeInstruction(CodeInstruction)
Creates a copy of another instruction, including its labels and blocks.
public CodeInstruction(CodeInstruction other)
Parameters
otherCodeInstructionThe instruction to copy.
CodeInstruction(OpCode, object?)
Creates an instruction.
public CodeInstruction(OpCode opcode, object? operand = null)
Parameters
Properties
blocks
The exception-handling boundaries that open or close at this instruction.
public List<ExceptionBlock> blocks { get; }
Property Value
labels
The labels attached to this instruction as a branch target.
public List<Label> labels { get; }
Property Value
opcode
The opcode.
public OpCode opcode { get; set; }
Property Value
operand
The operand, or null when the opcode takes none.
public object? operand { get; set; }
Property Value
Methods
Calls(MethodInfo)
Tests whether this instruction calls the given method.
public bool Calls(MethodInfo method)
Parameters
methodMethodInfoThe method to match.
Returns
Remarks
Matches both Call and Callvirt, as Harmony does, so a migrated transpiler body selects the same call sites it selected before.
Exceptions
- ArgumentNullException
Thrown when
methodis null.
Is(OpCode, object?)
Tests whether this instruction has the given opcode and operand.
public bool Is(OpCode match, object? matchOperand)
Parameters
matchOpCodeThe opcode to match.
matchOperandobjectThe operand to match, or null to match any operand.
Returns
Remarks
Numeric operands compare by value across box types, so matching 4 finds an operand
boxed as byte, int, or long alike. Short-form
opcodes carry a byte operand, and requiring authors to know that is a silent
-false trap. Integral and floating-point operands never cross-match.
IsLdarg(int?)
Tests whether this instruction loads an argument, optionally a specific slot.
public bool IsLdarg(int? n = null)
Parameters
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
WithLabels(params Label[])
Attaches branch-target labels to this instruction.
public CodeInstruction WithLabels(params Label[] add)
Parameters
addLabel[]The labels to attach.
Returns
- CodeInstruction
This instruction, so the call can be chained onto a constructor.
WithLabels(IEnumerable<Label>)
Attaches branch-target labels to this instruction.
public CodeInstruction WithLabels(IEnumerable<Label> add)
Parameters
addIEnumerable<Label>The labels to attach.
Returns
- CodeInstruction
This instruction, so the call can be chained onto a constructor.