Skip to content

Commit 0d23c28

Browse files
griesemermdempsky
authored andcommitted
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 <[email protected]> Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 57331b7 commit 0d23c28

File tree

1 file changed

+8
-6
lines changed
  • src/cmd/compile/internal/gc

1 file changed

+8
-6
lines changed

src/cmd/compile/internal/gc/fmt.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ func (p *printer) nodedump(n *Node, flag FmtFlag) *printer {
14041404

14051405
if recur {
14061406
p.indent()
1407-
if p.dumpdepth > 10 {
1407+
if dumpdepth > 10 {
14081408
return p.s("...")
14091409
}
14101410

@@ -1654,9 +1654,9 @@ func Nconv(n *Node, flag FmtFlag) string {
16541654
p.nodefmt(n, flag)
16551655

16561656
case FDbg:
1657-
p.dumpdepth++
1657+
dumpdepth++
16581658
p.nodedump(n, flag)
1659-
p.dumpdepth--
1659+
dumpdepth--
16601660

16611661
default:
16621662
Fatalf("unhandled %%N mode")
@@ -1715,8 +1715,7 @@ func Dump(s string, n *Node) {
17151715

17161716
// printer is a buffer for creating longer formatted strings.
17171717
type printer struct {
1718-
buf []byte
1719-
dumpdepth int
1718+
buf []byte
17201719
}
17211720

17221721
// printer implements io.Writer.
@@ -1742,10 +1741,13 @@ func (p *printer) f(format string, args ...interface{}) *printer {
17421741
return p
17431742
}
17441743

1744+
// TODO(gri) make this a field of printer
1745+
var dumpdepth int
1746+
17451747
// indent prints indentation to p.
17461748
func (p *printer) indent() {
17471749
p.s("\n")
1748-
for i := 0; i < p.dumpdepth; i++ {
1750+
for i := 0; i < dumpdepth; i++ {
17491751
p.s(". ")
17501752
}
17511753
}

0 commit comments

Comments
 (0)