mirror of
https://github.com/golang/go
synced 2024-11-26 20:31:25 -07:00
[dev.regabi] cmd/compile: use ir.NewNameAt in SubstArgTypes
So we can remove Name.CloneName now. Passes toolstash -cmp. Change-Id: I63e57ba52a7031e06fe9c4ee9aee7de6dec70792 Reviewed-on: https://go-review.googlesource.com/c/go/+/281312 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
8fc44cf0fa
commit
a30fd52884
@ -147,12 +147,6 @@ func (n *Name) copy() Node { panic(n.no("copy")) }
|
|||||||
func (n *Name) doChildren(do func(Node) bool) bool { return false }
|
func (n *Name) doChildren(do func(Node) bool) bool { return false }
|
||||||
func (n *Name) editChildren(edit func(Node) Node) {}
|
func (n *Name) editChildren(edit func(Node) Node) {}
|
||||||
|
|
||||||
// CloneName makes a cloned copy of the name.
|
|
||||||
// It's not ir.Copy(n) because in general that operation is a mistake on names,
|
|
||||||
// which uniquely identify variables.
|
|
||||||
// Callers must use n.CloneName to make clear they intend to create a separate name.
|
|
||||||
func (n *Name) CloneName() *Name { c := *n; return &c }
|
|
||||||
|
|
||||||
// TypeDefn returns the type definition for a named OTYPE.
|
// TypeDefn returns the type definition for a named OTYPE.
|
||||||
// That is, given "type T Defn", it returns Defn.
|
// That is, given "type T Defn", it returns Defn.
|
||||||
// It is used by package types.
|
// It is used by package types.
|
||||||
|
@ -26,12 +26,12 @@ func LookupRuntime(name string) *ir.Name {
|
|||||||
// The result of SubstArgTypes MUST be assigned back to old, e.g.
|
// The result of SubstArgTypes MUST be assigned back to old, e.g.
|
||||||
// n.Left = SubstArgTypes(n.Left, t1, t2)
|
// n.Left = SubstArgTypes(n.Left, t1, t2)
|
||||||
func SubstArgTypes(old *ir.Name, types_ ...*types.Type) *ir.Name {
|
func SubstArgTypes(old *ir.Name, types_ ...*types.Type) *ir.Name {
|
||||||
n := old.CloneName()
|
|
||||||
|
|
||||||
for _, t := range types_ {
|
for _, t := range types_ {
|
||||||
types.CalcSize(t)
|
types.CalcSize(t)
|
||||||
}
|
}
|
||||||
n.SetType(types.SubstAny(n.Type(), &types_))
|
n := ir.NewNameAt(old.Pos(), old.Sym())
|
||||||
|
n.Class_ = old.Class()
|
||||||
|
n.SetType(types.SubstAny(old.Type(), &types_))
|
||||||
if len(types_) > 0 {
|
if len(types_) > 0 {
|
||||||
base.Fatalf("substArgTypes: too many argument types")
|
base.Fatalf("substArgTypes: too many argument types")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user