コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
 internal static string GetMethodIL(this CompilationTestData.MethodData method)
 {
     return(ILBuilderVisualizer.ILBuilderToString(method.ILBuilder));
 }
コード例 #5
0
        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();
        }
コード例 #6
0
        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();
        }