5 // Jb Evain (jbevain@gmail.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 namespace Mono.Cecil.Cil {
31 public struct OpCode {
39 FlowControl m_flowControl;
40 OpCodeType m_opCodeType;
41 OperandType m_operandType;
42 StackBehaviour m_stackBehaviourPop;
43 StackBehaviour m_stackBehaviourPush;
46 get { return m_name; }
50 get { return m_size; }
62 get { return m_size == 1 ? m_op2 : (short) ((m_op1 << 8) | m_op2); }
66 get { return m_code; }
69 public FlowControl FlowControl {
70 get { return m_flowControl; }
73 public OpCodeType OpCodeType {
74 get { return m_opCodeType; }
77 public OperandType OperandType {
78 get { return m_operandType; }
81 public StackBehaviour StackBehaviourPop {
82 get { return m_stackBehaviourPop; }
85 public StackBehaviour StackBehaviourPush {
86 get { return m_stackBehaviourPush; }
89 internal OpCode (string name, byte op1, byte op2, int size,
90 Code code, FlowControl flowControl,
91 OpCodeType opCodeType, OperandType operandType,
92 StackBehaviour pop, StackBehaviour push)
99 m_flowControl = flowControl;
100 m_opCodeType = opCodeType;
101 m_operandType = operandType;
102 m_stackBehaviourPop = pop;
103 m_stackBehaviourPush = push;
106 OpCodes.OneByteOpCode [op2] = this;
108 OpCodes.TwoBytesOpCode [op2] = this;
111 public override int GetHashCode ()
116 public override bool Equals (object obj)
118 if (!(obj is OpCode))
120 OpCode v = (OpCode) obj;
121 return v.m_op1 == m_op1 && v.m_op2 == m_op2;
124 public static bool operator == (OpCode one, OpCode other)
126 return one.Equals (other);
129 public static bool operator != (OpCode one, OpCode other)
131 return !one.Equals (other);
134 public override string ToString ()