Example #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();
        }