Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateMethodBodyHelper()

void System.Reflection.Emit.MethodBuilder.CreateMethodBodyHelper ( ILGenerator il)
inlinepackage

Definition at line 220 of file MethodBuilder.cs.

221 {
222 if (il == null)
223 {
224 throw new ArgumentNullException("il");
225 }
226 int num = 0;
227 ModuleBuilder module = m_module;
229 if (m_bIsBaked)
230 {
231 throw new InvalidOperationException(SR.InvalidOperation_MethodHasBody);
232 }
233 if (il.m_methodBuilder != this && il.m_methodBuilder != null)
234 {
235 throw new InvalidOperationException(SR.InvalidOperation_BadILGeneratorUsage);
236 }
238 if (il.m_ScopeTree.m_iOpenScopeCount != 0)
239 {
240 throw new InvalidOperationException(SR.InvalidOperation_OpenLocalVariableScope);
241 }
242 m_ubBody = il.BakeByteArray();
243 m_mdMethodFixups = il.GetTokenFixups();
244 __ExceptionInfo[] exceptions = il.GetExceptions();
246 if (num2 > 0)
247 {
248 m_exceptions = new ExceptionHandler[num2];
249 for (int i = 0; i < exceptions.Length; i++)
250 {
251 int[] filterAddresses = exceptions[i].GetFilterAddresses();
252 int[] catchAddresses = exceptions[i].GetCatchAddresses();
253 int[] catchEndAddresses = exceptions[i].GetCatchEndAddresses();
254 Type[] catchClass = exceptions[i].GetCatchClass();
255 int numberOfCatches = exceptions[i].GetNumberOfCatches();
256 int startAddress = exceptions[i].GetStartAddress();
257 int endAddress = exceptions[i].GetEndAddress();
258 int[] exceptionTypes = exceptions[i].GetExceptionTypes();
259 for (int j = 0; j < numberOfCatches; j++)
260 {
261 int exceptionTypeToken = 0;
262 if (catchClass[j] != null)
263 {
264 exceptionTypeToken = module.GetTypeTokenInternal(catchClass[j]);
265 }
266 switch (exceptionTypes[j])
267 {
268 case 0:
269 case 1:
270 case 4:
271 m_exceptions[num++] = new ExceptionHandler(startAddress, endAddress, filterAddresses[j], catchAddresses[j], catchEndAddresses[j], exceptionTypes[j], exceptionTypeToken);
272 break;
273 case 2:
274 m_exceptions[num++] = new ExceptionHandler(startAddress, exceptions[i].GetFinallyEndAddress(), filterAddresses[j], catchAddresses[j], catchEndAddresses[j], exceptionTypes[j], exceptionTypeToken);
275 break;
276 }
277 }
278 }
279 }
280 m_bIsBaked = true;
281 }
static int CalculateNumberOfExceptions(__ExceptionInfo[] excp)

References System.Reflection.Emit.ILGenerator.BakeByteArray(), System.Reflection.Emit.MethodBuilder.CalculateNumberOfExceptions(), System.exceptions, System.Reflection.Emit.ILGenerator.GetExceptions(), System.Reflection.Emit.ILGenerator.GetTokenFixups(), System.Reflection.Emit.ModuleBuilder.GetTypeTokenInternal(), System.SR.InvalidOperation_BadILGeneratorUsage, System.SR.InvalidOperation_MethodHasBody, System.SR.InvalidOperation_OpenLocalVariableScope, System.Reflection.Emit.MethodBuilder.m_bIsBaked, System.Reflection.Emit.MethodBuilder.m_containingType, System.Reflection.Emit.MethodBuilder.m_exceptions, System.Reflection.Emit.ScopeTree.m_iOpenScopeCount, System.Reflection.Emit.MethodBuilder.m_mdMethodFixups, System.Reflection.Emit.ILGenerator.m_methodBuilder, System.Reflection.Emit.MethodBuilder.m_module, System.Reflection.Emit.ILGenerator.m_ScopeTree, System.Reflection.Emit.MethodBuilder.m_ubBody, System.Reflection.Emit.TypeBuilder.ThrowIfCreated(), and System.Reflection.Emit.MethodBuilder.ThrowIfShouldNotHaveBody().