2003-05-19 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / System.Reflection.Emit / OpCode.cs
1 //
2 // System.Reflection.Emit.OpCode
3 //
4 // Author:
5 //   Sergey Chaban (serge@wildwestsoftware.com)
6 //
7
8 using System;
9 using System.Reflection;
10 using System.Reflection.Emit;
11
12
13 namespace System.Reflection.Emit {
14
15         public struct OpCode {
16
17                 internal string name;
18                 internal int size;
19                 internal OpCodeType type;
20                 internal OperandType operandType;
21                 internal StackBehaviour pop;
22                 internal StackBehaviour push;
23                 internal FlowControl flowCtrl;
24                 internal byte op1;
25                 internal byte op2;
26
27                 internal OpCode (string name, int size,
28                                  OpCodeType opcodeType,
29                                  OperandType operandType,
30                                  StackBehaviour pop,
31                                  StackBehaviour push,
32                                  FlowControl flowCtrl,
33                                  byte op1, byte op2)
34                 {
35                         this.name = name;
36                         this.size = size;
37                         this.type = opcodeType;
38                         this.operandType = operandType;
39                         this.pop = pop;
40                         this.push = push;
41                         this.flowCtrl = flowCtrl;
42                         this.op1 = op1;
43                         this.op2 = op2;
44                 }
45
46
47
48                 /// <summary>
49                 /// </summary>
50                 public string Name {
51                         get {
52                                 return name;
53                         }
54                 }
55
56                 /// <summary>
57                 /// </summary>
58                 public int Size {
59                         get {
60                                 return size;
61                         }
62                 }
63
64
65                 /// <summary>
66                 /// </summary>
67                 public OpCodeType OpCodeType {
68                         get {
69                                 return type;
70                         }
71                 }
72
73                 /// <summary>
74                 /// </summary>
75                 public OperandType OperandType {
76                         get {
77                                 return operandType;
78                         }
79                 }
80
81                 /// <summary>
82                 /// </summary>
83                 public FlowControl FlowControl {
84                         get {
85                                 return flowCtrl;
86                         }
87                 }
88
89
90                 /// <summary>
91                 /// </summary>
92                 public StackBehaviour StackBehaviourPop {
93                         get {
94                                 return pop;
95                         }
96                 }
97
98
99                 /// <summary>
100                 /// </summary>
101                 public StackBehaviour StackBehaviourPush {
102                         get {
103                                 return push;
104                         }
105                 }
106
107
108                 /// <summary>
109                 /// </summary>
110                 public short Value {
111                         get {
112                                 if (size == 1) {
113                                         return op2;
114                                 } else {
115                                         // two byte instruction - combine
116                                         // give the same values as the mscorlib impl
117                                         // this makes the Value property useless
118                                         return (short) ((op1 << 2) | op2);
119                                 }
120                         }
121                 }
122
123                 public override string ToString()
124                 {
125                         return Name;
126                 }
127         } // OpCode
128
129 } // System.Reflection.Emit