29
29
namespace Mono.Cecil.Cil {
31
public enum FlowControl {
43
public enum OpCodeType {
52
public enum OperandType {
75
public enum StackBehaviour {
31
107
public struct OpCode {
37
byte m_stackBehaviourPop;
38
byte m_stackBehaviourPush;
112
readonly byte flow_control;
113
readonly byte opcode_type;
114
readonly byte operand_type;
115
readonly byte stack_behavior_pop;
116
readonly byte stack_behavior_push;
40
118
public string Name {
42
int index = (Size == 1) ? Op2 : (Op2 + 256);
43
return OpCodeNames.names [index];
119
get { return OpCodeNames.names [op1 == 0xff ? op2 : op2 + 256]; }
48
get { return ((m_value & 0xff00) == 0xff00) ? 1 : 2; }
123
get { return op1 == 0xff ? 1 : 2; }
52
get { return (byte) (m_value >> 8); }
56
get { return (byte) m_value; }
59
134
public short Value {
60
get { return (Size == 1) ? Op2 : m_value; }
135
get { return (short) ((op1 << 8) | op2); }
63
138
public Code Code {
64
get { return (Code) m_code; }
139
get { return (Code) code; }
67
142
public FlowControl FlowControl {
68
get { return (FlowControl) m_flowControl; }
143
get { return (FlowControl) flow_control; }
71
146
public OpCodeType OpCodeType {
72
get { return (OpCodeType) m_opCodeType; }
147
get { return (OpCodeType) opcode_type; }
75
150
public OperandType OperandType {
76
get { return (OperandType) m_operandType; }
151
get { return (OperandType) operand_type; }
79
154
public StackBehaviour StackBehaviourPop {
80
get { return (StackBehaviour) m_stackBehaviourPop; }
155
get { return (StackBehaviour) stack_behavior_pop; }
83
158
public StackBehaviour StackBehaviourPush {
84
get { return (StackBehaviour) m_stackBehaviourPush; }
159
get { return (StackBehaviour) stack_behavior_push; }
87
internal OpCode (byte op1, byte op2,
88
Code code, FlowControl flowControl,
89
OpCodeType opCodeType, OperandType operandType,
90
StackBehaviour pop, StackBehaviour push)
162
internal OpCode (int x, int y)
92
m_value = (short) ((op1 << 8) | op2);
94
m_flowControl = (byte) flowControl;
95
m_opCodeType = (byte) opCodeType;
96
m_operandType = (byte) operandType;
97
m_stackBehaviourPop = (byte) pop;
98
m_stackBehaviourPush = (byte) push;
164
this.op1 = (byte) ((x >> 0) & 0xff);
165
this.op2 = (byte) ((x >> 8) & 0xff);
166
this.code = (byte) ((x >> 16) & 0xff);
167
this.flow_control = (byte) ((x >> 24) & 0xff);
169
this.opcode_type = (byte) ((y >> 0) & 0xff);
170
this.operand_type = (byte) ((y >> 8) & 0xff);
171
this.stack_behavior_pop = (byte) ((y >> 16) & 0xff);
172
this.stack_behavior_push = (byte) ((y >> 24) & 0xff);
101
175
OpCodes.OneByteOpCode [op2] = this;
106
180
public override int GetHashCode ()
111
185
public override bool Equals (object obj)
113
187
if (!(obj is OpCode))
115
OpCode v = (OpCode) obj;
116
return v.m_value == m_value;
190
var opcode = (OpCode) obj;
191
return op1 == opcode.op1 && op2 == opcode.op2;
119
194
public bool Equals (OpCode opcode)
121
return (m_value == opcode.m_value);
196
return op1 == opcode.op1 && op2 == opcode.op2;
124
199
public static bool operator == (OpCode one, OpCode other)
126
return (one.m_value == other.m_value);
201
return one.op1 == other.op1 && one.op2 == other.op2;
129
204
public static bool operator != (OpCode one, OpCode other)
131
return (one.m_value != other.m_value);
206
return one.op1 != other.op1 || one.op2 != other.op2;
134
209
public override string ToString ()