mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove conditional code dealing with two export formats
This removes some scaffolding introduced pre-1.7, introduced to fix an export format bug, and to minimize conflicts with older formats. The currently deployed and recognized format is "v1", so don't worry about other versions. This is a step towards a better scheme for internal export format versioning. For #16244. Change-Id: Ic7cf99dd2a24ad5484cc54aed44fa09332c2cf72 Reviewed-on: https://go-review.googlesource.com/27205 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
f50ced6d73
commit
074d6a649c
3 changed files with 11 additions and 33 deletions
|
|
@ -153,13 +153,9 @@ const debugFormat = false // default: false
|
||||||
// TODO(gri) disable and remove once there is only one export format again
|
// TODO(gri) disable and remove once there is only one export format again
|
||||||
const forceObjFileStability = true
|
const forceObjFileStability = true
|
||||||
|
|
||||||
// Supported export format versions.
|
// Current export format version.
|
||||||
// TODO(gri) Make this more systematic (issue #16244).
|
// TODO(gri) Make this more systematic (issue #16244).
|
||||||
const (
|
const exportVersion = "v1"
|
||||||
exportVersion0 = "v0"
|
|
||||||
exportVersion1 = "v1"
|
|
||||||
exportVersion = exportVersion1
|
|
||||||
)
|
|
||||||
|
|
||||||
// exportInlined enables the export of inlined function bodies and related
|
// exportInlined enables the export of inlined function bodies and related
|
||||||
// dependencies. The compiler should work w/o any loss of functionality with
|
// dependencies. The compiler should work w/o any loss of functionality with
|
||||||
|
|
@ -734,14 +730,7 @@ func (p *exporter) typ(t *Type) {
|
||||||
p.paramList(sig.Recvs(), inlineable)
|
p.paramList(sig.Recvs(), inlineable)
|
||||||
p.paramList(sig.Params(), inlineable)
|
p.paramList(sig.Params(), inlineable)
|
||||||
p.paramList(sig.Results(), inlineable)
|
p.paramList(sig.Results(), inlineable)
|
||||||
|
p.bool(m.Nointerface) // record go:nointerface pragma value (see also #16243)
|
||||||
// for issue #16243
|
|
||||||
// We make this conditional for 1.7 to avoid consistency problems
|
|
||||||
// with installed packages compiled with an older version.
|
|
||||||
// TODO(gri) Clean up after 1.7 is out (issue #16244)
|
|
||||||
if exportVersion == exportVersion1 {
|
|
||||||
p.bool(m.Nointerface)
|
|
||||||
}
|
|
||||||
|
|
||||||
var f *Func
|
var f *Func
|
||||||
if inlineable {
|
if inlineable {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import (
|
||||||
type importer struct {
|
type importer struct {
|
||||||
in *bufio.Reader
|
in *bufio.Reader
|
||||||
buf []byte // reused for reading strings
|
buf []byte // reused for reading strings
|
||||||
version string
|
|
||||||
|
|
||||||
// object lists, in order of deserialization
|
// object lists, in order of deserialization
|
||||||
strList []string
|
strList []string
|
||||||
|
|
@ -68,9 +67,8 @@ func Import(in *bufio.Reader) {
|
||||||
|
|
||||||
// --- generic export data ---
|
// --- generic export data ---
|
||||||
|
|
||||||
p.version = p.string()
|
if v := p.string(); v != exportVersion {
|
||||||
if p.version != exportVersion0 && p.version != exportVersion1 {
|
Fatalf("importer: unknown export data version: %s", v)
|
||||||
Fatalf("importer: unknown export data version: %s", p.version)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate typList with predeclared "known" types
|
// populate typList with predeclared "known" types
|
||||||
|
|
@ -429,11 +427,7 @@ func (p *importer) typ() *Type {
|
||||||
recv := p.paramList() // TODO(gri) do we need a full param list for the receiver?
|
recv := p.paramList() // TODO(gri) do we need a full param list for the receiver?
|
||||||
params := p.paramList()
|
params := p.paramList()
|
||||||
result := p.paramList()
|
result := p.paramList()
|
||||||
|
nointerface := p.bool()
|
||||||
nointerface := false
|
|
||||||
if p.version == exportVersion1 {
|
|
||||||
nointerface = p.bool()
|
|
||||||
}
|
|
||||||
|
|
||||||
n := methodname1(newname(sym), recv[0].Right)
|
n := methodname1(newname(sym), recv[0].Right)
|
||||||
n.Type = functype(recv[0], params, result)
|
n.Type = functype(recv[0], params, result)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ type importer struct {
|
||||||
data []byte
|
data []byte
|
||||||
path string
|
path string
|
||||||
buf []byte // for reading strings
|
buf []byte // for reading strings
|
||||||
version string
|
|
||||||
|
|
||||||
// object lists
|
// object lists
|
||||||
strList []string // in order of appearance
|
strList []string // in order of appearance
|
||||||
|
|
@ -67,9 +66,8 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i
|
||||||
|
|
||||||
// --- generic export data ---
|
// --- generic export data ---
|
||||||
|
|
||||||
p.version = p.string()
|
if v := p.string(); v != "v1" {
|
||||||
if p.version != "v0" && p.version != "v1" {
|
return p.read, nil, fmt.Errorf("unknown export data version: %s", v)
|
||||||
return p.read, nil, fmt.Errorf("unknown export data version: %s", p.version)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate typList with predeclared "known" types
|
// populate typList with predeclared "known" types
|
||||||
|
|
@ -305,10 +303,7 @@ func (p *importer) typ(parent *types.Package) types.Type {
|
||||||
recv, _ := p.paramList() // TODO(gri) do we need a full param list for the receiver?
|
recv, _ := p.paramList() // TODO(gri) do we need a full param list for the receiver?
|
||||||
params, isddd := p.paramList()
|
params, isddd := p.paramList()
|
||||||
result, _ := p.paramList()
|
result, _ := p.paramList()
|
||||||
|
p.int() // go:nointerface pragma - discarded
|
||||||
if p.version == "v1" {
|
|
||||||
p.int() // nointerface flag - discarded
|
|
||||||
}
|
|
||||||
|
|
||||||
sig := types.NewSignature(recv.At(0), params, result, isddd)
|
sig := types.NewSignature(recv.At(0), params, result, isddd)
|
||||||
t0.AddMethod(types.NewFunc(token.NoPos, parent, name, sig))
|
t0.AddMethod(types.NewFunc(token.NoPos, parent, name, sig))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue