Add the ability to create Instructions without the appropriate operand type #932

Open
opened 2024-02-04 14:26:58 -06:00 by slxdy · 1 comment
slxdy commented 2024-02-04 14:26:58 -06:00 (Migrated from github.com)

Because this isn't currently possible, cloning instructions or pre-making instructions before assigning their operator is hell.
It's an unnecessary limitation that simply shouldn't exist.

Because this isn't currently possible, cloning instructions or pre-making instructions before assigning their operator is hell. It's an unnecessary limitation that simply shouldn't exist.
slxdy commented 2024-02-04 14:45:03 -06:00 (Migrated from github.com)

My current workaround (not really safe):

public static Instruction CreateInstructionRaw(OpCode opCode, object? operand = null)
{
    var instruction = (Instruction)RuntimeHelpers.GetUninitializedObject(typeof(Instruction));
    instruction.OpCode = opCode;
    instruction.Operand = operand;
    return instruction;
}
My current workaround (not really safe): ```cs public static Instruction CreateInstructionRaw(OpCode opCode, object? operand = null) { var instruction = (Instruction)RuntimeHelpers.GetUninitializedObject(typeof(Instruction)); instruction.OpCode = opCode; instruction.Operand = operand; return instruction; } ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil#932
No description provided.