コード例 #1
0
        private static string DetailedMessage(string errorMessage, MethodNode method, Frame[] frames, AbstractInsnNode errorLocation)
        {
            StringWriter message = new StringWriter();

            using (PrintWriter @out = new PrintWriter(message))
            {
                IList <int> localLengths = new List <int>();
                IList <int> stackLengths = new List <int>();
                foreach (Frame frame in frames)
                {
                    if (frame != null)
                    {
                        for (int i = 0; i < frame.Locals; i++)
                        {
                            Insert(i, frame.getLocal(i), localLengths);
                        }
                        for (int i = 0; i < frame.StackSize; i++)
                        {
                            Insert(i, frame.getStack(i), stackLengths);
                        }
                    }
                }
                Textifier          formatted = new Textifier();
                TraceMethodVisitor mv        = new TraceMethodVisitor(formatted);

                @out.println(errorMessage);
                @out.append("\t\tin ").append(method.name).append(method.desc).println();
                for (int i = 0; i < method.instructions.size(); i++)
                {
                    AbstractInsnNode insn = method.instructions.get(i);
                    insn.accept(mv);
                    Frame frame = frames[i];
                    @out.append("\t\t");
                    @out.append(insn == errorLocation ? ">>> " : "    ");
                    @out.format("%05d [", i);
                    if (frame == null)
                    {
//JAVA TO C# CONVERTER WARNING: Unlike Java's ListIterator, enumerators in .NET do not allow altering the collection:
                        Padding(@out, localLengths.GetEnumerator(), '?');
                        @out.append(" : ");
//JAVA TO C# CONVERTER WARNING: Unlike Java's ListIterator, enumerators in .NET do not allow altering the collection:
                        Padding(@out, stackLengths.GetEnumerator(), '?');
                    }
                    else
                    {
                        Emit(@out, localLengths, frame.getLocal, frame.Locals);
                        Padding(@out, localLengths.listIterator(frame.Locals), '-');
                        @out.append(" : ");
                        Emit(@out, stackLengths, frame.getStack, frame.StackSize);
                        Padding(@out, stackLengths.listIterator(frame.StackSize), ' ');
                    }
                    @out.print("] : ");
                    @out.print(formatted.text.get(formatted.text.size() - 1));
                }
                for (int j = 0; j < method.tryCatchBlocks.size(); j++)
                {
                    method.tryCatchBlocks.get(j).accept(mv);
                    @out.print(" " + formatted.text.get(formatted.text.size() - 1));
                }
            }
            return(message.ToString());
        }