diff options
author | Matthew Dempsky <mdempsky@google.com> | 2020-12-28 19:14:39 -0800 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2020-12-29 07:54:40 +0000 |
commit | 25c613c02dabb45f3a3dc038a8f01c664d98731a (patch) | |
tree | 9a40e67713e82378a5cecad7e01e287e4c362b57 /src/cmd/compile/internal/reflectdata/reflect.go | |
parent | 289da2b33ed6292c853017a15d3108d22ea7491a (diff) | |
download | go-25c613c02dabb45f3a3dc038a8f01c664d98731a.tar.gz go-25c613c02dabb45f3a3dc038a8f01c664d98731a.zip |
[dev.regabi] cmd/compile: add Linksym helpers
Syms are meant to be just interned (pkg, name) tuples, and are a
purely abstract, Go-language concept. As such, associating them with
linker symbols (a low-level, implementation-oriented detail) is
inappropriate.
There's still work to be done before linker symbols can be directly
attached to their appropriate, higher-level objects instead. But in
the mean-time, we can at least add helper functions and discourage
folks from using Sym.Linksym directly. The next CL will mechanically
rewrite code to use these helpers where possible.
Passes toolstash -cmp.
Change-Id: I413bd1c80bce056304f9a7343526bd153f2b9c7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/280639
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/reflectdata/reflect.go')
-rw-r--r-- | src/cmd/compile/internal/reflectdata/reflect.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index df80380fc1..4c625b40cb 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -812,8 +812,8 @@ func dcommontype(lsym *obj.LSym, t *types.Type) int { // TrackSym returns the symbol for tracking use of field/method f, assumed // to be a member of struct/interface type t. -func TrackSym(t *types.Type, f *types.Field) *types.Sym { - return ir.Pkgs.Track.Lookup(t.ShortString() + "." + f.Sym.Name) +func TrackSym(t *types.Type, f *types.Field) *obj.LSym { + return ir.Pkgs.Track.Lookup(t.ShortString() + "." + f.Sym.Name).Linksym() } func TypeSymPrefix(prefix string, t *types.Type) *types.Sym { @@ -845,6 +845,18 @@ func TypeSym(t *types.Type) *types.Sym { return s } +func TypeLinksymPrefix(prefix string, t *types.Type) *obj.LSym { + return TypeSymPrefix(prefix, t).Linksym() +} + +func TypeLinksymLookup(name string) *obj.LSym { + return types.TypeSymLookup(name).Linksym() +} + +func TypeLinksym(t *types.Type) *obj.LSym { + return TypeSym(t).Linksym() +} + func TypePtr(t *types.Type) *ir.AddrExpr { s := TypeSym(t) if s.Def == nil { |