mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/types: overhaul and simplify API
This CL removes a lot of the redundant methods for accessing struct fields and signature parameters. In particular, users never have to write ".Slice()" or ".FieldSlice()" anymore; the exported APIs just do what you want. Further internal refactorings to follow. Change-Id: I45212f6772fe16aad39d0e68b82d71b0796e5639 Reviewed-on: https://go-review.googlesource.com/c/go/+/521295 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
fecf51717f
commit
14f5eb7f31
36 changed files with 241 additions and 329 deletions
|
|
@ -201,7 +201,7 @@ func (l *linker) relocObj(pr *pkgReader, idx pkgbits.Index) pkgbits.Index {
|
|||
|
||||
if obj.Op() == ir.OTYPE && !obj.Alias() {
|
||||
if typ := obj.Type(); !typ.IsInterface() {
|
||||
for _, method := range typ.Methods().Slice() {
|
||||
for _, method := range typ.Methods() {
|
||||
l.exportBody(method.Nname.(*ir.Name), local)
|
||||
}
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ func (l *linker) relocFuncExt(w *pkgbits.Encoder, name *ir.Name) {
|
|||
|
||||
// Escape analysis.
|
||||
for _, fs := range &types.RecvsParams {
|
||||
for _, f := range fs(name.Type()).FieldSlice() {
|
||||
for _, f := range fs(name.Type()) {
|
||||
w.String(f.Note)
|
||||
}
|
||||
}
|
||||
|
|
@ -315,7 +315,7 @@ func (l *linker) relocTypeExt(w *pkgbits.Encoder, name *ir.Name) {
|
|||
l.lsymIdx(w, "", reflectdata.TypeLinksym(typ.PtrTo()))
|
||||
|
||||
if typ.Kind() != types.TINTER {
|
||||
for _, method := range typ.Methods().Slice() {
|
||||
for _, method := range typ.Methods() {
|
||||
l.relocFuncExt(w, method.Nname.(*ir.Name))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue