diff options
author | Matthew Dempsky <mdempsky@google.com> | 2021-06-11 01:10:56 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2021-06-11 14:46:45 +0000 |
commit | 62e32dd386103b5ee8dfe921eb791b14277843b5 (patch) | |
tree | e180928130737ecaec2d2e29466b7f21f0caa0ca /src/cmd/compile/internal/typecheck/iimport.go | |
parent | 18788245ea25a6f0ac11b02c15f5a94eab7a9e97 (diff) | |
download | go-62e32dd386103b5ee8dfe921eb791b14277843b5.tar.gz go-62e32dd386103b5ee8dfe921eb791b14277843b5.zip |
[dev.typeparams] cmd/compile: extract SetBaseTypeIndex function
The unified IR importer requires a way to set symbol indices for
imported types, so provide an exported API for this.
Change-Id: I2f088628f56d5b9f1097196dc1aa23f0a8b8d496
Reviewed-on: https://go-review.googlesource.com/c/go/+/327050
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/iimport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iimport.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 6d42875f49..9054a83e6e 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -993,7 +993,13 @@ func (r *importReader) symIdx(s *types.Sym) { func (r *importReader) typeExt(t *types.Type) { t.SetNotInHeap(r.bool()) - i, pi := r.int64(), r.int64() + SetBaseTypeIndex(t, r.int64(), r.int64()) +} + +func SetBaseTypeIndex(t *types.Type, i, pi int64) { + if t.Obj() == nil { + base.Fatalf("SetBaseTypeIndex on non-defined type %v", t) + } if i != -1 && pi != -1 { typeSymIdx[t] = [2]int64{i, pi} } @@ -1001,6 +1007,7 @@ func (r *importReader) typeExt(t *types.Type) { // Map imported type T to the index of type descriptor symbols of T and *T, // so we can use index to reference the symbol. +// TODO(mdempsky): Store this information directly in the Type's Name. var typeSymIdx = make(map[*types.Type][2]int64) func BaseTypeIndex(t *types.Type) int64 { |