void ReadExceptionHandlerSpecific (ExceptionHandler handler) { switch (handler.HandlerType) { case ExceptionHandlerType.Catch: handler.CatchType = (TypeReference) reader.LookupToken (ReadToken ()); break; case ExceptionHandlerType.Filter: handler.FilterStart = GetInstruction (ReadInt32 ()); break; default: Advance (4); break; } }
void WriteExceptionHandlerSpecific (ExceptionHandler handler) { switch (handler.HandlerType) { case ExceptionHandlerType.Catch: WriteMetadataToken (metadata.LookupToken (handler.CatchType)); break; case ExceptionHandlerType.Filter: WriteInt32 (handler.FilterStart.Offset); break; default: WriteInt32 (0); break; } }
// inline ? void ReadExceptionHandlers (int count, Func<int> read_entry, Func<int> read_length) { for (int i = 0; i < count; i++) { var handler = new ExceptionHandler ( (ExceptionHandlerType) (read_entry () & 0x7)); handler.TryStart = GetInstruction (read_entry ()); handler.TryEnd = GetInstruction (handler.TryStart.Offset + read_length ()); handler.HandlerStart = GetInstruction (read_entry ()); handler.HandlerEnd = GetInstruction (handler.HandlerStart.Offset + read_length ()); ReadExceptionHandlerSpecific (handler); this.body.ExceptionHandlers.Add (handler); } }