WriteOffsetReference() public static method

public static WriteOffsetReference ( PlainTextOutput writer, dnlib.DotNet.Emit.Instruction instruction ) : void
writer PlainTextOutput
instruction dnlib.DotNet.Emit.Instruction
return void
示例#1
0
        void WriteStructureHeader(ILStructure s)
        {
            switch (s.Type)
            {
            case ILStructureType.Loop:
                output.Write("// loop start", TextTokenType.Comment);
                if (s.LoopEntryPoint != null)
                {
                    output.Write(" (head: ", TextTokenType.Comment);
                    DisassemblerHelpers.WriteOffsetReference(output, s.LoopEntryPoint, null, TextTokenType.Comment);
                    output.Write(')', TextTokenType.Comment);
                }
                output.WriteLine();
                break;

            case ILStructureType.Try:
                output.WriteLine(".try", TextTokenType.ILDirective);
                output.WriteLineLeftBrace();
                break;

            case ILStructureType.Handler:
                switch (s.ExceptionHandler.HandlerType)
                {
                case ExceptionHandlerType.Catch:
                case ExceptionHandlerType.Filter:
                    output.Write("catch", TextTokenType.Keyword);
                    if (s.ExceptionHandler.CatchType != null)
                    {
                        output.WriteSpace();
                        s.ExceptionHandler.CatchType.WriteTo(output, ILNameSyntax.TypeName);
                    }
                    output.WriteLine();
                    break;

                case ExceptionHandlerType.Finally:
                    output.WriteLine("finally", TextTokenType.Keyword);
                    break;

                case ExceptionHandlerType.Fault:
                    output.WriteLine("fault", TextTokenType.Keyword);
                    break;

                default:
                    output.WriteLine(s.ExceptionHandler.HandlerType.ToString(), TextTokenType.Keyword);
                    break;
                }
                output.WriteLineLeftBrace();
                break;

            case ILStructureType.Filter:
                output.WriteLine("filter", TextTokenType.Keyword);
                output.WriteLineLeftBrace();
                break;

            default:
                throw new NotSupportedException();
            }
            output.Indent();
        }
示例#2
0
        void WriteStructureHeader(ILStructure s)
        {
            switch (s.Type)
            {
            case ILStructureType.Loop:
                output.Write("// loop start");
                if (s.LoopEntryPoint != null)
                {
                    output.Write(" (head: ");
                    DisassemblerHelpers.WriteOffsetReference(output, s.LoopEntryPoint);
                    output.Write(')');
                }
                output.WriteLine();
                break;

            case ILStructureType.Try:
                output.WriteLine(".try");
                output.WriteLine("{");
                break;

            case ILStructureType.Handler:
                switch (s.ExceptionHandler.HandlerType)
                {
                case Mono.Cecil.Cil.ExceptionHandlerType.Catch:
                case Mono.Cecil.Cil.ExceptionHandlerType.Filter:
                    output.Write("catch");
                    if (s.ExceptionHandler.CatchType != null)
                    {
                        output.Write(' ');
                        s.ExceptionHandler.CatchType.WriteTo(output, ILNameSyntax.TypeName);
                    }
                    output.WriteLine();
                    break;

                case Mono.Cecil.Cil.ExceptionHandlerType.Finally:
                    output.WriteLine("finally");
                    break;

                case Mono.Cecil.Cil.ExceptionHandlerType.Fault:
                    output.WriteLine("fault");
                    break;

                default:
                    throw new NotSupportedException();
                }
                output.WriteLine("{");
                break;

            case ILStructureType.Filter:
                output.WriteLine("filter");
                output.WriteLine("{");
                break;

            default:
                throw new NotSupportedException();
            }
            output.Indent();
        }
        void WriteStructureHeader(ILStructure s)
        {
            switch (s.Type)
            {
            case ILStructureType.Loop:
                output.Write("// loop start");
                if (s.LoopEntryPointOffset >= 0)
                {
                    output.Write(" (head: ");
                    DisassemblerHelpers.WriteOffsetReference(output, s.LoopEntryPointOffset);
                    output.Write(')');
                }
                output.WriteLine();
                break;

            case ILStructureType.Try:
                output.WriteLine(".try");
                output.WriteLine("{");
                break;

            case ILStructureType.Handler:
                switch (s.ExceptionHandler.Kind)
                {
                case ExceptionRegionKind.Catch:
                case ExceptionRegionKind.Filter:
                    output.Write("catch");
                    if (!s.ExceptionHandler.CatchType.IsNil)
                    {
                        output.Write(' ');
                        s.ExceptionHandler.CatchType.WriteTo(s.Module, output, s.GenericContext, ILNameSyntax.TypeName);
                    }
                    output.WriteLine();
                    break;

                case ExceptionRegionKind.Finally:
                    output.WriteLine("finally");
                    break;

                case ExceptionRegionKind.Fault:
                    output.WriteLine("fault");
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                output.WriteLine("{");
                break;

            case ILStructureType.Filter:
                output.WriteLine("filter");
                output.WriteLine("{");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            output.Indent();
        }
示例#4
0
        private void WriteStructureHeader(IlStructure s)
        {
            switch (s.Type)
            {
            case IlStructureType.Loop:
                _o.Write("// loop start");
                if (s.LoopEntryPoint != null)
                {
                    _o.Write(" (head: ");
                    DisassemblerHelpers.WriteOffsetReference(_o, s.LoopEntryPoint);
                    _o.Write(')');
                }
                _o.WriteLine();
                break;

            case IlStructureType.Try:
                _o.WriteLine(".try");
                _o.WriteLine("{");
                break;

            case IlStructureType.Handler:
                switch (s.ExceptionHandler.HandlerType)
                {
                case ExceptionHandlerType.Catch:
                case ExceptionHandlerType.Filter:
                    _o.Write("catch");
                    if (s.ExceptionHandler.CatchType != null)
                    {
                        _o.Write(' ');
                        s.ExceptionHandler.CatchType.WriteTo(_o, IlNameSyntax.TypeName);
                    }
                    _o.WriteLine();
                    break;

                case ExceptionHandlerType.Finally:
                    _o.WriteLine("finally");
                    break;

                case ExceptionHandlerType.Fault:
                    _o.WriteLine("fault");
                    break;

                default:
                    throw new NotSupportedException();
                }
                _o.WriteLine("{");
                break;

            case IlStructureType.Filter:
                _o.WriteLine("filter");
                _o.WriteLine("{");
                break;

            default:
                throw new NotSupportedException();
            }
            _o.Indent();
        }