Commit e28a890d authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/compile: remove nodesOrNodeListPtr outside of syntax.go

Passes toolstash -cmp.

Update #14473.

Change-Id: I2620374b79c61b1e48467b98afe2d7d3beef878b
Reviewed-on: https://go-review.googlesource.com/20354Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent beabd872
...@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) { ...@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) {
if len(body) > 0 { if len(body) > 0 {
typecheckslice(body, Etop) typecheckslice(body, Etop)
walkstmtslice(body) walkstmtlist(body)
xfunc.Func.Enter.Set(body) xfunc.Func.Enter.Set(body)
xfunc.Func.Needctxt = true xfunc.Func.Needctxt = true
} }
...@@ -404,7 +404,7 @@ func transformclosure(xfunc *Node) { ...@@ -404,7 +404,7 @@ func transformclosure(xfunc *Node) {
lineno = lno lineno = lno
} }
func walkclosure(func_ *Node, init nodesOrNodeListPtr) *Node { func walkclosure(func_ *Node, init *Nodes) *Node {
// If no closure vars, don't bother wrapping. // If no closure vars, don't bother wrapping.
if len(func_.Func.Cvars.Slice()) == 0 { if len(func_.Func.Cvars.Slice()) == 0 {
return func_.Func.Closure.Func.Nname return func_.Func.Closure.Func.Nname
...@@ -623,7 +623,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -623,7 +623,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
return xfunc return xfunc
} }
func walkpartialcall(n *Node, init nodesOrNodeListPtr) *Node { func walkpartialcall(n *Node, init *Nodes) *Node {
// Create closure in the form of a composite literal. // Create closure in the form of a composite literal.
// For x.M with receiver (x) type T, the generated code looks like: // For x.M with receiver (x) type T, the generated code looks like:
// //
......
...@@ -86,16 +86,14 @@ func instrument(fn *Node) { ...@@ -86,16 +86,14 @@ func instrument(fn *Node) {
} }
} }
func instrumentlist(l nodesOrNodeList, init nodesOrNodeListPtr) { func instrumentlist(l nodesOrNodeList, init *Nodes) {
var instr *NodeList
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
instr = nil var instr Nodes
instrumentnode(it.P(), &instr, 0, 0) instrumentnode(it.P(), &instr, 0, 0)
if init == nil { if init == nil {
appendNodeSeq(&it.N().Ninit, instr) it.N().Ninit.AppendNodes(&instr)
} else { } else {
appendNodeSeq(init, instr) init.AppendNodes(&instr)
} }
} }
} }
...@@ -103,7 +101,7 @@ func instrumentlist(l nodesOrNodeList, init nodesOrNodeListPtr) { ...@@ -103,7 +101,7 @@ func instrumentlist(l nodesOrNodeList, init nodesOrNodeListPtr) {
// walkexpr and walkstmt combined // walkexpr and walkstmt combined
// walks the tree and adds calls to the // walks the tree and adds calls to the
// instrumentation code to top-level (statement) nodes' init // instrumentation code to top-level (statement) nodes' init
func instrumentnode(np **Node, init nodesOrNodeListPtr, wr int, skip int) { func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
n := *np n := *np
if n == nil { if n == nil {
...@@ -163,8 +161,10 @@ func instrumentnode(np **Node, init nodesOrNodeListPtr, wr int, skip int) { ...@@ -163,8 +161,10 @@ func instrumentnode(np **Node, init nodesOrNodeListPtr, wr int, skip int) {
out = append(out, it.N()) out = append(out, it.N())
} }
default: default:
instrumentnode(it.P(), &out, 0, 0) var outn Nodes
out = append(out, it.N()) outn.Set(out)
instrumentnode(it.P(), &outn, 0, 0)
out = append(outn.Slice(), it.N())
} }
} }
setNodeSeq(&n.List, out) setNodeSeq(&n.List, out)
...@@ -460,7 +460,7 @@ func isartificial(n *Node) bool { ...@@ -460,7 +460,7 @@ func isartificial(n *Node) bool {
return false return false
} }
func callinstr(np **Node, init nodesOrNodeListPtr, wr int, skip int) bool { func callinstr(np **Node, init *Nodes, wr int, skip int) bool {
n := *np n := *np
//print("callinstr for %+N [ %O ] etype=%E class=%d\n", //print("callinstr for %+N [ %O ] etype=%E class=%d\n",
...@@ -529,7 +529,7 @@ func callinstr(np **Node, init nodesOrNodeListPtr, wr int, skip int) bool { ...@@ -529,7 +529,7 @@ func callinstr(np **Node, init nodesOrNodeListPtr, wr int, skip int) bool {
f = mkcall(name, nil, init, uintptraddr(n)) f = mkcall(name, nil, init, uintptraddr(n))
} }
appendNodeSeqNode(init, f) init.Append(f)
return true return true
} }
...@@ -575,13 +575,13 @@ func uintptraddr(n *Node) *Node { ...@@ -575,13 +575,13 @@ func uintptraddr(n *Node) *Node {
return r return r
} }
func detachexpr(n *Node, init nodesOrNodeListPtr) *Node { func detachexpr(n *Node, init *Nodes) *Node {
addr := Nod(OADDR, n, nil) addr := Nod(OADDR, n, nil)
l := temp(Ptrto(n.Type)) l := temp(Ptrto(n.Type))
as := Nod(OAS, l, addr) as := Nod(OAS, l, addr)
typecheck(&as, Etop) typecheck(&as, Etop)
walkexpr(&as, init) walkexpr(&as, init)
appendNodeSeqNode(init, as) init.Append(as)
ind := Nod(OIND, l, nil) ind := Nod(OIND, l, nil)
typecheck(&ind, Erv) typecheck(&ind, Erv)
walkexpr(&ind, init) walkexpr(&ind, init)
......
...@@ -156,7 +156,10 @@ func walkselect(sel *Node) { ...@@ -156,7 +156,10 @@ func walkselect(sel *Node) {
a := Nod(OIF, nil, nil) a := Nod(OIF, nil, nil)
a.Left = Nod(OEQ, ch, nodnil()) a.Left = Nod(OEQ, ch, nodnil())
a.Nbody.Set([]*Node{mkcall("block", nil, &l)}) var ln Nodes
ln.Set(l)
a.Nbody.Set([]*Node{mkcall("block", nil, &ln)})
l = ln.Slice()
typecheck(&a, Etop) typecheck(&a, Etop)
l = append(l, a) l = append(l, a)
l = append(l, n) l = append(l, n)
...@@ -303,7 +306,7 @@ func walkselect(sel *Node) { ...@@ -303,7 +306,7 @@ func walkselect(sel *Node) {
// selv is no longer alive after use. // selv is no longer alive after use.
r.Nbody.Append(Nod(OVARKILL, selv, nil)) r.Nbody.Append(Nod(OVARKILL, selv, nil))
r.Nbody.Append(cas.Nbody.Slice()...) r.Nbody.AppendNodes(&cas.Nbody)
r.Nbody.Append(Nod(OBREAK, nil, nil)) r.Nbody.Append(Nod(OBREAK, nil, nil))
init = append(init, r) init = append(init, r)
} }
...@@ -316,7 +319,7 @@ func walkselect(sel *Node) { ...@@ -316,7 +319,7 @@ func walkselect(sel *Node) {
out: out:
setNodeSeq(&sel.List, nil) setNodeSeq(&sel.List, nil)
walkstmtlist(sel.Nbody) walkstmtlist(sel.Nbody.Slice())
lineno = lno lineno = lno
} }
......
...@@ -528,11 +528,11 @@ func simplename(n *Node) bool { ...@@ -528,11 +528,11 @@ func simplename(n *Node) bool {
return true return true
} }
func litas(l *Node, r *Node, init nodesOrNodeListPtr) { func litas(l *Node, r *Node, init *Nodes) {
a := Nod(OAS, l, r) a := Nod(OAS, l, r)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
} }
const ( const (
...@@ -570,7 +570,7 @@ func getdyn(n *Node, top int) int { ...@@ -570,7 +570,7 @@ func getdyn(n *Node, top int) int {
return mode return mode
} }
func structlit(ctxt int, pass int, n *Node, var_ *Node, init nodesOrNodeListPtr) { func structlit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
r := it.N() r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
...@@ -631,11 +631,11 @@ func structlit(ctxt int, pass int, n *Node, var_ *Node, init nodesOrNodeListPtr) ...@@ -631,11 +631,11 @@ func structlit(ctxt int, pass int, n *Node, var_ *Node, init nodesOrNodeListPtr)
walkstmt(&a) walkstmt(&a)
} }
appendNodeSeqNode(init, a) init.Append(a)
} }
} }
func arraylit(ctxt int, pass int, n *Node, var_ *Node, init nodesOrNodeListPtr) { func arraylit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
r := it.N() r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
...@@ -696,11 +696,11 @@ func arraylit(ctxt int, pass int, n *Node, var_ *Node, init nodesOrNodeListPtr) ...@@ -696,11 +696,11 @@ func arraylit(ctxt int, pass int, n *Node, var_ *Node, init nodesOrNodeListPtr)
walkstmt(&a) walkstmt(&a)
} }
appendNodeSeqNode(init, a) init.Append(a)
} }
} }
func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
// make an array type // make an array type
t := shallow(n.Type) t := shallow(n.Type)
...@@ -723,7 +723,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -723,7 +723,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a = Nod(OAS, var_, a) a = Nod(OAS, var_, a)
typecheck(&a, Etop) typecheck(&a, Etop)
a.Dodata = 2 a.Dodata = 2
appendNodeSeqNode(init, a) init.Append(a)
return return
} }
...@@ -768,7 +768,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -768,7 +768,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
if vstat == nil { if vstat == nil {
a = Nod(OAS, x, nil) a = Nod(OAS, x, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
appendNodeSeqNode(init, a) // zero new temp init.Append(a) // zero new temp
} }
a = Nod(OADDR, x, nil) a = Nod(OADDR, x, nil)
...@@ -777,7 +777,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -777,7 +777,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
if vstat == nil { if vstat == nil {
a = Nod(OAS, temp(t), nil) a = Nod(OAS, temp(t), nil)
typecheck(&a, Etop) typecheck(&a, Etop)
appendNodeSeqNode(init, a) // zero new temp init.Append(a) // zero new temp
a = a.Left a = a.Left
} }
...@@ -790,7 +790,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -790,7 +790,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a = Nod(OAS, vauto, a) a = Nod(OAS, vauto, a)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
if vstat != nil { if vstat != nil {
// copy static to heap (4) // copy static to heap (4)
...@@ -799,7 +799,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -799,7 +799,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a = Nod(OAS, a, vstat) a = Nod(OAS, a, vstat)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
} }
// make slice out of heap (5) // make slice out of heap (5)
...@@ -808,7 +808,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -808,7 +808,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
orderstmtinplace(&a) orderstmtinplace(&a)
walkstmt(&a) walkstmt(&a)
appendNodeSeqNode(init, a) init.Append(a)
// put dynamics into slice (6) // put dynamics into slice (6)
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
...@@ -847,11 +847,11 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -847,11 +847,11 @@ func slicelit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
orderstmtinplace(&a) orderstmtinplace(&a)
walkstmt(&a) walkstmt(&a)
appendNodeSeqNode(init, a) init.Append(a)
} }
} }
func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) {
ctxt = 0 ctxt = 0
// make the map var // make the map var
...@@ -927,7 +927,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -927,7 +927,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
a.Dodata = 2 a.Dodata = 2
appendNodeSeqNode(init, a) init.Append(a)
// build vstat[b].b = value; // build vstat[b].b = value;
setlineno(value) setlineno(value)
...@@ -939,7 +939,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -939,7 +939,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
a.Dodata = 2 a.Dodata = 2
appendNodeSeqNode(init, a) init.Append(a)
b++ b++
} }
...@@ -971,7 +971,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -971,7 +971,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
walkstmt(&a) walkstmt(&a)
appendNodeSeqNode(init, a) init.Append(a)
} }
// put in dynamic entries one-at-a-time // put in dynamic entries one-at-a-time
...@@ -1000,18 +1000,18 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1000,18 +1000,18 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a = Nod(OAS, key, r.Left) a = Nod(OAS, key, r.Left)
typecheck(&a, Etop) typecheck(&a, Etop)
walkstmt(&a) walkstmt(&a)
appendNodeSeqNode(init, a) init.Append(a)
setlineno(r.Right) setlineno(r.Right)
a = Nod(OAS, val, r.Right) a = Nod(OAS, val, r.Right)
typecheck(&a, Etop) typecheck(&a, Etop)
walkstmt(&a) walkstmt(&a)
appendNodeSeqNode(init, a) init.Append(a)
setlineno(val) setlineno(val)
a = Nod(OAS, Nod(OINDEX, var_, key), val) a = Nod(OAS, Nod(OINDEX, var_, key), val)
typecheck(&a, Etop) typecheck(&a, Etop)
walkstmt(&a) walkstmt(&a)
appendNodeSeqNode(init, a) init.Append(a)
if nerr != nerrors { if nerr != nerrors {
break break
...@@ -1021,14 +1021,14 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1021,14 +1021,14 @@ func maplit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
if key != nil { if key != nil {
a = Nod(OVARKILL, key, nil) a = Nod(OVARKILL, key, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
appendNodeSeqNode(init, a) init.Append(a)
a = Nod(OVARKILL, val, nil) a = Nod(OVARKILL, val, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
appendNodeSeqNode(init, a) init.Append(a)
} }
} }
func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) {
t := n.Type t := n.Type
switch n.Op { switch n.Op {
default: default:
...@@ -1054,7 +1054,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1054,7 +1054,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a := Nod(OAS, var_, r) a := Nod(OAS, var_, r)
typecheck(&a, Etop) typecheck(&a, Etop)
appendNodeSeqNode(init, a) init.Append(a)
var_ = Nod(OIND, var_, nil) var_ = Nod(OIND, var_, nil)
typecheck(&var_, Erv|Easgn) typecheck(&var_, Erv|Easgn)
...@@ -1077,7 +1077,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1077,7 +1077,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
// add expressions to automatic // add expressions to automatic
structlit(ctxt, 2, n, var_, init) structlit(ctxt, 2, n, var_, init)
...@@ -1095,7 +1095,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1095,7 +1095,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a := Nod(OAS, var_, nil) a := Nod(OAS, var_, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
} }
structlit(ctxt, 3, n, var_, init) structlit(ctxt, 3, n, var_, init)
...@@ -1121,7 +1121,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1121,7 +1121,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
// add expressions to automatic // add expressions to automatic
arraylit(ctxt, 2, n, var_, init) arraylit(ctxt, 2, n, var_, init)
...@@ -1139,7 +1139,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1139,7 +1139,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
a := Nod(OAS, var_, nil) a := Nod(OAS, var_, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
} }
arraylit(ctxt, 3, n, var_, init) arraylit(ctxt, 3, n, var_, init)
...@@ -1152,7 +1152,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) { ...@@ -1152,7 +1152,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init nodesOrNodeListPtr) {
} }
} }
func oaslit(n *Node, init nodesOrNodeListPtr) bool { func oaslit(n *Node, init *Nodes) bool {
if n.Left == nil || n.Right == nil { if n.Left == nil || n.Right == nil {
// not a special composit literal assignment // not a special composit literal assignment
return false return false
......
...@@ -1628,15 +1628,14 @@ func Brrev(op Op) Op { ...@@ -1628,15 +1628,14 @@ func Brrev(op Op) Op {
// return side effect-free n, appending side effects to init. // return side effect-free n, appending side effects to init.
// result is assignable if n is. // result is assignable if n is.
func safeexpr(n *Node, init nodesOrNodeListPtr) *Node { func safeexpr(n *Node, init *Nodes) *Node {
if n == nil { if n == nil {
return nil return nil
} }
if nodeSeqLen(n.Ninit) != 0 { if nodeSeqLen(n.Ninit) != 0 {
walkstmtlist(n.Ninit) walkstmtlist(n.Ninit.Slice())
appendNodeSeq(init, n.Ninit) init.AppendNodes(&n.Ninit)
setNodeSeq(&n.Ninit, nil)
} }
switch n.Op { switch n.Op {
...@@ -1687,18 +1686,18 @@ func safeexpr(n *Node, init nodesOrNodeListPtr) *Node { ...@@ -1687,18 +1686,18 @@ func safeexpr(n *Node, init nodesOrNodeListPtr) *Node {
return cheapexpr(n, init) return cheapexpr(n, init)
} }
func copyexpr(n *Node, t *Type, init nodesOrNodeListPtr) *Node { func copyexpr(n *Node, t *Type, init *Nodes) *Node {
l := temp(t) l := temp(t)
a := Nod(OAS, l, n) a := Nod(OAS, l, n)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
appendNodeSeqNode(init, a) init.Append(a)
return l return l
} }
// return side-effect free and cheap n, appending side effects to init. // return side-effect free and cheap n, appending side effects to init.
// result may not be assignable. // result may not be assignable.
func cheapexpr(n *Node, init nodesOrNodeListPtr) *Node { func cheapexpr(n *Node, init *Nodes) *Node {
switch n.Op { switch n.Op {
case ONAME, OLITERAL: case ONAME, OLITERAL:
return n return n
...@@ -2765,7 +2764,7 @@ func isbadimport(path string) bool { ...@@ -2765,7 +2764,7 @@ func isbadimport(path string) bool {
return false return false
} }
func checknil(x *Node, init nodesOrNodeListPtr) { func checknil(x *Node, init *Nodes) {
if Isinter(x.Type) { if Isinter(x.Type) {
x = Nod(OITAB, x, nil) x = Nod(OITAB, x, nil)
typecheck(&x, Erv) typecheck(&x, Erv)
...@@ -2773,7 +2772,7 @@ func checknil(x *Node, init nodesOrNodeListPtr) { ...@@ -2773,7 +2772,7 @@ func checknil(x *Node, init nodesOrNodeListPtr) {
n := Nod(OCHECKNIL, x, nil) n := Nod(OCHECKNIL, x, nil)
n.Typecheck = 1 n.Typecheck = 1
appendNodeSeqNode(init, n) init.Append(n)
} }
// Can this type be stored directly in an interface word? // Can this type be stored directly in an interface word?
......
...@@ -279,7 +279,7 @@ func (s *exprSwitch) walk(sw *Node) { ...@@ -279,7 +279,7 @@ func (s *exprSwitch) walk(sw *Node) {
if nerrors == 0 { if nerrors == 0 {
cas = append(cas, def) cas = append(cas, def)
sw.Nbody.Set(append(cas, sw.Nbody.Slice()...)) sw.Nbody.Set(append(cas, sw.Nbody.Slice()...))
walkstmtlist(sw.Nbody) walkstmtlist(sw.Nbody.Slice())
} }
} }
...@@ -670,7 +670,7 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -670,7 +670,7 @@ func (s *typeSwitch) walk(sw *Node) {
cas = append(cas, def) cas = append(cas, def)
sw.Nbody.Set(append(cas, sw.Nbody.Slice()...)) sw.Nbody.Set(append(cas, sw.Nbody.Slice()...))
setNodeSeq(&sw.List, nil) setNodeSeq(&sw.List, nil)
walkstmtlist(sw.Nbody) walkstmtlist(sw.Nbody.Slice())
} }
} }
......
...@@ -466,6 +466,18 @@ func (n *Nodes) Append(a ...*Node) { ...@@ -466,6 +466,18 @@ func (n *Nodes) Append(a ...*Node) {
} }
} }
// AppendNodes appends the contents of *n2 to n, then clears n2.
func (n *Nodes) AppendNodes(n2 *Nodes) {
switch {
case n2.slice == nil:
case n.slice == nil:
n.slice = n2.slice
default:
*n.slice = append(*n.slice, *n2.slice...)
}
n2.slice = nil
}
// SetToNodeList sets Nodes to the contents of a NodeList. // SetToNodeList sets Nodes to the contents of a NodeList.
func (n *Nodes) SetToNodeList(l *NodeList) { func (n *Nodes) SetToNodeList(l *NodeList) {
s := make([]*Node, 0, count(l)) s := make([]*Node, 0, count(l))
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment