public override void OnTryStatement(TryStatement node)
{
++_tryBlock;
Label end = _il.BeginExceptionBlock();
// The fault handler isn't very well supported by the
// the ILGenerator. Thus, when there is a failure block
// in the same try as an except or ensure block, we
// need to do some special brute forcing with the exception
// block context in the ILGenerator.
if(null != node.FailureBlock && null != node.EnsureBlock)
{
++_tryBlock;
_il.BeginExceptionBlock();
}
if(null != node.FailureBlock && node.ExceptionHandlers.Count > 0)
{
++_tryBlock;
_il.BeginExceptionBlock();
}
Visit(node.ProtectedBlock);
Visit(node.ExceptionHandlers);
if(null != node.FailureBlock)
{
// Logic to back out of the manually forced blocks
if(node.ExceptionHandlers.Count > 0)
{
_il.EndExceptionBlock();
--_tryBlock;
}
_il.BeginFaultBlock();
Visit(node.FailureBlock);
// Logic to back out of the manually forced blocks once more
if(null != node.EnsureBlock)
{
_il.EndExceptionBlock();
--_tryBlock;
}
}
if (null != node.EnsureBlock)
{
_il.BeginFinallyBlock();
Visit(node.EnsureBlock);
}
_il.EndExceptionBlock();
--_tryBlock;
}