[dev.regabi] cmd/compile: add NewNamed

The start of abstracting away Type fields. This adds a new constructor
for named types, styled after go/types.NewNamed. Along with helper
methods for SetNod and Pos, this allows hiding Nod.

Change-Id: Ica107034b6346c7b523bf6ae2a34009e350a9aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/274434
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Matthew Dempsky 2020-12-01 01:42:47 -08:00
parent 63a6f08b39
commit f37aa5e4e2
11 changed files with 75 additions and 63 deletions

View file

@ -545,9 +545,7 @@ func (*ParenExpr) CanBeNtype() {}
func (n *ParenExpr) SetOTYPE(t *types.Type) {
n.op = OTYPE
n.typ = t
if t.Nod == nil {
t.Nod = n
}
t.SetNod(n)
}
// A ResultExpr represents a direct access to a result slot on the stack frame.
@ -762,9 +760,7 @@ func (n *StarExpr) SetOTYPE(t *types.Type) {
n.op = OTYPE
n.X = nil
n.typ = t
if t.Nod == nil {
t.Nod = n
}
t.SetNod(n)
}
func (n *StarExpr) DeepCopy(pos src.XPos) Node {