1
0
mirror of https://github.com/golang/go synced 2024-09-30 05:34:35 -06: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 {
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(". ")
}
}