mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: use old export format if not compiling with generics
Write out export data with the old export format (iexportVersionPosCol) if not compiling with generics (-G=0, the default value). This helps ensure we don't break tests involving x/tools/go/gcexportdata (since we can't modify that tool yet to use the new format). Change-Id: I5f9bce44ed1e0696fc65fead6bab9e30de88461d Reviewed-on: https://go-review.googlesource.com/c/go/+/323189 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
8c99e5db43
commit
c2c1b53b39
1 changed files with 16 additions and 4 deletions
|
|
@ -306,7 +306,12 @@ func WriteExports(out *bufio.Writer) {
|
||||||
// Assemble header.
|
// Assemble header.
|
||||||
var hdr intWriter
|
var hdr intWriter
|
||||||
hdr.WriteByte('i')
|
hdr.WriteByte('i')
|
||||||
hdr.uint64(iexportVersionCurrent)
|
if base.Flag.G > 0 {
|
||||||
|
hdr.uint64(iexportVersionCurrent)
|
||||||
|
} else {
|
||||||
|
// Use old export format if doing -G=0 (no generics)
|
||||||
|
hdr.uint64(iexportVersionPosCol)
|
||||||
|
}
|
||||||
hdr.uint64(uint64(p.strings.Len()))
|
hdr.uint64(uint64(p.strings.Len()))
|
||||||
hdr.uint64(dataLen)
|
hdr.uint64(dataLen)
|
||||||
|
|
||||||
|
|
@ -478,7 +483,9 @@ func (p *iexporter) doDecl(n *ir.Name) {
|
||||||
// referenced via their type offset (via typOff) in all
|
// referenced via their type offset (via typOff) in all
|
||||||
// other places in the signature and function that they
|
// other places in the signature and function that they
|
||||||
// are used.
|
// are used.
|
||||||
w.tparamList(n.Type().TParams().FieldSlice())
|
if base.Flag.G > 0 {
|
||||||
|
w.tparamList(n.Type().TParams().FieldSlice())
|
||||||
|
}
|
||||||
w.signature(n.Type())
|
w.signature(n.Type())
|
||||||
w.funcExt(n)
|
w.funcExt(n)
|
||||||
|
|
||||||
|
|
@ -511,8 +518,10 @@ func (p *iexporter) doDecl(n *ir.Name) {
|
||||||
w.tag('T')
|
w.tag('T')
|
||||||
w.pos(n.Pos())
|
w.pos(n.Pos())
|
||||||
|
|
||||||
// Export any new typeparams needed for this type
|
if base.Flag.G > 0 {
|
||||||
w.typeList(n.Type().RParams())
|
// Export any new typeparams needed for this type
|
||||||
|
w.typeList(n.Type().RParams())
|
||||||
|
}
|
||||||
underlying := n.Type().Underlying()
|
underlying := n.Type().Underlying()
|
||||||
if underlying == types.ErrorType.Underlying() {
|
if underlying == types.ErrorType.Underlying() {
|
||||||
// For "type T error", use error as the
|
// For "type T error", use error as the
|
||||||
|
|
@ -826,6 +835,7 @@ func (w *exportWriter) startType(k itag) {
|
||||||
|
|
||||||
func (w *exportWriter) doTyp(t *types.Type) {
|
func (w *exportWriter) doTyp(t *types.Type) {
|
||||||
if t.Kind() == types.TTYPEPARAM {
|
if t.Kind() == types.TTYPEPARAM {
|
||||||
|
assert(base.Flag.G > 0)
|
||||||
// A typeparam has a name, but doesn't have an underlying type.
|
// A typeparam has a name, but doesn't have an underlying type.
|
||||||
// Just write out the details of the type param here. All other
|
// Just write out the details of the type param here. All other
|
||||||
// uses of this typeparam type will be written out as its unique
|
// uses of this typeparam type will be written out as its unique
|
||||||
|
|
@ -846,6 +856,7 @@ func (w *exportWriter) doTyp(t *types.Type) {
|
||||||
|
|
||||||
s := t.Sym()
|
s := t.Sym()
|
||||||
if s != nil && t.OrigSym != nil {
|
if s != nil && t.OrigSym != nil {
|
||||||
|
assert(base.Flag.G > 0)
|
||||||
// This is an instantiated type - could be a re-instantiation like
|
// This is an instantiated type - could be a re-instantiation like
|
||||||
// Value[T2] or a full instantiation like Value[int].
|
// Value[T2] or a full instantiation like Value[int].
|
||||||
if strings.Index(s.Name, "[") < 0 {
|
if strings.Index(s.Name, "[") < 0 {
|
||||||
|
|
@ -945,6 +956,7 @@ func (w *exportWriter) doTyp(t *types.Type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case types.TUNION:
|
case types.TUNION:
|
||||||
|
assert(base.Flag.G > 0)
|
||||||
// TODO(danscales): possibly put out the tilde bools in more
|
// TODO(danscales): possibly put out the tilde bools in more
|
||||||
// compact form.
|
// compact form.
|
||||||
w.startType(unionType)
|
w.startType(unionType)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue