internal static string ILBuilderToString( ILBuilder builder, Func <Cci.ILocalDefinition, LocalInfo> mapLocal = null, IReadOnlyDictionary <int, string> markers = null ) { var sb = new StringBuilder(); var ilStream = builder.RealizedIL; if (mapLocal == null) { mapLocal = local => new LocalInfo(local.Name, local.Type, local.IsPinned, local.IsReference); } var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(mapLocal); var visualizer = new ILBuilderVisualizer(builder.module); if (!ilStream.IsDefault) { visualizer.DumpMethod( sb, builder.MaxStack, ilStream, locals, GetHandlerSpans(builder.RealizedExceptionHandlers), markers, builder.AreLocalsZeroed ); } else { sb.AppendLine("{"); visualizer.VisualizeHeader(sb, 0, builder.MaxStack, locals); // serialize blocks as-is var current = builder.leaderBlock; while (current != null) { DumpBlockIL(current, sb); current = current.NextBlock; } sb.AppendLine("}"); } return(sb.ToString()); }
internal static string LocalSignatureToString( ILBuilder builder, Func <Cci.ILocalDefinition, LocalInfo> mapLocal = null) { var sb = new StringBuilder(); if (mapLocal == null) { mapLocal = local => new LocalInfo(local.Name, local.Type, local.IsPinned, local.IsReference); } var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(mapLocal); var visualizer = new ILBuilderVisualizer(builder.module); visualizer.VisualizeHeader(sb, -1, -1, locals); return(sb.ToString()); }
/// <remarks> /// Invoked via Reflection from <see cref="ILBuilder.GetDebuggerDisplay()"/> /// </remarks> internal static string ILBuilderToString( ILBuilder builder, Func<Cci.ILocalDefinition, LocalInfo> mapLocal = null, IReadOnlyDictionary<int, string> markers = null) { var sb = new StringBuilder(); var ilStream = builder.RealizedIL; if (mapLocal == null) { mapLocal = local => new LocalInfo(local.Name, local.Type, local.IsPinned, local.IsReference); } var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(mapLocal); var visualizer = new ILBuilderVisualizer(builder.module); if (ilStream != null) { visualizer.DumpMethod(sb, builder.MaxStack, ilStream, locals, GetHandlerSpans(builder.RealizedExceptionHandlers), markers); } else { sb.AppendLine("{"); visualizer.VisualizeHeader(sb, 0, builder.MaxStack, locals); // serialize blocks as-is var current = builder.leaderBlock; while (current != null) { DumpBlockIL(current, sb); current = current.NextBlock; } sb.AppendLine("}"); } return sb.ToString(); }
internal static string GetMethodIL(this CompilationTestData.MethodData method) { return(ILBuilderVisualizer.ILBuilderToString(method.ILBuilder)); }
internal static string LocalSignatureToString( ILBuilder builder, Func<Cci.ILocalDefinition, LocalInfo> mapLocal = null) { var sb = new StringBuilder(); if (mapLocal == null) { mapLocal = local => new LocalInfo(local.Name, local.Type, local.IsPinned, local.IsReference); } var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(mapLocal); var visualizer = new ILBuilderVisualizer(builder.module); visualizer.VisualizeHeader(sb, -1, -1, locals); return sb.ToString(); }
internal static string ILBuilderToString(ILBuilder builder) { var sb = new StringBuilder(); var ilStream = builder.RealizedIL; var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(ToLocalInfo); var visualizer = new ILBuilderVisualizer(builder.module); if (ilStream != null) { visualizer.DumpMethod(sb, builder.MaxStack, ilStream, locals, GetHandlerSpans(builder.RealizedExceptionHandlers)); } else { sb.AppendLine("{"); visualizer.VisualizeHeader(sb, 0, builder.MaxStack, locals); // serialize blocks as-is var current = builder.leaderBlock; while (current != null) { DumpBlockIL(current, sb); current = current.NextBlock; } sb.AppendLine("}"); } return sb.ToString(); }