private static void DumpBasicBlockIL(ILBuilder.BasicBlock block, StringBuilder sb) { var instrCnt = block.RegularInstructionsLength; if (instrCnt != 0) { var il = block.RegularInstructions.ToImmutableArray(); new ILBuilderVisualizer(block.builder.module).DumpILBlock(il, instrCnt, sb, Array.Empty <ILVisualizer.HandlerSpan>(), block.Start); } if (block.BranchCode != ILOpCode.Nop) { sb.Append(string.Format(" IL_{0:x4}:", block.RegularInstructionsLength + block.Start)); sb.Append(string.Format(" {0,-10}", GetInstructionName(block.BranchCode))); if (block.BranchCode.IsBranch()) { var branchBlock = block.BranchBlock; 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)); } } sb.AppendLine(); } }
private static string BasicBlockToString(ILBuilder.BasicBlock block) { StringBuilder sb = new StringBuilder(); DumpBlockIL(block, sb); return(sb.ToString()); }
private static void DumpBlockIL(ILBuilder.BasicBlock block, StringBuilder sb) { if (block is ILBuilder.SwitchBlock switchBlock) { DumpSwitchBlockIL(switchBlock, sb); } else { DumpBasicBlockIL(block, sb); } }
private static void DumpBlockIL(ILBuilder.BasicBlock block, StringBuilder sb) { var switchBlock = block as ILBuilder.SwitchBlock; if (switchBlock != null) { DumpSwitchBlockIL(switchBlock, sb); } else { DumpBasicBlockIL(block, sb); } }