aboutsummaryrefslogtreecommitdiff
path: root/src/go/internal/gcimporter/iimport.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/internal/gcimporter/iimport.go')
-rw-r--r--src/go/internal/gcimporter/iimport.go46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/go/internal/gcimporter/iimport.go b/src/go/internal/gcimporter/iimport.go
index 76d47d08f1..dbc9b3a83e 100644
--- a/src/go/internal/gcimporter/iimport.go
+++ b/src/go/internal/gcimporter/iimport.go
@@ -41,6 +41,16 @@ func (r *intReader) uint64() uint64 {
return i
}
+// Keep this in sync with constants in iexport.go.
+const (
+ iexportVersionGo1_11 = 0
+ iexportVersionPosCol = 1
+ // TODO: before release, change this back to 2.
+ iexportVersionGenerics = iexportVersionPosCol
+
+ iexportVersionCurrent = iexportVersionGenerics
+)
+
const predeclReserved = 32
type itag uint64
@@ -56,6 +66,8 @@ const (
signatureType
structType
interfaceType
+ typeParamType
+ instType
)
// iImportData imports a package from the serialized package data
@@ -63,7 +75,7 @@ const (
// If the export data version is not recognized or the format is otherwise
// compromised, an error is returned.
func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataReader *bufio.Reader, path string) (pkg *types.Package, err error) {
- const currentVersion = 1
+ const currentVersion = iexportVersionCurrent
version := int64(-1)
defer func() {
if e := recover(); e != nil {
@@ -79,9 +91,13 @@ func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataRea
version = int64(r.uint64())
switch version {
- case currentVersion, 0:
+ case /* iexportVersionGenerics, */ iexportVersionPosCol, iexportVersionGo1_11:
default:
- errorf("unknown iexport format version %d", version)
+ if version > iexportVersionGenerics {
+ errorf("unstable iexport format version %d, just rebuild compiler and std library", version)
+ } else {
+ errorf("unknown iexport format version %d", version)
+ }
}
sLen := int64(r.uint64())
@@ -95,8 +111,9 @@ func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataRea
declData := data[sLen:]
p := iimporter{
- ipath: path,
- version: int(version),
+ exportVersion: version,
+ ipath: path,
+ version: int(version),
stringData: stringData,
stringCache: make(map[uint64]string),
@@ -172,8 +189,9 @@ func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataRea
}
type iimporter struct {
- ipath string
- version int
+ exportVersion int64
+ ipath string
+ version int
stringData []byte
stringCache map[uint64]string
@@ -276,6 +294,9 @@ func (r *importReader) obj(name string) {
r.declare(types.NewFunc(pos, r.currPkg, name, sig))
+ case 'G':
+ errorf("unexpected parameterized function/method")
+
case 'T':
// Types can be recursive. We need to setup a stub
// declaration before recursing.
@@ -297,6 +318,9 @@ func (r *importReader) obj(name string) {
}
}
+ case 'U':
+ errorf("unexpected parameterized type")
+
case 'V':
typ := r.typ()
@@ -549,6 +573,14 @@ func (r *importReader) doType(base *types.Named) types.Type {
typ := types.NewInterfaceType(methods, embeddeds)
r.p.interfaceList = append(r.p.interfaceList, typ)
return typ
+
+ case typeParamType:
+ errorf("do not handle type param types yet")
+ return nil
+
+ case instType:
+ errorf("do not handle instantiated types yet")
+ return nil
}
}