Exemple #1
0
            public override string ToString()
            {
                var sb = new StringBuilder();

                string name = _interpreter.Name ?? "lambda_method";

                sb.Append("object ").Append(name).AppendLine("(object[])");
                sb.AppendLine("{");

                sb.Append("  .locals ").Append(_interpreter.LocalCount).AppendLine();
                sb.Append("  .maxstack ").Append(_interpreter.Instructions.MaxStackDepth).AppendLine();
                sb.Append("  .maxcontinuation ").Append(_interpreter.Instructions.MaxContinuationDepth).AppendLine();
                sb.AppendLine();

                Instruction[] instructions           = _interpreter.Instructions.Instructions;
                InstructionArray.DebugView debugView = new InstructionArray.DebugView(_interpreter.Instructions);
                InstructionList.DebugView.InstructionView[] instructionViews = debugView.GetInstructionViews(includeDebugCookies: false);

                for (int i = 0; i < instructions.Length; i++)
                {
                    EmitExits(sb, i);

                    int startCount;
                    if (_tryStart.TryGetValue(i, out startCount))
                    {
                        for (int j = 0; j < startCount; j++)
                        {
                            sb.Append(_indent).AppendLine(".try");
                            sb.Append(_indent).AppendLine("{");
                            Indent();
                        }
                    }

                    string handler;
                    if (_handlerEnter.TryGetValue(i, out handler))
                    {
                        sb.Append(_indent).AppendLine(handler);
                        sb.Append(_indent).AppendLine("{");
                        Indent();
                    }

                    Instruction instruction = instructions[i];
                    InstructionList.DebugView.InstructionView instructionView = instructionViews[i];

                    sb.AppendFormat(string.Format(CultureInfo.InvariantCulture, "{0}IP_{1}: {2}", _indent, i.ToString().PadLeft(4, '0'), instructionView.GetValue())).AppendLine();
                }

                EmitExits(sb, instructions.Length);

                sb.AppendLine("}");

                return(sb.ToString());
            }
Exemple #2
0
            public override string ToString()
            {
                var sb = new StringBuilder();

                var name = _interpreter.Name ?? "lambda_method";

                sb.Append("object ").Append(name).AppendLine("(object[])");
                sb.AppendLine("{");

                sb.Append("  .locals ").Append(_interpreter.LocalCount).AppendLine();
                sb.Append("  .maxstack ").Append(_interpreter.Instructions.MaxStackDepth).AppendLine();
                sb.Append("  .maxcontinuation ").Append(_interpreter.Instructions.MaxContinuationDepth).AppendLine();
                sb.AppendLine();

                var instructions     = _interpreter.Instructions.Instructions;
                var debugView        = new InstructionArray.DebugView(_interpreter.Instructions);
                var instructionViews = debugView.GetInstructionViews();

                for (var i = 0; i < instructions.Length; i++)
                {
                    EmitExits(sb, i);

                    if (_tryStart.TryGetValue(i, out var startCount))
                    {
                        for (var j = 0; j < startCount; j++)
                        {
                            sb.Append(_indent).AppendLine(".try");
                            sb.Append(_indent).AppendLine("{");
                            Indent();
                        }
                    }

                    if (_handlerEnter.TryGetValue(i, out var handler))
                    {
                        sb.Append(_indent).AppendLine(handler);
                        sb.Append(_indent).AppendLine("{");
                        Indent();
                    }

                    var instructionView = instructionViews[i];

                    sb.Append(_indent).Append("IP_").AppendFormat("{0:0000}", i).Append(": ").AppendLine(instructionView.GetValue());
                }

                EmitExits(sb, instructions.Length);

                sb.AppendLine("}");

                return(sb.ToString());
            }