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 sealed class Instruction : ICodeVisitable {
37
Instruction m_previous;
40
SequencePoint m_sequencePoint;
43
get { return m_offset; }
44
set { m_offset = value; }
47
public OpCode OpCode {
48
get { return m_opCode; }
49
set { m_opCode = value; }
52
public object Operand {
53
get { return m_operand; }
54
set { m_operand = value; }
57
public Instruction Previous {
58
get { return m_previous; }
59
set { m_previous = value; }
62
public Instruction Next {
63
get { return m_next; }
64
set { m_next = value; }
67
public SequencePoint SequencePoint {
68
get { return m_sequencePoint; }
69
set { m_sequencePoint = value; }
72
internal Instruction (int offset, OpCode opCode, object operand) : this (offset, opCode)
77
internal Instruction (int offset, OpCode opCode)
83
internal Instruction (OpCode opCode, object operand) : this (0, opCode, operand)
87
internal Instruction (OpCode opCode) : this (0, opCode)
93
int size = m_opCode.Size;
95
switch (m_opCode.OperandType) {
96
case OperandType.InlineSwitch:
97
size += (1 + ((Instruction []) m_operand).Length) * 4;
99
case OperandType.InlineI8:
100
case OperandType.InlineR:
103
case OperandType.InlineBrTarget:
104
case OperandType.InlineField:
105
case OperandType.InlineI:
106
case OperandType.InlineMethod:
107
case OperandType.InlineString:
108
case OperandType.InlineTok:
109
case OperandType.InlineType:
110
case OperandType.ShortInlineR:
113
case OperandType.InlineParam:
114
case OperandType.InlineVar:
117
case OperandType.ShortInlineBrTarget:
118
case OperandType.ShortInlineI:
119
case OperandType.ShortInlineParam:
120
case OperandType.ShortInlineVar:
128
public void Accept (ICodeVisitor visitor)
130
visitor.VisitInstruction (this);