Xamarin Public Jenkins (auto-signing) 6bdd276d05 Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
2017-04-10 11:41:01 +00:00

111 lines
2.0 KiB
C#

// InstrToken.cs
// Author: Sergey Chaban (serge@wildwestsoftware.com)
#if !MOBILE
using System;
using System.Reflection.Emit;
namespace Mono.ILASM {
public class InstrToken : ILToken {
/// <summary>
/// </summary>
public InstrToken (OpCode opcode)
{
this.val = opcode;
token = GetInstrType (opcode);
}
/// <summary>
/// </summary>
/// <param name="opcode"></param>
/// <returns></returns>
public static int GetInstrType (OpCode opcode)
{
OperandType t = opcode.OperandType;
int token = Token.UNKNOWN;
switch (t) {
case OperandType.InlineBrTarget:
case OperandType.ShortInlineBrTarget:
token = Token.INSTR_BRTARGET;
break;
case OperandType.InlineField:
token = Token.INSTR_FIELD;
break;
case OperandType.InlineI:
case OperandType.ShortInlineI:
token = Token.INSTR_I;
break;
case OperandType.InlineI8:
token = Token.INSTR_I8;
break;
case OperandType.InlineMethod:
token = Token.INSTR_METHOD;
break;
case OperandType.InlineNone:
token = Token.INSTR_NONE;
break;
#pragma warning disable 618
case OperandType.InlinePhi:
token = Token.INSTR_PHI;
break;
#pragma warning restore 618
case OperandType.InlineR:
case OperandType.ShortInlineR:
token = Token.INSTR_R;
break;
/*
case OperandType.InlineRVA:
token = Token.INSTR_RVA;
break;
*/
case OperandType.InlineSig:
token = Token.INSTR_SIG;
break;
case OperandType.InlineString:
token = Token.INSTR_STRING;
break;
case OperandType.InlineSwitch:
token = Token.INSTR_SWITCH;
break;
case OperandType.InlineTok:
token = Token.INSTR_TOK;
break;
case OperandType.InlineType:
token = Token.INSTR_TYPE;
break;
case OperandType.InlineVar:
case OperandType.ShortInlineVar:
token = Token.INSTR_VAR;
break;
}
return token;
}
}
}
#endif