コード例 #1
0
        private static void DumpSwitchBlockIL(ILBuilder.SwitchBlock block, StringBuilder sb)
        {
            byte[] il = block.RegularInstructions.Buffer;
            new ILBuilderVisualizer(block.builder.module).DumpILBlock(il, (int)block.RegularInstructionsLength, sb, SpecializedCollections.EmptyArray<ILVisualizer.HandlerSpan>(), block.Start);

            // switch (N, t1, t2... tN)
            //  IL ==> ILOpCode.Switch < unsigned int32 > < int32 >... < int32 >

            sb.Append(string.Format("  IL_{0:x4}:", block.RegularInstructionsLength + block.Start));
            sb.Append(string.Format("  {0,-10}", GetInstructionName(block.BranchCode)));
            sb.Append(string.Format("  IL_{0:x4}:", block.BranchesCount));

            var blockBuilder = ArrayBuilder<ILBuilder.BasicBlock>.GetInstance();
            block.GetBranchBlocks(blockBuilder);

            foreach (var branchBlock in blockBuilder)
            {
                if (branchBlock == null)
                {
                    // this happens if label is not yet marked.
                    sb.Append(" <unmarked label>");
                }
                else
                {
                    sb.Append(string.Format(" IL_{0:x4}", branchBlock.Start));
                }
            }

            blockBuilder.Free();

            sb.AppendLine();
        }