Ejemplo n.º 1
0
            internal override string Dump()
            {
                var node = new TreeDumperNode("boundSpillSequenceBuilder", null, new TreeDumperNode[]
                {
                    new TreeDumperNode("locals", this.GetLocals(), null),
                    new TreeDumperNode("statements", null, from x in this.GetStatements() select BoundTreeDumperNodeProducer.MakeTree(x)),
                    new TreeDumperNode("value", null, new TreeDumperNode[] { BoundTreeDumperNodeProducer.MakeTree(this.Value) }),
                    new TreeDumperNode("type", this.Type, null)
                });

                return(TreeDumper.DumpCompact(node));
            }
Ejemplo n.º 2
0
        internal string Dump()
        {
            return(TreeDumper.DumpCompact(DumpAncestors()));

            TreeDumperNode DumpAncestors()
            {
                TreeDumperNode current = null;

                for (Binder scope = this; scope != null; scope = scope.Next)
                {
                    var(description, snippet, locals) = Print(scope);
                    var sub = new List <TreeDumperNode>();
                    if (!locals.IsEmpty())
                    {
                        sub.Add(new TreeDumperNode("locals", locals, null));
                    }
                    var currentContainer = scope.ContainingMemberOrLambda;
                    if (currentContainer != null && currentContainer != scope.Next?.ContainingMemberOrLambda)
                    {
                        sub.Add(new TreeDumperNode("containing symbol", currentContainer.ToDisplayString(), null));
                    }
                    if (snippet != null)
                    {
                        sub.Add(new TreeDumperNode($"scope", $"{snippet} ({scope.ScopeDesignator.Kind()})", null));
                    }
                    if (current != null)
                    {
                        sub.Add(current);
                    }
                    current = new TreeDumperNode(description, null, sub);
                }

                return(current);
            }

            (string description, string snippet, string locals) Print(Binder scope)
            {
                var    locals  = string.Join(", ", scope.Locals.SelectAsArray(s => s.Name));
                string snippet = null;

                if (scope.ScopeDesignator != null)
                {
                    var lines = scope.ScopeDesignator.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    if (lines.Length == 1)
                    {
                        snippet = lines[0];
                    }
                    else
                    {
                        var first    = lines[0];
                        var last     = lines[lines.Length - 1].Trim();
                        var lastSize = Math.Min(last.Length, 12);
                        snippet = first.Substring(0, Math.Min(first.Length, 12)) + " ... " + last.Substring(last.Length - lastSize, lastSize);
                    }
                    snippet = snippet.IsEmpty() ? null : snippet;
                }

                var description = scope.GetType().Name;

                return(description, snippet, locals);
            }
        }
Ejemplo n.º 3
0
 internal override string Dump()
 {
     var node = new TreeDumperNode("boundSpillSequence2", null, new TreeDumperNode[]
         {
             new TreeDumperNode("locals", this.Locals, null),
             new TreeDumperNode("statements", null, from x in this.Statements select BoundTreeDumperNodeProducer.MakeTree(x)),
             new TreeDumperNode("value", null, new TreeDumperNode[] { BoundTreeDumperNodeProducer.MakeTree(this.Value) }),
             new TreeDumperNode("type", this.Type, null)
         });
     return TreeDumper.DumpCompact(node);
 }
Ejemplo n.º 4
0
 public static new string DumpCompact(TreeDumperNode root)
 {
     return(new MyTreeDumper().DoDumpCompact(root));
 }