**** Merged from MCS ****
[mono-project.git] / mcs / ilasm / scanner / InstrToken.cs
blobedd6db37398d6b56afa7d9a3d181142b0605c9c8
1 // InstrToken.cs
2 // Author: Sergey Chaban (serge@wildwestsoftware.com)
4 using System;
5 using System.Reflection.Emit;
7 namespace Mono.ILASM {
9 public class InstrToken : ILToken {
12 /// <summary>
13 /// </summary>
14 public InstrToken (OpCode opcode)
16 this.val = opcode;
17 token = GetInstrType (opcode);
21 /// <summary>
22 /// </summary>
23 /// <param name="opcode"></param>
24 /// <returns></returns>
25 public static int GetInstrType (OpCode opcode)
27 OperandType t = opcode.OperandType;
28 int token = Token.UNKNOWN;
30 switch (t) {
32 case OperandType.InlineBrTarget:
33 case OperandType.ShortInlineBrTarget:
34 token = Token.INSTR_BRTARGET;
35 break;
37 case OperandType.InlineField:
38 token = Token.INSTR_FIELD;
39 break;
41 case OperandType.InlineI:
42 case OperandType.ShortInlineI:
43 token = Token.INSTR_I;
44 break;
46 case OperandType.InlineI8:
47 token = Token.INSTR_I8;
48 break;
50 case OperandType.InlineMethod:
51 token = Token.INSTR_METHOD;
52 break;
54 case OperandType.InlineNone:
55 token = Token.INSTR_NONE;
56 break;
58 case OperandType.InlinePhi:
59 token = Token.INSTR_PHI;
60 break;
62 case OperandType.InlineR:
63 case OperandType.ShortInlineR:
64 token = Token.INSTR_R;
65 break;
68 case OperandType.InlineRVA:
69 token = Token.INSTR_RVA;
70 break;
73 case OperandType.InlineSig:
74 token = Token.INSTR_SIG;
75 break;
77 case OperandType.InlineString:
78 token = Token.INSTR_STRING;
79 break;
81 case OperandType.InlineSwitch:
82 token = Token.INSTR_SWITCH;
83 break;
85 case OperandType.InlineTok:
86 token = Token.INSTR_TOK;
87 break;
89 case OperandType.InlineType:
90 token = Token.INSTR_TYPE;
91 break;
93 case OperandType.InlineVar:
94 case OperandType.ShortInlineVar:
95 token = Token.INSTR_VAR;
96 break;
99 return token;