github.com/bir3/gocompiler@v0.3.205/src/cmd/compile/internal/noder/export.go (about)

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package noder
     6  
     7  import (
     8  	"bytes"
     9  	"fmt"
    10  	"io"
    11  
    12  	"github.com/bir3/gocompiler/src/cmd/compile/internal/base"
    13  	"github.com/bir3/gocompiler/src/cmd/compile/internal/typecheck"
    14  	"github.com/bir3/gocompiler/src/cmd/internal/bio"
    15  )
    16  
    17  func WriteExports(out *bio.Writer) {
    18  	var data bytes.Buffer
    19  
    20  	if base.Debug.Unified != 0 {
    21  		data.WriteByte('u')
    22  		writeUnifiedExport(&data)
    23  	} else {
    24  		typecheck.WriteExports(&data, true)
    25  	}
    26  
    27  	// The linker also looks for the $$ marker - use char after $$ to distinguish format.
    28  	out.WriteString("\n$$B\n") // indicate binary export format
    29  	io.Copy(out, &data)
    30  	out.WriteString("\n$$\n")
    31  
    32  	if base.Debug.Export != 0 {
    33  		fmt.Printf("BenchmarkExportSize:%s 1 %d bytes\n", base.Ctxt.Pkgpath, data.Len())
    34  	}
    35  }