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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Internal.TypeSystem;
namespace Internal.IL
{
//
// This duplicates types from System.Reflection.Metadata to avoid layering issues, and
// because of the System.Reflection.Metadata constructors are not public anyway.
//
public enum ILExceptionRegionKind
{
Catch = 0,
Filter = 1,
Finally = 2,
Fault = 4,
}
public struct ILExceptionRegion
{
public readonly ILExceptionRegionKind Kind;
public readonly int TryOffset;
public readonly int TryLength;
public readonly int HandlerOffset;
public readonly int HandlerLength;
public readonly int ClassToken;
public readonly int FilterOffset;
public ILExceptionRegion(
ILExceptionRegionKind kind,
int tryOffset,
int tryLength,
int handlerOffset,
int handlerLength,
int classToken,
int filterOffset)
{
Kind = kind;
TryOffset = tryOffset;
TryLength = tryLength;
HandlerOffset = handlerOffset;
HandlerLength = handlerLength;
ClassToken = classToken;
FilterOffset = filterOffset;
}
}
/// <summary>
/// Represents a method body.
/// </summary>
[System.Diagnostics.DebuggerTypeProxy(typeof(MethodILDebugView))]
public abstract partial class MethodILScope
{
/// <summary>
/// Gets the method whose body this <see cref=""/> represents.
/// </summary>
public abstract MethodDesc OwningMethod { get; }
/// <summary>
/// Gets the open (uninstantiated) version of the <see cref="MethodILScope"/>.
/// </summary>
public virtual MethodILScope GetMethodILScopeDefinition()
{
return this;
}
/// <summary>
/// Resolves a token from within the method body into a type system object
/// (typically a <see cref="MethodDesc"/>, <see cref="FieldDesc"/>, <see cref="TypeDesc"/>,
/// or <see cref="MethodSignature"/>).
/// </summary>
public abstract object GetObject(int token, NotFoundBehavior notFoundBehavior = NotFoundBehavior.Throw);
public override string ToString()
{
return OwningMethod.ToString();
}
}
/// <summary>
/// Represents a method body.
/// </summary>
[System.Diagnostics.DebuggerTypeProxy(typeof(MethodILDebugView))]
public abstract partial class MethodIL : MethodILScope
{
/// <summary>
/// Gets the maximum possible stack depth this method declares.
/// </summary>
public abstract int MaxStack { get; }
/// <summary>
/// Gets a value indicating whether the locals should be initialized to zero
/// before first access.
/// </summary>
public abstract bool IsInitLocals { get; }
/// <summary>
/// Retrieves IL opcode bytes of this method body.
/// </summary>
public abstract byte[] GetILBytes();
/// <summary>
/// Gets the list of locals this method body defines.
/// </summary>
public abstract LocalVariableDefinition[] GetLocals();
/// <summary>
/// Gets a list of exception regions this method body defines.
/// </summary>
public abstract ILExceptionRegion[] GetExceptionRegions();
public sealed override MethodILScope GetMethodILScopeDefinition()
{
return GetMethodILDefinition();
}
/// <summary>
/// Gets the open (uninstantiated) version of the <see cref="MethodIL"/>.
/// </summary>
public virtual MethodIL GetMethodILDefinition()
{
return this;
}
}
}
|