Skip to content

Commit c4012b6

Browse files
cmd/compile: remove nodesOrNodeList outside of syntax.go
Passes toolstash -cmp. Update #14473. Change-Id: I717ebd948dfc8faf8b9ef5aa02c67484af618d18 Reviewed-on: https://go-review.googlesource.com/20359 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent f3a29f1 commit c4012b6

24 files changed

+218
-219
lines changed

src/cmd/compile/internal/gc/alg.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func genhash(sym *Sym, t *Type) {
288288
Curfn = fn
289289
fn.Func.Dupok = true
290290
typecheck(&fn, Etop)
291-
typechecklist(fn.Nbody, Etop)
291+
typechecklist(fn.Nbody.Slice(), Etop)
292292
Curfn = nil
293293

294294
// Disable safemode while compiling this code: the code we
@@ -486,7 +486,7 @@ func geneq(sym *Sym, t *Type) {
486486
Curfn = fn
487487
fn.Func.Dupok = true
488488
typecheck(&fn, Etop)
489-
typechecklist(fn.Nbody, Etop)
489+
typechecklist(fn.Nbody.Slice(), Etop)
490490
Curfn = nil
491491

492492
// Disable safemode while compiling this code: the code we

src/cmd/compile/internal/gc/bexport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ func (p *exporter) inlinedBody(n *Node) {
806806
p.int(index)
807807
}
808808

809-
func (p *exporter) nodeList(list nodesOrNodeList) {
809+
func (p *exporter) nodeList(list Nodes) {
810810
it := nodeSeqIterate(list)
811811
if p.trace {
812812
p.tracef("[ ")

src/cmd/compile/internal/gc/bimport.go

+13-14
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ func (p *importer) typ() *Type {
249249
}
250250
sym := pkg.Lookup(name)
251251

252-
n := methodname1(newname(sym), recv.N.Right)
253-
n.Type = functype(recv.N, params, result)
252+
n := methodname1(newname(sym), recv[0].Right)
253+
n.Type = functype(recv[0], params, result)
254254
checkwidth(n.Type)
255255
// addmethod uses the global variable structpkg to verify consistency
256256
{
@@ -342,14 +342,14 @@ func (p *importer) qualifiedName() *Sym {
342342
}
343343

344344
// go.y:hidden_structdcl_list
345-
func (p *importer) fieldList() *NodeList {
345+
func (p *importer) fieldList() []*Node {
346346
i := p.int()
347347
if i == 0 {
348348
return nil
349349
}
350-
n := list1(p.field())
351-
for i--; i > 0; i-- {
352-
n = list(n, p.field())
350+
n := make([]*Node, 0, i)
351+
for ; i > 0; i-- {
352+
n = append(n, p.field())
353353
}
354354
return n
355355
}
@@ -389,14 +389,14 @@ func (p *importer) note() (v Val) {
389389
}
390390

391391
// go.y:hidden_interfacedcl_list
392-
func (p *importer) methodList() *NodeList {
392+
func (p *importer) methodList() []*Node {
393393
i := p.int()
394394
if i == 0 {
395395
return nil
396396
}
397-
n := list1(p.method())
398-
for i--; i > 0; i-- {
399-
n = list(n, p.method())
397+
n := make([]*Node, 0, i)
398+
for ; i > 0; i-- {
399+
n = append(n, p.method())
400400
}
401401
return n
402402
}
@@ -428,7 +428,7 @@ func (p *importer) fieldName() *Sym {
428428
}
429429

430430
// go.y:ohidden_funarg_list
431-
func (p *importer) paramList() *NodeList {
431+
func (p *importer) paramList() []*Node {
432432
i := p.int()
433433
if i == 0 {
434434
return nil
@@ -440,10 +440,9 @@ func (p *importer) paramList() *NodeList {
440440
named = false
441441
}
442442
// i > 0
443-
n := list1(p.param(named))
444-
i--
443+
n := make([]*Node, 0, i)
445444
for ; i > 0; i-- {
446-
n = list(n, p.param(named))
445+
n = append(n, p.param(named))
447446
}
448447
return n
449448
}

src/cmd/compile/internal/gc/closure.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func typecheckclosure(func_ *Node, top int) {
111111
Curfn = func_
112112
olddd := decldepth
113113
decldepth = 1
114-
typechecklist(func_.Nbody, Etop)
114+
typechecklist(func_.Nbody.Slice(), Etop)
115115
decldepth = olddd
116116
Curfn = oldfn
117117
}

src/cmd/compile/internal/gc/dcl.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList {
297297
lastconst = cl
298298
lasttype = t
299299
}
300-
clcopy := listtreecopy(cl, lno)
300+
clcopy := listtreecopy(nodeSeqSlice(cl), lno)
301301

302302
var v *Node
303303
var c *Node
@@ -437,7 +437,7 @@ func colasname(n *Node) bool {
437437
return false
438438
}
439439

440-
func colasdefn(left nodesOrNodeList, defn *Node) {
440+
func colasdefn(left Nodes, defn *Node) {
441441
for it := nodeSeqIterate(left); !it.Done(); it.Next() {
442442
if it.N().Sym != nil {
443443
it.N().Sym.Flags |= SymUniq
@@ -828,13 +828,13 @@ func checkdupfields(t *Type, what string) {
828828

829829
// convert a parsed id/type list into
830830
// a type for struct/interface/arglist
831-
func tostruct(l nodesOrNodeList) *Type {
831+
func tostruct(l []*Node) *Type {
832832
t := typ(TSTRUCT)
833833
tostruct0(t, l)
834834
return t
835835
}
836836

837-
func tostruct0(t *Type, l nodesOrNodeList) {
837+
func tostruct0(t *Type, l []*Node) {
838838
if t == nil || t.Etype != TSTRUCT {
839839
Fatalf("struct expected")
840840
}
@@ -860,7 +860,7 @@ func tostruct0(t *Type, l nodesOrNodeList) {
860860
}
861861
}
862862

863-
func tofunargs(l nodesOrNodeList) *Type {
863+
func tofunargs(l []*Node) *Type {
864864
var f *Type
865865

866866
t := typ(TSTRUCT)
@@ -955,13 +955,13 @@ func interfacefield(n *Node) *Type {
955955
return f
956956
}
957957

958-
func tointerface(l nodesOrNodeList) *Type {
958+
func tointerface(l []*Node) *Type {
959959
t := typ(TINTER)
960960
tointerface0(t, l)
961961
return t
962962
}
963963

964-
func tointerface0(t *Type, l nodesOrNodeList) *Type {
964+
func tointerface0(t *Type, l []*Node) *Type {
965965
if t == nil || t.Etype != TINTER {
966966
Fatalf("interface expected")
967967
}
@@ -1155,20 +1155,20 @@ func isifacemethod(f *Type) bool {
11551155
}
11561156

11571157
// turn a parsed function declaration into a type
1158-
func functype(this *Node, in nodesOrNodeList, out nodesOrNodeList) *Type {
1158+
func functype(this *Node, in, out []*Node) *Type {
11591159
t := typ(TFUNC)
11601160
functype0(t, this, in, out)
11611161
return t
11621162
}
11631163

1164-
func functype0(t *Type, this *Node, in nodesOrNodeList, out nodesOrNodeList) {
1164+
func functype0(t *Type, this *Node, in, out []*Node) {
11651165
if t == nil || t.Etype != TFUNC {
11661166
Fatalf("function type expected")
11671167
}
11681168

1169-
var rcvr *NodeList
1169+
var rcvr []*Node
11701170
if this != nil {
1171-
rcvr = list1(this)
1171+
rcvr = []*Node{this}
11721172
}
11731173
t.Type = tofunargs(rcvr)
11741174
t.Type.Down = tofunargs(out)
@@ -1538,7 +1538,7 @@ func checknowritebarrierrec() {
15381538
})
15391539
}
15401540

1541-
func (c *nowritebarrierrecChecker) visitcodelist(l nodesOrNodeList) {
1541+
func (c *nowritebarrierrecChecker) visitcodelist(l Nodes) {
15421542
for it := nodeSeqIterate(l); !it.Done(); it.Next() {
15431543
c.visitcode(it.N())
15441544
}

src/cmd/compile/internal/gc/esc.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 {
110110
return min
111111
}
112112

113-
func (v *bottomUpVisitor) visitcodelist(l nodesOrNodeList, min uint32) uint32 {
113+
func (v *bottomUpVisitor) visitcodelist(l Nodes, min uint32) uint32 {
114114
for it := nodeSeqIterate(l); !it.Done(); it.Next() {
115115
min = v.visitcode(it.N(), min)
116116
}
@@ -300,9 +300,9 @@ func (l Level) guaranteedDereference() int {
300300

301301
type NodeEscState struct {
302302
Curfn *Node
303-
Escflowsrc []*Node // flow(this, src)
304-
Escretval *NodeList // on OCALLxxx, list of dummy return values
305-
Escloopdepth int32 // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes
303+
Escflowsrc []*Node // flow(this, src)
304+
Escretval Nodes // on OCALLxxx, list of dummy return values
305+
Escloopdepth int32 // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes
306306
Esclevel Level
307307
Walkgen uint32
308308
Maxextraloopdepth int32
@@ -522,7 +522,7 @@ var looping Label
522522

523523
var nonlooping Label
524524

525-
func escloopdepthlist(e *EscState, l nodesOrNodeList) {
525+
func escloopdepthlist(e *EscState, l Nodes) {
526526
for it := nodeSeqIterate(l); !it.Done(); it.Next() {
527527
escloopdepth(e, it.N())
528528
}
@@ -566,7 +566,7 @@ func escloopdepth(e *EscState, n *Node) {
566566
escloopdepthlist(e, n.Rlist)
567567
}
568568

569-
func esclist(e *EscState, l nodesOrNodeList, up *Node) {
569+
func esclist(e *EscState, l Nodes, up *Node) {
570570
for it := nodeSeqIterate(l); !it.Done(); it.Next() {
571571
esc(e, it.N(), up)
572572
}
@@ -771,7 +771,7 @@ func esc(e *EscState, n *Node, up *Node) {
771771
}
772772

773773
case ORETURN:
774-
ll := nodesOrNodeList(n.List)
774+
ll := n.List
775775
if nodeSeqLen(n.List) == 1 && Curfn.Type.Outtuple > 1 {
776776
// OAS2FUNC in disguise
777777
// esccall already done on n->list->n
@@ -1204,7 +1204,7 @@ func describeEscape(em uint16) string {
12041204

12051205
// escassignfromtag models the input-to-output assignment flow of one of a function
12061206
// calls arguments, where the flow is encoded in "note".
1207-
func escassignfromtag(e *EscState, note *string, dsts nodesOrNodeList, src *Node) uint16 {
1207+
func escassignfromtag(e *EscState, note *string, dsts Nodes, src *Node) uint16 {
12081208
em := parsetag(note)
12091209
if src.Op == OLITERAL {
12101210
return em
@@ -1320,7 +1320,7 @@ func escNoteOutputParamFlow(e uint16, vargen int32, level Level) uint16 {
13201320
func initEscretval(e *EscState, n *Node, fntype *Type) {
13211321
i := 0
13221322
nE := e.nodeEscState(n)
1323-
setNodeSeq(&nE.Escretval, nil) // Suspect this is not nil for indirect calls.
1323+
nE.Escretval.Set(nil) // Suspect this is not nil for indirect calls.
13241324
for t := getoutargx(fntype).Type; t != nil; t = t.Down {
13251325
src := Nod(ONAME, nil, nil)
13261326
buf := fmt.Sprintf(".out%d", i)
@@ -1332,7 +1332,7 @@ func initEscretval(e *EscState, n *Node, fntype *Type) {
13321332
e.nodeEscState(src).Escloopdepth = e.loopdepth
13331333
src.Used = true
13341334
src.Lineno = n.Lineno
1335-
appendNodeSeqNode(&nE.Escretval, src)
1335+
nE.Escretval.Append(src)
13361336
}
13371337
}
13381338

@@ -1368,7 +1368,7 @@ func esccall(e *EscState, n *Node, up *Node) {
13681368
indirect = true
13691369
}
13701370

1371-
ll := nodesOrNodeList(n.List)
1371+
ll := n.List
13721372
if nodeSeqLen(n.List) == 1 {
13731373
a := nodeSeqFirst(n.List)
13741374
if a.Type.Etype == TSTRUCT && a.Type.Funarg { // f(g()).

src/cmd/compile/internal/gc/export.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func dumppkg(p *Pkg) {
106106
}
107107

108108
// Look for anything we need for the inline body
109-
func reexportdeplist(ll nodesOrNodeList) {
109+
func reexportdeplist(ll Nodes) {
110110
for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
111111
reexportdep(it.N())
112112
}

src/cmd/compile/internal/gc/fmt.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,9 @@ func Nconv(n *Node, flag int) string {
16991699
}
17001700

17011701
func (l *NodeList) String() string {
1702-
return Hconv(l, 0)
1702+
var n Nodes
1703+
n.Set(nodeSeqSlice(l))
1704+
return Hconv(n, 0)
17031705
}
17041706

17051707
func (n Nodes) String() string {
@@ -1708,7 +1710,7 @@ func (n Nodes) String() string {
17081710

17091711
// Fmt '%H': NodeList.
17101712
// Flags: all those of %N plus ',': separate with comma's instead of semicolons.
1711-
func Hconv(l nodesOrNodeList, flag int) string {
1713+
func Hconv(l Nodes, flag int) string {
17121714
if nodeSeqLen(l) == 0 && fmtmode == FDbg {
17131715
return "<nil>"
17141716
}
@@ -1736,7 +1738,7 @@ func Hconv(l nodesOrNodeList, flag int) string {
17361738
return buf.String()
17371739
}
17381740

1739-
func dumplist(s string, l nodesOrNodeList) {
1741+
func dumplist(s string, l Nodes) {
17401742
fmt.Printf("%s%v\n", s, Hconv(l, obj.FmtSign))
17411743
}
17421744

src/cmd/compile/internal/gc/gen.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func stmtlabel(n *Node) *Label {
215215
}
216216

217217
// compile statements
218-
func Genlist(l nodesOrNodeList) {
218+
func Genlist(l Nodes) {
219219
for it := nodeSeqIterate(l); !it.Done(); it.Next() {
220220
gen(it.N())
221221
}
@@ -440,7 +440,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) {
440440
r1.Type = byteptr
441441
r2.Type = byteptr
442442
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
443-
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List, 0, nil))
443+
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List.Slice(), 0, nil))
444444
gen(call)
445445
Regfree(&r1)
446446
Regfree(&r2)
@@ -526,7 +526,7 @@ func Cgen_As2dottype(n, res, resok *Node) {
526526
dowidth(fn.Type)
527527
call := Nod(OCALLFUNC, fn, nil)
528528
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
529-
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List, 0, nil))
529+
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List.Slice(), 0, nil))
530530
gen(call)
531531
Regfree(&r1)
532532
Regfree(&r2)

src/cmd/compile/internal/gc/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func fninit(n *NodeList) {
9494
return
9595
}
9696

97-
nf := initfix(n)
97+
nf := initfix(nodeSeqSlice(n))
9898
if !anyinit(nf) {
9999
return
100100
}

0 commit comments

Comments
 (0)