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 { ...@@ -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 { ...@@ -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")
...@@ -1715,8 +1715,7 @@ func Dump(s string, n *Node) { ...@@ -1715,8 +1715,7 @@ 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 { ...@@ -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(". ")
} }
} }
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