Commit 0d23c285 authored by Robert Griesemer's avatar Robert Griesemer Committed by Matthew Dempsky

cmd/compile: make dumpdepth a global again

Fixes indenting in debug output like -W.

Change-Id: Ia16b0bad47428cee71fe036c297731e841ec9ca0
Reviewed-on: https://go-review.googlesource.com/27924Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 57331b79
......@@ -1404,7 +1404,7 @@ func (p *printer) nodedump(n *Node, flag FmtFlag) *printer {
if recur {
p.indent()
if p.dumpdepth > 10 {
if dumpdepth > 10 {
return p.s("...")
}
......@@ -1654,9 +1654,9 @@ func Nconv(n *Node, flag FmtFlag) string {
p.nodefmt(n, flag)
case FDbg:
p.dumpdepth++
dumpdepth++
p.nodedump(n, flag)
p.dumpdepth--
dumpdepth--
default:
Fatalf("unhandled %%N mode")
......@@ -1715,8 +1715,7 @@ func Dump(s string, n *Node) {
// printer is a buffer for creating longer formatted strings.
type printer struct {
buf []byte
dumpdepth int
buf []byte
}
// printer implements io.Writer.
......@@ -1742,10 +1741,13 @@ func (p *printer) f(format string, args ...interface{}) *printer {
return p
}
// TODO(gri) make this a field of printer
var dumpdepth int
// indent prints indentation to p.
func (p *printer) indent() {
p.s("\n")
for i := 0; i < p.dumpdepth; i++ {
for i := 0; i < dumpdepth; i++ {
p.s(". ")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment