public override void BeginCatchBlock(Type exceptionType)
{
if (CurrExcStackCount == 0)
{
throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
}
Contract.EndContractBlock();
__ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1];
RuntimeType rtType = exceptionType as RuntimeType;
if (current.GetCurrentState() == __ExceptionInfo.State_Filter)
{
if (exceptionType != null)
{
throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType);
}
this.Emit(OpCodes.Endfilter);
current.MarkCatchAddr(ILOffset, null);
}
else
{
// execute this branch if previous clause is Catch or Fault
if (exceptionType == null)
{
throw new ArgumentNullException(nameof(exceptionType));
}
if (rtType == null)
{
throw new ArgumentException(SR.Argument_MustBeRuntimeType);
}
Label endLabel = current.GetEndLabel();
this.Emit(OpCodes.Leave, endLabel);
// if this is a catch block the exception will be pushed on the stack and we need to update the stack info
UpdateStackSize(OpCodes.Nop, 1);
current.MarkCatchAddr(ILOffset, exceptionType);
// this is relying on too much implementation details of the base and so it's highly breaking
// Need to have a more integrated story for exceptions
current.m_filterAddr[current.m_currentCatch - 1] = GetTokenFor(rtType);
}
}