[dev.regabi] cmd/compile: implement copy for nodes

Put each node in charge of making copies of its own slices.
This removes a generic use of Body, SetBody, and so on
in func Copy, heading toward removing those even from
being used in package ir.

Passes buildall w/ toolstash -cmp.

Change-Id: I249b7fe54cf72e9d2f0467b10f3f257abf9b29b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/275374
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-12-03 18:43:18 -05:00
parent d855b30fe4
commit 18f2df7e81
7 changed files with 532 additions and 281 deletions

View file

@ -117,7 +117,7 @@ func NewFunc(pos src.XPos) *Func {
func (f *Func) String() string { return fmt.Sprint(f) }
func (f *Func) Format(s fmt.State, verb rune) { FmtNode(f, s, verb) }
func (f *Func) rawCopy() Node { panic(f.no("rawCopy")) }
func (f *Func) copy() Node { panic(f.no("copy")) }
func (f *Func) Func() *Func { return f }
func (f *Func) Body() Nodes { return f.body }
func (f *Func) PtrBody() *Nodes { return &f.body }