aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/reflectdata/reflect.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-06-26 18:18:16 -0700
committerKeith Randall <khr@golang.org>2021-06-29 20:39:05 +0000
commit5fa6bbc669c22f05deb421c324b90b30ae3caa08 (patch)
tree78ce2c34869ee254f7ca69a52d085e3c75b6d425 /src/cmd/compile/internal/reflectdata/reflect.go
parentdfa8fd861ca99614f03ce409584c4f9ea3e6a3da (diff)
downloadgo-5fa6bbc669c22f05deb421c324b90b30ae3caa08.tar.gz
go-5fa6bbc669c22f05deb421c324b90b30ae3caa08.zip
[dev.typeparams] cmd/compile: clean up instantiation and dictionary naming
Separate generation of instantiation and dictionary name generation. Add code to add subdictionaries to a dictionary. Not quite working yet, as we need to trigger generation of the subdictionaries for methods. Change-Id: I0d46053eba695b217630b06ef2f990f6a0b52d83 Reviewed-on: https://go-review.googlesource.com/c/go/+/331209 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/reflect.go')
-rw-r--r--src/cmd/compile/internal/reflectdata/reflect.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go
index 351aaab399..27522ca85e 100644
--- a/src/cmd/compile/internal/reflectdata/reflect.go
+++ b/src/cmd/compile/internal/reflectdata/reflect.go
@@ -1869,7 +1869,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field, forItab bool) *obj.LSy
} else if !baseOrig.IsPtr() && method.Type.Recv().Type.IsPtr() {
baseOrig = types.NewPtr(baseOrig)
}
- args = append(args, getDictionary(".inst."+ir.MethodSym(baseOrig, method.Sym).Name, targs)) // TODO: remove .inst.
+ args = append(args, getDictionary(ir.MethodSym(baseOrig, method.Sym), targs))
if indirect {
args = append(args, ir.NewStarExpr(base.Pos, dot.X))
} else if methodrcvr.IsPtr() && methodrcvr.Elem() == dot.X.Type() {
@@ -1971,28 +1971,16 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) {
// getDictionary returns the dictionary for the given named generic function
// or method, with the given type arguments.
-// TODO: pass a reference to the generic function instead? We might need
-// that to look up protodictionaries.
-func getDictionary(name string, targs []*types.Type) ir.Node {
+func getDictionary(gf *types.Sym, targs []*types.Type) ir.Node {
if len(targs) == 0 {
- base.Fatalf("%s should have type arguments", name)
+ base.Fatalf("%s should have type arguments", gf.Name)
}
- // The dictionary for this instantiation is named after the function
- // and concrete types it is instantiated with.
- // TODO: decouple this naming from the instantiation naming. The instantiation
- // naming will be based on GC shapes, this naming must be fully stenciled.
- if !strings.HasPrefix(name, ".inst.") {
- base.Fatalf("%s should start in .inst.", name)
- }
- name = ".dict." + name[6:]
-
- // Get a symbol representing the dictionary.
- sym := typecheck.Lookup(name)
+ sym := typecheck.MakeDictName(gf, targs, true)
// Initialize the dictionary, if we haven't yet already.
if lsym := sym.Linksym(); len(lsym.P) == 0 {
- base.Fatalf("Dictionary should have alredy been generated: %v", sym)
+ base.Fatalf("Dictionary should have already been generated: %s.%s", sym.Pkg.Path, sym.Name)
}
// Make a node referencing the dictionary symbol.