2 // Author: Sergey Chaban (serge@wildwestsoftware.com)
7 using System
.Reflection
.Emit
;
11 public class InstrToken
: ILToken
{
16 public InstrToken (OpCode opcode
)
19 token
= GetInstrType (opcode
);
25 /// <param name="opcode"></param>
26 /// <returns></returns>
27 public static int GetInstrType (OpCode opcode
)
29 OperandType t
= opcode
.OperandType
;
30 int token
= Token
.UNKNOWN
;
34 case OperandType
.InlineBrTarget
:
35 case OperandType
.ShortInlineBrTarget
:
36 token
= Token
.INSTR_BRTARGET
;
39 case OperandType
.InlineField
:
40 token
= Token
.INSTR_FIELD
;
43 case OperandType
.InlineI
:
44 case OperandType
.ShortInlineI
:
45 token
= Token
.INSTR_I
;
48 case OperandType
.InlineI8
:
49 token
= Token
.INSTR_I8
;
52 case OperandType
.InlineMethod
:
53 token
= Token
.INSTR_METHOD
;
56 case OperandType
.InlineNone
:
57 token
= Token
.INSTR_NONE
;
59 #pragma warning disable 618
60 case OperandType
.InlinePhi
:
61 token
= Token
.INSTR_PHI
;
63 #pragma warning restore 618
65 case OperandType
.InlineR
:
66 case OperandType
.ShortInlineR
:
67 token
= Token
.INSTR_R
;
71 case OperandType.InlineRVA:
72 token = Token.INSTR_RVA;
76 case OperandType
.InlineSig
:
77 token
= Token
.INSTR_SIG
;
80 case OperandType
.InlineString
:
81 token
= Token
.INSTR_STRING
;
84 case OperandType
.InlineSwitch
:
85 token
= Token
.INSTR_SWITCH
;
88 case OperandType
.InlineTok
:
89 token
= Token
.INSTR_TOK
;
92 case OperandType
.InlineType
:
93 token
= Token
.INSTR_TYPE
;
96 case OperandType
.InlineVar
:
97 case OperandType
.ShortInlineVar
:
98 token
= Token
.INSTR_VAR
;