1
0
mirror of https://github.com/golang/go synced 2024-11-26 11:28:21 -07:00

[dev.regabi] cmd/compile/internal/gc: refactor to use stop using Func.Nname

Automated factoring produced by rf script below to replace uses of
Func.Nname with Field.Nname or Node.MethodName as appropriate.

Some dead assignments to Func.Nname are left behind; these will be
removed in a subequent remove-only CL.

Passes toolstash-check.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex \
  import "cmd/compile/internal/types"; \
  var f *types.Field; \
  var n *types.Node; \
  f.Type.Nname() -> f.Nname; \
  f.Type.SetNname(n) -> f.Nname = n; \
  f.Type.FuncType().Nname -> f.Nname

ex \
  var n *Node; \
  asNode(n.Type.Nname()) -> n.MethodName(); \
  asNode(n.Type.FuncType().Nname) -> n.MethodName(); \
  asNode(callpartMethod(n).Type.Nname()) -> n.MethodName()
'

Change-Id: Iaae054324dfe7da6f5d8b8d57a1e05b58cc5968c
Reviewed-on: https://go-review.googlesource.com/c/go/+/272389
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>
This commit is contained in:
Matthew Dempsky 2020-11-22 20:43:16 -08:00
parent d5928847de
commit c50c7a8c06
9 changed files with 16 additions and 16 deletions

View File

@ -37,7 +37,7 @@ func (p *exporter) markType(t *types.Type) {
if t.Sym != nil && t.Etype != TINTER {
for _, m := range t.Methods().Slice() {
if types.IsExported(m.Sym.Name) {
p.markObject(asNode(m.Type.Nname()))
p.markObject(asNode(m.Nname))
}
}
}

View File

@ -897,7 +897,7 @@ func addmethod(n *Node, msym *types.Sym, t *types.Type, local, nointerface bool)
}
f := types.NewField(lineno, msym, t)
f.Type.SetNname(asTypesNode(n.Func.Nname))
f.Nname = asTypesNode(n.Func.Nname)
f.SetNointerface(nointerface)
mt.Methods().Append(f)

View File

@ -544,7 +544,7 @@ func (e *Escape) exprSkipInit(k EscHole, n *Node) {
for i := m.Type.NumResults(); i > 0; i-- {
ks = append(ks, e.heapHole())
}
paramK := e.tagHole(ks, asNode(m.Type.Nname()), m.Type.Recv())
paramK := e.tagHole(ks, asNode(m.Nname), m.Type.Recv())
e.expr(e.teeHole(paramK, closureK), n.Left)
@ -778,7 +778,7 @@ func (e *Escape) call(ks []EscHole, call, where *Node) {
fn = v.Func.Closure.Func.Nname
}
case OCALLMETH:
fn = asNode(call.Left.Type.FuncType().Nname)
fn = call.Left.MethodName()
}
fntype := call.Left.Type

View File

@ -994,7 +994,7 @@ func (w *exportWriter) funcExt(n *Node) {
func (w *exportWriter) methExt(m *types.Field) {
w.bool(m.Nointerface())
w.funcExt(asNode(m.Type.Nname()))
w.funcExt(asNode(m.Nname))
}
func (w *exportWriter) linkname(s *types.Sym) {

View File

@ -333,7 +333,7 @@ func (r *importReader) doDecl(n *Node) {
// methodSym already marked m.Sym as a function.
f := types.NewField(mpos, msym, mtyp)
f.Type.SetNname(asTypesNode(m))
f.Nname = asTypesNode(m)
ms[i] = f
}
t.Methods().Set(ms)
@ -667,7 +667,7 @@ func (r *importReader) methExt(m *types.Field) {
if r.bool() {
m.SetNointerface(true)
}
r.funcExt(asNode(m.Type.Nname()))
r.funcExt(asNode(m.Nname))
}
func (r *importReader) linkname(s *types.Sym) {

View File

@ -277,7 +277,7 @@ func (d *initDeps) visit(n *Node) bool {
switch n.Op {
case ONAME:
if n.isMethodExpression() {
d.foundDep(asNode(n.Type.FuncType().Nname))
d.foundDep(n.MethodName())
return false
}
@ -290,7 +290,7 @@ func (d *initDeps) visit(n *Node) bool {
d.inspectList(n.Func.Closure.Nbody)
case ODOTMETH, OCALLPART:
d.foundDep(asNode(n.Type.FuncType().Nname))
d.foundDep(n.MethodName())
}
return true

View File

@ -267,7 +267,7 @@ func inlFlood(n *Node) {
switch n.Class() {
case PFUNC:
if n.isMethodExpression() {
inlFlood(asNode(n.Type.Nname()))
inlFlood(n.MethodName())
} else {
inlFlood(n)
exportsym(n)
@ -277,7 +277,7 @@ func inlFlood(n *Node) {
}
case ODOTMETH:
fn := asNode(n.Type.Nname())
fn := n.MethodName()
inlFlood(fn)
case OCALLPART:
@ -714,7 +714,7 @@ func inlCallee(fn *Node) *Node {
switch {
case fn.Op == ONAME && fn.Class() == PFUNC:
if fn.isMethodExpression() {
n := asNode(fn.Type.Nname())
n := fn.MethodName()
// Check that receiver type matches fn.Left.
// TODO(mdempsky): Handle implicit dereference
// of pointer receiver argument?

View File

@ -78,7 +78,7 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 {
case ONAME:
if n.Class() == PFUNC {
if n.isMethodExpression() {
n = asNode(n.Type.Nname())
n = n.MethodName()
}
if n != nil && n.Name.Defn != nil {
if m := v.visit(n.Name.Defn); m < min {
@ -87,14 +87,14 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 {
}
}
case ODOTMETH:
fn := asNode(n.Type.Nname())
fn := n.MethodName()
if fn != nil && fn.Op == ONAME && fn.Class() == PFUNC && fn.Name.Defn != nil {
if m := v.visit(fn.Name.Defn); m < min {
min = m
}
}
case OCALLPART:
fn := asNode(callpartMethod(n).Type.Nname())
fn := asNode(callpartMethod(n).Nname)
if fn != nil && fn.Op == ONAME && fn.Class() == PFUNC && fn.Name.Defn != nil {
if m := v.visit(fn.Name.Defn); m < min {
min = m

View File

@ -4024,7 +4024,7 @@ func curpkg() *types.Pkg {
// referenced by expression n, which must be a method selector,
// method expression, or method value.
func (n *Node) MethodName() *Node {
return asNode(n.MethodFunc().Type.Nname())
return asNode(n.MethodFunc().Nname)
}
// MethodFunc is like MethodName, but returns the types.Field instead.