]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile/internal/gc: add MethodName for getting referenced method
authorMatthew Dempsky <mdempsky@google.com>
Sun, 22 Nov 2020 21:47:55 +0000 (13:47 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 24 Nov 2020 01:34:13 +0000 (01:34 +0000)
commitb30c7a80443c6aed5a7f57ae4c57d691ea88ad9a
tree6b6a82e33a0bd7d40a36ab4463bcbb2bbd7c266d
parente1047302bdbfcac0f2331ebd5f6126a8b3c3b9b3
[dev.regabi] cmd/compile/internal/gc: add MethodName for getting referenced method

A common operation throughout the front end is getting the ONAME for a
method used in a method selector, method expression, or method value.
This CL adds MethodName as a uniform API for doing this for all of
these kinds of nodes.

For method selectors (ODOTMETH) and method expressions (ONAMEs where
isMethodExpression reports true), we take advantage of the Node.Opt
field to save the types.Field. This is the approach we already started
taking in golang.org/cl/271217 (caching types.Field in Node.Opt for
ODOT).

For method values (OCALLPART), we continue using the existing
callpartMethod helper function. Escape analysis already uses Node.Opt
for tracking the method value's closure's data flow.

A subsequent, automated refactoring CL will make more use of this
method. For now, we just address a few cases in inl.go that aren't
easily automated.

Passes toolstash-check.

Change-Id: Ic92b288b2d8b2fa7e18e3b68634326b8ef0d869b
Reviewed-on: https://go-review.googlesource.com/c/go/+/272387
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/fmtmap_test.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/typecheck.go