mscorlib(4.0.0.0) API with additions
__ExceptionInfo.cs
2 {
3  internal sealed class __ExceptionInfo
4  {
5  internal const int None = 0;
6 
7  internal const int Filter = 1;
8 
9  internal const int Finally = 2;
10 
11  internal const int Fault = 4;
12 
13  internal const int PreserveStack = 4;
14 
15  internal const int State_Try = 0;
16 
17  internal const int State_Filter = 1;
18 
19  internal const int State_Catch = 2;
20 
21  internal const int State_Finally = 3;
22 
23  internal const int State_Fault = 4;
24 
25  internal const int State_Done = 5;
26 
27  internal int m_startAddr;
28 
29  internal int[] m_filterAddr;
30 
31  internal int[] m_catchAddr;
32 
33  internal int[] m_catchEndAddr;
34 
35  internal int[] m_type;
36 
37  internal Type[] m_catchClass;
38 
39  internal Label m_endLabel;
40 
41  internal Label m_finallyEndLabel;
42 
43  internal int m_endAddr;
44 
45  internal int m_endFinally;
46 
47  internal int m_currentCatch;
48 
49  private int m_currentState;
50 
51  private __ExceptionInfo()
52  {
53  m_startAddr = 0;
54  m_filterAddr = null;
55  m_catchAddr = null;
56  m_catchEndAddr = null;
57  m_endAddr = 0;
58  m_currentCatch = 0;
59  m_type = null;
60  m_endFinally = -1;
61  m_currentState = 0;
62  }
63 
64  internal __ExceptionInfo(int startAddr, Label endLabel)
65  {
66  m_startAddr = startAddr;
67  m_endAddr = -1;
68  m_filterAddr = new int[4];
69  m_catchAddr = new int[4];
70  m_catchEndAddr = new int[4];
71  m_catchClass = new Type[4];
72  m_currentCatch = 0;
73  m_endLabel = endLabel;
74  m_type = new int[4];
75  m_endFinally = -1;
76  m_currentState = 0;
77  }
78 
79  private static Type[] EnlargeArray(Type[] incoming)
80  {
81  Type[] array = new Type[incoming.Length * 2];
82  Array.Copy(incoming, array, incoming.Length);
83  return array;
84  }
85 
86  private void MarkHelper(int catchorfilterAddr, int catchEndAddr, Type catchClass, int type)
87  {
88  if (m_currentCatch >= m_catchAddr.Length)
89  {
90  m_filterAddr = ILGenerator.EnlargeArray(m_filterAddr);
91  m_catchAddr = ILGenerator.EnlargeArray(m_catchAddr);
92  m_catchEndAddr = ILGenerator.EnlargeArray(m_catchEndAddr);
93  m_catchClass = EnlargeArray(m_catchClass);
94  m_type = ILGenerator.EnlargeArray(m_type);
95  }
96  if (type == 1)
97  {
98  m_type[m_currentCatch] = type;
99  m_filterAddr[m_currentCatch] = catchorfilterAddr;
100  m_catchAddr[m_currentCatch] = -1;
101  if (m_currentCatch > 0)
102  {
103  m_catchEndAddr[m_currentCatch - 1] = catchorfilterAddr;
104  }
105  }
106  else
107  {
108  m_catchClass[m_currentCatch] = catchClass;
109  if (m_type[m_currentCatch] != 1)
110  {
111  m_type[m_currentCatch] = type;
112  }
113  m_catchAddr[m_currentCatch] = catchorfilterAddr;
114  if (m_currentCatch > 0 && m_type[m_currentCatch] != 1)
115  {
116  m_catchEndAddr[m_currentCatch - 1] = catchEndAddr;
117  }
118  m_catchEndAddr[m_currentCatch] = -1;
119  m_currentCatch++;
120  }
121  if (m_endAddr == -1)
122  {
123  m_endAddr = catchorfilterAddr;
124  }
125  }
126 
127  internal void MarkFilterAddr(int filterAddr)
128  {
129  m_currentState = 1;
130  MarkHelper(filterAddr, filterAddr, null, 1);
131  }
132 
133  internal void MarkFaultAddr(int faultAddr)
134  {
135  m_currentState = 4;
136  MarkHelper(faultAddr, faultAddr, null, 4);
137  }
138 
139  internal void MarkCatchAddr(int catchAddr, Type catchException)
140  {
141  m_currentState = 2;
142  MarkHelper(catchAddr, catchAddr, catchException, 0);
143  }
144 
145  internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr)
146  {
147  if (m_endFinally != -1)
148  {
149  throw new ArgumentException(Environment.GetResourceString("Argument_TooManyFinallyClause"));
150  }
151  m_currentState = 3;
152  m_endFinally = finallyAddr;
153  MarkHelper(finallyAddr, endCatchAddr, null, 2);
154  }
155 
156  internal void Done(int endAddr)
157  {
158  m_catchEndAddr[m_currentCatch - 1] = endAddr;
159  m_currentState = 5;
160  }
161 
162  internal int GetStartAddress()
163  {
164  return m_startAddr;
165  }
166 
167  internal int GetEndAddress()
168  {
169  return m_endAddr;
170  }
171 
172  internal int GetFinallyEndAddress()
173  {
174  return m_endFinally;
175  }
176 
177  internal Label GetEndLabel()
178  {
179  return m_endLabel;
180  }
181 
182  internal int[] GetFilterAddresses()
183  {
184  return m_filterAddr;
185  }
186 
187  internal int[] GetCatchAddresses()
188  {
189  return m_catchAddr;
190  }
191 
192  internal int[] GetCatchEndAddresses()
193  {
194  return m_catchEndAddr;
195  }
196 
197  internal Type[] GetCatchClass()
198  {
199  return m_catchClass;
200  }
201 
202  internal int GetNumberOfCatches()
203  {
204  return m_currentCatch;
205  }
206 
207  internal int[] GetExceptionTypes()
208  {
209  return m_type;
210  }
211 
212  internal void SetFinallyEndLabel(Label lbl)
213  {
214  m_finallyEndLabel = lbl;
215  }
216 
217  internal Label GetFinallyEndLabel()
218  {
219  return m_finallyEndLabel;
220  }
221 
222  internal bool IsInner(__ExceptionInfo exc)
223  {
224  int num = exc.m_currentCatch - 1;
225  int num2 = m_currentCatch - 1;
226  if (exc.m_catchEndAddr[num] < m_catchEndAddr[num2])
227  {
228  return true;
229  }
230  if (exc.m_catchEndAddr[num] == m_catchEndAddr[num2] && exc.GetEndAddress() > GetEndAddress())
231  {
232  return true;
233  }
234  return false;
235  }
236 
237  internal int GetCurrentState()
238  {
239  return m_currentState;
240  }
241  }
242 }
Generates Microsoft intermediate language (MSIL) instructions.
Definition: ILGenerator.cs:12
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Represents a label in the instruction stream. Label is used in conjunction with the T:System....
Definition: Label.cs:8
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275