mirror of
https://github.com/golang/go
synced 2024-09-30 07:28:36 -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:
parent
57331b79da
commit
0d23c28526
@ -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")
|
||||
@ -1716,7 +1716,6 @@ func Dump(s string, n *Node) {
|
||||
// printer is a buffer for creating longer formatted strings.
|
||||
type printer struct {
|
||||
buf []byte
|
||||
dumpdepth int
|
||||
}
|
||||
|
||||
// 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(". ")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user