예제 #1
0
 public static CilInstruction Create(CilOpCode code, IEnumerable <CilInstruction> operand)
 {
     if (code.OperandType != CilOperandType.InlineSwitch)
     {
         throw new ArgumentException("Opcode does not accept a collection of instructions as operand.", "code");
     }
     return(new CilInstruction(0, code, new List <CilInstruction>(operand)));
 }
예제 #2
0
 /// <summary>
 /// Writes the operation code to the output stream.
 /// </summary>
 /// <param name="opCode">The opcode to write.</param>
 private void WriteOpCode(CilOpCode opCode)
 {
     if (opCode.Size == 2)
     {
         _writer.WriteByte(opCode.Op1);
     }
     _writer.WriteByte(opCode.Op2);
 }
예제 #3
0
 public static CilInstruction Create(CilOpCode code, float operand)
 {
     if (code.OperandType != CilOperandType.ShortInlineR)
     {
         throw new ArgumentException("Opcode does not accept a float32 operand.", "code");
     }
     return(new CilInstruction(0, code, operand));
 }
예제 #4
0
 public static CilInstruction Create(CilOpCode code, string operand)
 {
     if (code.OperandType != CilOperandType.InlineString)
     {
         throw new ArgumentException("Opcode does not accept a string operand.", "code");
     }
     return(new CilInstruction(0, code, operand));
 }
예제 #5
0
 public static CilInstruction Create(CilOpCode code, CilInstruction instruction)
 {
     if (code.OperandType != CilOperandType.ShortInlineBrTarget && code.OperandType != CilOperandType.InlineBrTarget)
     {
         throw new ArgumentException("Opcode does not accept an instruction operand.", "code");
     }
     return(new CilInstruction(0, code, instruction));
 }
예제 #6
0
 public static CilInstruction Create(CilOpCode code)
 {
     if (code.OperandType != CilOperandType.InlineNone)
     {
         throw new ArgumentException("Opcode requires an operand.", "code");
     }
     return(new CilInstruction(0, code, null));
 }
예제 #7
0
 public static CilInstruction Create(CilOpCode code, ParameterSignature operand)
 {
     if (code.OperandType != CilOperandType.InlineArgument && code.OperandType != CilOperandType.ShortInlineArgument)
     {
         throw new ArgumentException("Opcode does not accept a parameter operand.", "code");
     }
     return(new CilInstruction(0, code, operand));
 }
예제 #8
0
 public static CilInstruction Create(CilOpCode code, VariableSignature operand)
 {
     if (code.OperandType != CilOperandType.InlineVar && code.OperandType != CilOperandType.ShortInlineVar)
     {
         throw new ArgumentException("Opcode does not accept a local variable operand.", "code");
     }
     return(new CilInstruction(0, code, operand));
 }
예제 #9
0
 public static CilInstruction Create(CilOpCode code, IMemberReference operand)
 {
     switch (code.OperandType)
     {
     case CilOperandType.InlineField:
     case CilOperandType.InlineMethod:
     case CilOperandType.InlineTok:
     case CilOperandType.InlineType:
         return(new CilInstruction(0, code, operand));
     }
     throw new ArgumentException("Opcode does not accept a member operand operand.", "code");
 }
예제 #10
0
 public CilInstruction(int offset, CilOpCode opCode, object operand)
 {
     Offset  = offset;
     OpCode  = opCode;
     Operand = operand;
 }
예제 #11
0
 public virtual string FormatOpCode(CilOpCode opcode)
 {
     return(opcode.Name.ToLowerInvariant());
 }