Commit 0fb82fbc authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: remove global bout variable

Change-Id: I7054bbec080708c3a11ed62d7f6594e82aa33747
Reviewed-on: https://go-review.googlesource.com/61691
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
parent 34db5f0c
...@@ -19,7 +19,7 @@ var ( ...@@ -19,7 +19,7 @@ var (
Debug_export int // if set, print debugging information about export data Debug_export int // if set, print debugging information about export data
) )
func exportf(format string, args ...interface{}) { func exportf(bout *bio.Writer, format string, args ...interface{}) {
fmt.Fprintf(bout, format, args...) fmt.Fprintf(bout, format, args...)
if Debug_export != 0 { if Debug_export != 0 {
fmt.Printf(format, args...) fmt.Printf(format, args...)
...@@ -222,14 +222,14 @@ func (x methodbyname) Len() int { return len(x) } ...@@ -222,14 +222,14 @@ func (x methodbyname) Len() int { return len(x) }
func (x methodbyname) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func (x methodbyname) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
func (x methodbyname) Less(i, j int) bool { return x[i].Sym.Name < x[j].Sym.Name } func (x methodbyname) Less(i, j int) bool { return x[i].Sym.Name < x[j].Sym.Name }
func dumpexport() { func dumpexport(bout *bio.Writer) {
if buildid != "" { if buildid != "" {
exportf("build id %q\n", buildid) exportf(bout, "build id %q\n", buildid)
} }
size := 0 // size of export section without enclosing markers size := 0 // size of export section without enclosing markers
// The linker also looks for the $$ marker - use char after $$ to distinguish format. // The linker also looks for the $$ marker - use char after $$ to distinguish format.
exportf("\n$$B\n") // indicate binary export format exportf(bout, "\n$$B\n") // indicate binary export format
if debugFormat { if debugFormat {
// save a copy of the export data // save a copy of the export data
var copy bytes.Buffer var copy bytes.Buffer
...@@ -253,7 +253,7 @@ func dumpexport() { ...@@ -253,7 +253,7 @@ func dumpexport() {
} else { } else {
size = export(bout.Writer, Debug_export != 0) size = export(bout.Writer, Debug_export != 0)
} }
exportf("\n$$\n") exportf(bout, "\n$$\n")
if Debug_export != 0 { if Debug_export != 0 {
fmt.Printf("export data size = %d bytes\n", size) fmt.Printf("export data size = %d bytes\n", size)
......
...@@ -7,7 +7,6 @@ package gc ...@@ -7,7 +7,6 @@ package gc
import ( import (
"cmd/compile/internal/ssa" "cmd/compile/internal/ssa"
"cmd/compile/internal/types" "cmd/compile/internal/types"
"cmd/internal/bio"
"cmd/internal/obj" "cmd/internal/obj"
"cmd/internal/src" "cmd/internal/src"
"sync" "sync"
...@@ -85,8 +84,6 @@ var outfile string ...@@ -85,8 +84,6 @@ var outfile string
var linkobj string var linkobj string
var dolinkobj bool var dolinkobj bool
var bout *bio.Writer
// nerrors is the number of compiler errors reported // nerrors is the number of compiler errors reported
// since the last call to saveerrors. // since the last call to saveerrors.
var nerrors int var nerrors int
......
...@@ -56,8 +56,7 @@ func dumpobj() { ...@@ -56,8 +56,7 @@ func dumpobj() {
} }
func dumpobj1(outfile string, mode int) { func dumpobj1(outfile string, mode int) {
var err error bout, err := bio.Create(outfile)
bout, err = bio.Create(outfile)
if err != nil { if err != nil {
flusherrors() flusherrors()
fmt.Printf("can't create %s: %v\n", outfile, err) fmt.Printf("can't create %s: %v\n", outfile, err)
...@@ -92,7 +91,7 @@ func dumpobj1(outfile string, mode int) { ...@@ -92,7 +91,7 @@ func dumpobj1(outfile string, mode int) {
printheader() printheader()
if mode&modeCompilerObj != 0 { if mode&modeCompilerObj != 0 {
dumpexport() dumpexport(bout)
} }
if writearchive { if writearchive {
......
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