Welcome to mirror list, hosted at ThFree Co, Russian Federation.

InstrToken.cs « scanner « ilasm « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: edd6db37398d6b56afa7d9a3d181142b0605c9c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// InstrToken.cs
// Author: Sergey Chaban (serge@wildwestsoftware.com)

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;

				case OperandType.InlinePhi:
					token = Token.INSTR_PHI;
					break;

				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;
		}


	}

}