1
0
mirror of https://github.com/golang/go synced 2024-11-18 03:44:46 -07:00

cmd/compile: make dumpdepth a global again

Fixes indenting in debug output like -W.

Change-Id: Ia16b0bad47428cee71fe036c297731e841ec9ca0
Reviewed-on: https://go-review.googlesource.com/27924
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Robert Griesemer 2016-08-26 16:38:06 -07:00 committed by Matthew Dempsky
parent 57331b79da
commit 0d23c28526

View File

@ -1404,7 +1404,7 @@ func (p *printer) nodedump(n *Node, flag FmtFlag) *printer {
if recur { if recur {
p.indent() p.indent()
if p.dumpdepth > 10 { if dumpdepth > 10 {
return p.s("...") return p.s("...")
} }
@ -1654,9 +1654,9 @@ func Nconv(n *Node, flag FmtFlag) string {
p.nodefmt(n, flag) p.nodefmt(n, flag)
case FDbg: case FDbg:
p.dumpdepth++ dumpdepth++
p.nodedump(n, flag) p.nodedump(n, flag)
p.dumpdepth-- dumpdepth--
default: default:
Fatalf("unhandled %%N mode") Fatalf("unhandled %%N mode")
@ -1716,7 +1716,6 @@ func Dump(s string, n *Node) {
// printer is a buffer for creating longer formatted strings. // printer is a buffer for creating longer formatted strings.
type printer struct { type printer struct {
buf []byte buf []byte
dumpdepth int
} }
// printer implements io.Writer. // printer implements io.Writer.
@ -1742,10 +1741,13 @@ func (p *printer) f(format string, args ...interface{}) *printer {
return p return p
} }
// TODO(gri) make this a field of printer
var dumpdepth int
// indent prints indentation to p. // indent prints indentation to p.
func (p *printer) indent() { func (p *printer) indent() {
p.s("\n") p.s("\n")
for i := 0; i < p.dumpdepth; i++ { for i := 0; i < dumpdepth; i++ {
p.s(". ") p.s(". ")
} }
} }