public ExceptionHandler(int tryOffset, int tryLength, int filterOffset, int handlerOffset, int handlerLength, ExceptionHandlingClauseOptions kind, int exceptionTypeToken) { if (tryOffset < 0 || tryLength < 0 || filterOffset < 0 || handlerOffset < 0 || handlerLength < 0) { throw new ArgumentOutOfRangeException(); } this.tryOffset = tryOffset; this.tryLength = tryLength; this.filterOffset = filterOffset; this.handlerOffset = handlerOffset; this.handlerLength = handlerLength; this.kind = kind; this.exceptionTypeToken = exceptionTypeToken; }
private static bool IsValidKind(ExceptionHandlingClauseOptions kind) { switch (kind) { case ExceptionHandlingClauseOptions.Clause: case ExceptionHandlingClauseOptions.Filter: case ExceptionHandlingClauseOptions.Finally: case ExceptionHandlingClauseOptions.Fault: return(true); default: return(false); } }
/// <summary>使用指定的参数初始化 <see cref="T:System.Reflection.Emit.ExceptionHandler" /> 类的新实例。</summary> /// <param name="tryOffset">此异常处理程序受保护的第一个指令的字节偏移量。</param> /// <param name="tryLength">由此异常处理程序保护的字节数。</param> /// <param name="filterOffset">筛选器代码的开始的字节偏移量。筛选器代码在处理程序块的第一条指令结束。对于非筛选异常处理程序,把此参数指定为0。</param> /// <param name="handlerOffset">此异常处理程序的第一个指令的字节偏移量。</param> /// <param name="handlerLength">在此异常处理程序中的字节数。</param> /// <param name="kind">枚举值之一,指定异常处理程序的类型。</param> /// <param name="exceptionTypeToken">该异常处理程序处理的异常标记类型。如果不适用,则指定 0(零)。</param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="tryOffset" />,<paramref name="filterOffset" />,<paramref name="handlerOffset" />,<paramref name="tryLength" /> 或 <paramref name="handlerLength" /> 为负。</exception> public ExceptionHandler(int tryOffset, int tryLength, int filterOffset, int handlerOffset, int handlerLength, ExceptionHandlingClauseOptions kind, int exceptionTypeToken) { if (tryOffset < 0) { throw new ArgumentOutOfRangeException("tryOffset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (tryLength < 0) { throw new ArgumentOutOfRangeException("tryLength", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (filterOffset < 0) { throw new ArgumentOutOfRangeException("filterOffset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (handlerOffset < 0) { throw new ArgumentOutOfRangeException("handlerOffset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (handlerLength < 0) { throw new ArgumentOutOfRangeException("handlerLength", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if ((long)tryOffset + (long)tryLength > (long)int.MaxValue) { throw new ArgumentOutOfRangeException("tryLength", Environment.GetResourceString("ArgumentOutOfRange_Range", (object)0, (object)(int.MaxValue - tryOffset))); } if ((long)handlerOffset + (long)handlerLength > (long)int.MaxValue) { throw new ArgumentOutOfRangeException("handlerLength", Environment.GetResourceString("ArgumentOutOfRange_Range", (object)0, (object)(int.MaxValue - handlerOffset))); } if (kind == ExceptionHandlingClauseOptions.Clause && (exceptionTypeToken & 16777215) == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeToken", (object)exceptionTypeToken), "exceptionTypeToken"); } if (!ExceptionHandler.IsValidKind(kind)) { throw new ArgumentOutOfRangeException("kind", Environment.GetResourceString("ArgumentOutOfRange_Enum")); } this.m_tryStartOffset = tryOffset; this.m_tryEndOffset = tryOffset + tryLength; this.m_filterOffset = filterOffset; this.m_handlerStartOffset = handlerOffset; this.m_handlerEndOffset = handlerOffset + handlerLength; this.m_kind = kind; this.m_exceptionClass = exceptionTypeToken; }
internal ExceptionHandler(int tryStartOffset, int tryEndOffset, int filterOffset, int handlerStartOffset, int handlerEndOffset, int kind, int exceptionTypeToken) { Debug.Assert(tryStartOffset >= 0); Debug.Assert(tryEndOffset >= 0); Debug.Assert(filterOffset >= 0); Debug.Assert(handlerStartOffset >= 0); Debug.Assert(handlerEndOffset >= 0); Debug.Assert(IsValidKind((ExceptionHandlingClauseOptions)kind)); Debug.Assert(kind != (int)ExceptionHandlingClauseOptions.Clause || (exceptionTypeToken & 0x00FFFFFF) != 0); m_tryStartOffset = tryStartOffset; m_tryEndOffset = tryEndOffset; m_filterOffset = filterOffset; m_handlerStartOffset = handlerStartOffset; m_handlerEndOffset = handlerEndOffset; m_kind = (ExceptionHandlingClauseOptions)kind; m_exceptionClass = exceptionTypeToken; }
private void BeginFinallyFaultBlock(ExceptionHandlingClauseOptions kind) { ExceptionBlock block = exceptionStack.Peek(); if (exceptionBlockAssistanceMode == EBAM_COMPAT || (exceptionBlockAssistanceMode == EBAM_CLEVER && stackHeight != -1)) { Emit(OpCodes.Leave, block.labelEnd); } if (block.handlerOffset == 0) { block.tryLength = code.Position - block.tryOffset; } else { block.handlerLength = code.Position - block.handlerOffset; Label labelEnd; if (exceptionBlockAssistanceMode != EBAM_COMPAT) { labelEnd = block.labelEnd; } else { MarkLabel(block.labelEnd); labelEnd = DefineLabel(); Emit(OpCodes.Leave, labelEnd); } exceptionStack.Pop(); ExceptionBlock newBlock = new ExceptionBlock(exceptions.Count); newBlock.labelEnd = labelEnd; newBlock.tryOffset = block.tryOffset; newBlock.tryLength = code.Position - block.tryOffset; block = newBlock; exceptions.Add(block); exceptionStack.Push(block); } block.handlerOffset = code.Position; block.kind = kind; stackHeight = 0; }
public static ExceptionHandlerType ToDNLib(this ExceptionHandlingClauseOptions options) => (ExceptionHandlerType)options;
// Token: 0x06004A5C RID: 19036 RVA: 0x0010CEC1 File Offset: 0x0010B0C1 private static bool IsValidKind(ExceptionHandlingClauseOptions kind) { return(kind <= ExceptionHandlingClauseOptions.Finally || kind == ExceptionHandlingClauseOptions.Fault); }
public HandlerBlock(ExceptionHandlingClauseOptions type, MetadataToken exceptionType, BaseSection handlerSection) { Type = type; ExceptionType = exceptionType; HandlerSection = handlerSection; }
public HandlerBlock(ExceptionHandlingClauseOptions type, BaseSection filterSection, BaseSection handlerSection) { Type = type; FilterSection = filterSection; HandlerSection = handlerSection; }
/// <summary>Initializes a new instance of the <see cref="T:System.Reflection.Emit.ExceptionHandler" /> class with the specified parameters.</summary><param name="tryOffset">The byte offset of the first instruction protected by this exception handler.</param><param name="tryLength">The number of bytes protected by this exception handler.</param><param name="filterOffset">The byte offset of the beginning of the filter code. The filter code ends at the first instruction of the handler block. For non-filter exception handlers, specify 0 (zero) for this parameter.</param><param name="handlerOffset">The byte offset of the first instruction of this exception handler.</param><param name="handlerLength">The number of bytes in this exception handler.</param><param name="kind">One of the enumeration values that specifies the kind of exception handler.</param><param name="exceptionTypeToken">The token of the exception type handled by this exception handler. If not applicable, specify 0 (zero).</param><exception cref="T:System.ArgumentOutOfRangeException"><paramref name="tryOffset" />, <paramref name="filterOffset" />, <paramref name="handlerOffset" />, <paramref name="tryLength" />, or <paramref name="handlerLength" /> are negative.</exception> public ExceptionHandler(int tryOffset, int tryLength, int filterOffset, int handlerOffset, int handlerLength, ExceptionHandlingClauseOptions kind, int exceptionTypeToken) { throw new NotImplementedException(); }