Exemplo n.º 1
0
        internal static void MarkBlockAfter(ILGenerator il, ExceptionBlock block)
        {
            if (block.blockType == ExceptionBlockType.EndExceptionBlock)
            {
                if (HarmonyInstance.DEBUG)
                {
                    // fake log a LEAVE code since BeginCatchBlock() does add it
                    LogIL(il, OpCodes.Leave, new LeaveTry());

                    FileLog.ChangeIndent(-1);
                    FileLog.LogBuffered("} // end handler");
                }
                il.EndExceptionBlock();
            }
        }
Exemplo n.º 2
0
        internal static void MarkBlockBefore(ILGenerator il, ExceptionBlock block, out Label?label)
        {
            label = null;
            switch (block.blockType)
            {
            case ExceptionBlockType.BeginExceptionBlock:
                if (HarmonyInstance.DEBUG)
                {
                    FileLog.LogBuffered(".try");
                    FileLog.LogBuffered("{");
                    FileLog.ChangeIndent(1);
                }
                label = il.BeginExceptionBlock();
                return;

            case ExceptionBlockType.BeginCatchBlock:
                if (HarmonyInstance.DEBUG)
                {
                    // fake log a LEAVE code since BeginCatchBlock() does add it
                    LogIL(il, OpCodes.Leave, new LeaveTry());

                    FileLog.ChangeIndent(-1);
                    FileLog.LogBuffered("} // end try");

                    FileLog.LogBuffered(".catch " + block.catchType);
                    FileLog.LogBuffered("{");
                    FileLog.ChangeIndent(1);
                }
                il.BeginCatchBlock(block.catchType);
                return;

            case ExceptionBlockType.BeginExceptFilterBlock:
                if (HarmonyInstance.DEBUG)
                {
                    // fake log a LEAVE code since BeginCatchBlock() does add it
                    LogIL(il, OpCodes.Leave, new LeaveTry());

                    FileLog.ChangeIndent(-1);
                    FileLog.LogBuffered("} // end try");

                    FileLog.LogBuffered(".filter");
                    FileLog.LogBuffered("{");
                    FileLog.ChangeIndent(1);
                }
                il.BeginExceptFilterBlock();
                return;

            case ExceptionBlockType.BeginFaultBlock:
                if (HarmonyInstance.DEBUG)
                {
                    // fake log a LEAVE code since BeginCatchBlock() does add it
                    LogIL(il, OpCodes.Leave, new LeaveTry());

                    FileLog.ChangeIndent(-1);
                    FileLog.LogBuffered("} // end try");

                    FileLog.LogBuffered(".fault");
                    FileLog.LogBuffered("{");
                    FileLog.ChangeIndent(1);
                }
                il.BeginFaultBlock();
                return;

            case ExceptionBlockType.BeginFinallyBlock:
                if (HarmonyInstance.DEBUG)
                {
                    // fake log a LEAVE code since BeginCatchBlock() does add it
                    LogIL(il, OpCodes.Leave, new LeaveTry());

                    FileLog.ChangeIndent(-1);
                    FileLog.LogBuffered("} // end try");

                    FileLog.LogBuffered(".finally");
                    FileLog.LogBuffered("{");
                    FileLog.ChangeIndent(1);
                }
                il.BeginFinallyBlock();
                return;
            }
        }