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; } }
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; } }
// 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); } }
static string FormatHandlerType (ExceptionHandler handler) { var handler_type = handler.HandlerType; var type = handler_type.ToString ().ToLowerInvariant (); switch (handler_type) { case ExceptionHandlerType.Catch: return string.Format ("{0} {1}", type, handler.CatchType.FullName); case ExceptionHandlerType.Filter: throw new NotImplementedException (); default: return type; } }
internal ControlFlowNode(int blockIndex, ExceptionHandler exceptionHandler, ControlFlowNode endFinallyOrFaultNode) { this.BlockIndex = blockIndex; this.NodeType = endFinallyOrFaultNode != null ? ControlFlowNodeType.FinallyOrFaultHandler : ControlFlowNodeType.CatchHandler; this.ExceptionHandler = exceptionHandler; this.EndFinallyOrFaultNode = endFinallyOrFaultNode; Debug.Assert((exceptionHandler.HandlerType == ExceptionHandlerType.Finally || exceptionHandler.HandlerType == ExceptionHandlerType.Fault) == (endFinallyOrFaultNode != null)); this.Offset = exceptionHandler.HandlerStart.Offset; }
public ILStructure(ILStructureType type, int startOffset, int endOffset, ExceptionHandler handler = null) { Debug.Assert(startOffset < endOffset); this.Type = type; this.StartOffset = startOffset; this.EndOffset = endOffset; this.ExceptionHandler = handler; }