Commit 38921b36 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/compile: rewrite code to omit many nodeSeq calls

This CL was automatically generated using a special-purpose AST
rewriting tool, followed by manual editing to put some comments back in
the right places and fix some bad line breaks.

The result is not perfect but it's a big step toward getting back to
sanity, and because it was automatically generated there is a decent
chance that it is correct.

Passes toolstash -cmp.

Update #14473.

Change-Id: I01c09078a6d78e2b008bc304d744b79469a38d3d
Reviewed-on: https://go-review.googlesource.com/20440Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent db506fe9
...@@ -185,13 +185,13 @@ func genhash(sym *Sym, t *Type) { ...@@ -185,13 +185,13 @@ func genhash(sym *Sym, t *Type) {
fn.Func.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t))) n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
appendNodeSeqNode(&tfn.List, n) tfn.List.Append(n)
np := n.Left np := n.Left
n = Nod(ODCLFIELD, newname(Lookup("h")), typenod(Types[TUINTPTR])) n = Nod(ODCLFIELD, newname(Lookup("h")), typenod(Types[TUINTPTR]))
appendNodeSeqNode(&tfn.List, n) tfn.List.Append(n)
nh := n.Left nh := n.Left
n = Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])) // return value n = Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])) // return value
appendNodeSeqNode(&tfn.Rlist, n) tfn.Rlist.Append(n)
funchdr(fn) funchdr(fn)
typecheck(&fn.Func.Nname.Name.Param.Ntype, Etype) typecheck(&fn.Func.Nname.Name.Param.Ntype, Etype)
...@@ -216,10 +216,10 @@ func genhash(sym *Sym, t *Type) { ...@@ -216,10 +216,10 @@ func genhash(sym *Sym, t *Type) {
n := Nod(ORANGE, nil, Nod(OIND, np, nil)) n := Nod(ORANGE, nil, Nod(OIND, np, nil))
ni := newname(Lookup("i")) ni := newname(Lookup("i"))
ni.Type = Types[TINT] ni.Type = Types[TINT]
setNodeSeq(&n.List, []*Node{ni}) n.List.Set([]*Node{ni})
n.Colas = true n.Colas = true
colasdefn(n.List, n) colasdefn(n.List, n)
ni = nodeSeqFirst(n.List) ni = n.List.First()
// h = hashel(&p[i], h) // h = hashel(&p[i], h)
call := Nod(OCALL, hashel, nil) call := Nod(OCALL, hashel, nil)
...@@ -228,8 +228,8 @@ func genhash(sym *Sym, t *Type) { ...@@ -228,8 +228,8 @@ func genhash(sym *Sym, t *Type) {
nx.Bounded = true nx.Bounded = true
na := Nod(OADDR, nx, nil) na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap na.Etype = 1 // no escape to heap
appendNodeSeqNode(&call.List, na) call.List.Append(na)
appendNodeSeqNode(&call.List, nh) call.List.Append(nh)
n.Nbody.Append(Nod(OAS, nh, call)) n.Nbody.Append(Nod(OAS, nh, call))
fn.Nbody.Append(n) fn.Nbody.Append(n)
...@@ -251,8 +251,8 @@ func genhash(sym *Sym, t *Type) { ...@@ -251,8 +251,8 @@ func genhash(sym *Sym, t *Type) {
nx := Nod(OXDOT, np, newname(f.Sym)) // TODO: fields from other packages? nx := Nod(OXDOT, np, newname(f.Sym)) // TODO: fields from other packages?
na := Nod(OADDR, nx, nil) na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap na.Etype = 1 // no escape to heap
appendNodeSeqNode(&call.List, na) call.List.Append(na)
appendNodeSeqNode(&call.List, nh) call.List.Append(nh)
fn.Nbody.Append(Nod(OAS, nh, call)) fn.Nbody.Append(Nod(OAS, nh, call))
f = f.Down f = f.Down
continue continue
...@@ -267,9 +267,9 @@ func genhash(sym *Sym, t *Type) { ...@@ -267,9 +267,9 @@ func genhash(sym *Sym, t *Type) {
nx := Nod(OXDOT, np, newname(f.Sym)) // TODO: fields from other packages? nx := Nod(OXDOT, np, newname(f.Sym)) // TODO: fields from other packages?
na := Nod(OADDR, nx, nil) na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap na.Etype = 1 // no escape to heap
appendNodeSeqNode(&call.List, na) call.List.Append(na)
appendNodeSeqNode(&call.List, nh) call.List.Append(nh)
appendNodeSeqNode(&call.List, Nodintconst(size)) call.List.Append(Nodintconst(size))
fn.Nbody.Append(Nod(OAS, nh, call)) fn.Nbody.Append(Nod(OAS, nh, call))
f = next f = next
...@@ -277,7 +277,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -277,7 +277,7 @@ func genhash(sym *Sym, t *Type) {
} }
r := Nod(ORETURN, nil, nil) r := Nod(ORETURN, nil, nil)
appendNodeSeqNode(&r.List, nh) r.List.Append(nh)
fn.Nbody.Append(r) fn.Nbody.Append(r)
if Debug['r'] != 0 { if Debug['r'] != 0 {
...@@ -339,9 +339,9 @@ func hashfor(t *Type) *Node { ...@@ -339,9 +339,9 @@ func hashfor(t *Type) *Node {
n := newname(sym) n := newname(sym)
n.Class = PFUNC n.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t)))) tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
appendNodeSeqNode(&tfn.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
typecheck(&tfn, Etype) typecheck(&tfn, Etype)
n.Type = tfn.Type n.Type = tfn.Type
return n return n
...@@ -367,13 +367,13 @@ func geneq(sym *Sym, t *Type) { ...@@ -367,13 +367,13 @@ func geneq(sym *Sym, t *Type) {
fn.Func.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t))) n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
appendNodeSeqNode(&tfn.List, n) tfn.List.Append(n)
np := n.Left np := n.Left
n = Nod(ODCLFIELD, newname(Lookup("q")), typenod(Ptrto(t))) n = Nod(ODCLFIELD, newname(Lookup("q")), typenod(Ptrto(t)))
appendNodeSeqNode(&tfn.List, n) tfn.List.Append(n)
nq := n.Left nq := n.Left
n = Nod(ODCLFIELD, nil, typenod(Types[TBOOL])) n = Nod(ODCLFIELD, nil, typenod(Types[TBOOL]))
appendNodeSeqNode(&tfn.Rlist, n) tfn.Rlist.Append(n)
funchdr(fn) funchdr(fn)
...@@ -398,10 +398,10 @@ func geneq(sym *Sym, t *Type) { ...@@ -398,10 +398,10 @@ func geneq(sym *Sym, t *Type) {
ni := newname(Lookup("i")) ni := newname(Lookup("i"))
ni.Type = Types[TINT] ni.Type = Types[TINT]
setNodeSeq(&nrange.List, []*Node{ni}) nrange.List.Set([]*Node{ni})
nrange.Colas = true nrange.Colas = true
colasdefn(nrange.List, nrange) colasdefn(nrange.List, nrange)
ni = nodeSeqFirst(nrange.List) ni = nrange.List.First()
// if p[i] != q[i] { return false } // if p[i] != q[i] { return false }
nx := Nod(OINDEX, np, ni) nx := Nod(OINDEX, np, ni)
...@@ -413,14 +413,14 @@ func geneq(sym *Sym, t *Type) { ...@@ -413,14 +413,14 @@ func geneq(sym *Sym, t *Type) {
nif := Nod(OIF, nil, nil) nif := Nod(OIF, nil, nil)
nif.Left = Nod(ONE, nx, ny) nif.Left = Nod(ONE, nx, ny)
r := Nod(ORETURN, nil, nil) r := Nod(ORETURN, nil, nil)
appendNodeSeqNode(&r.List, Nodbool(false)) r.List.Append(Nodbool(false))
nif.Nbody.Append(r) nif.Nbody.Append(r)
nrange.Nbody.Append(nif) nrange.Nbody.Append(nif)
fn.Nbody.Append(nrange) fn.Nbody.Append(nrange)
// return true // return true
ret := Nod(ORETURN, nil, nil) ret := Nod(ORETURN, nil, nil)
appendNodeSeqNode(&ret.List, Nodbool(true)) ret.List.Append(Nodbool(true))
fn.Nbody.Append(ret) fn.Nbody.Append(ret)
case TSTRUCT: case TSTRUCT:
...@@ -474,7 +474,7 @@ func geneq(sym *Sym, t *Type) { ...@@ -474,7 +474,7 @@ func geneq(sym *Sym, t *Type) {
} }
ret := Nod(ORETURN, nil, nil) ret := Nod(ORETURN, nil, nil)
appendNodeSeqNode(&ret.List, and) ret.List.Append(and)
fn.Nbody.Append(ret) fn.Nbody.Append(ret)
} }
...@@ -531,10 +531,10 @@ func eqmem(p *Node, q *Node, field *Node, size int64) *Node { ...@@ -531,10 +531,10 @@ func eqmem(p *Node, q *Node, field *Node, size int64) *Node {
typecheck(&ny, Erv) typecheck(&ny, Erv)
call := Nod(OCALL, eqmemfunc(size, nx.Type.Type, &needsize), nil) call := Nod(OCALL, eqmemfunc(size, nx.Type.Type, &needsize), nil)
appendNodeSeqNode(&call.List, nx) call.List.Append(nx)
appendNodeSeqNode(&call.List, ny) call.List.Append(ny)
if needsize != 0 { if needsize != 0 {
appendNodeSeqNode(&call.List, Nodintconst(size)) call.List.Append(Nodintconst(size))
} }
return call return call
......
...@@ -848,7 +848,7 @@ func (p *exporter) node(n *Node) { ...@@ -848,7 +848,7 @@ func (p *exporter) node(n *Node) {
// expressions // expressions
case OMAKEMAP, OMAKECHAN, OMAKESLICE: case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if p.bool(nodeSeqLen(n.List) != 0) { if p.bool(n.List.Len() != 0) {
p.nodeList(n.List) // TODO(gri) do we still need to export this? p.nodeList(n.List) // TODO(gri) do we still need to export this?
} }
p.nodesOrNil(n.Left, n.Right) p.nodesOrNil(n.Left, n.Right)
...@@ -970,7 +970,7 @@ func (p *exporter) node(n *Node) { ...@@ -970,7 +970,7 @@ func (p *exporter) node(n *Node) {
p.nodeList(n.Nbody) p.nodeList(n.Nbody)
case ORANGE: case ORANGE:
if p.bool(nodeSeqLen(n.List) != 0) { if p.bool(n.List.Len() != 0) {
p.nodeList(n.List) p.nodeList(n.List)
} }
p.node(n.Right) p.node(n.Right)
...@@ -982,7 +982,7 @@ func (p *exporter) node(n *Node) { ...@@ -982,7 +982,7 @@ func (p *exporter) node(n *Node) {
p.nodeList(n.List) p.nodeList(n.List)
case OCASE, OXCASE: case OCASE, OXCASE:
if p.bool(nodeSeqLen(n.List) != 0) { if p.bool(n.List.Len() != 0) {
p.nodeList(n.List) p.nodeList(n.List)
} }
p.nodeList(n.Nbody) p.nodeList(n.Nbody)
......
...@@ -589,7 +589,7 @@ func (p *importer) node() *Node { ...@@ -589,7 +589,7 @@ func (p *importer) node() *Node {
// expressions // expressions
case OMAKEMAP, OMAKECHAN, OMAKESLICE: case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if p.bool() { if p.bool() {
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
} }
n.Left, n.Right = p.nodesOrNil() n.Left, n.Right = p.nodesOrNil()
n.Type = p.typ() n.Type = p.typ()
...@@ -604,19 +604,19 @@ func (p *importer) node() *Node { ...@@ -604,19 +604,19 @@ func (p *importer) node() *Node {
n.Right = p.node() n.Right = p.node()
case OADDSTR: case OADDSTR:
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
case OPTRLIT: case OPTRLIT:
n.Left = p.node() n.Left = p.node()
case OSTRUCTLIT: case OSTRUCTLIT:
n.Type = p.typ() n.Type = p.typ()
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
n.Implicit = p.bool() n.Implicit = p.bool()
case OARRAYLIT, OMAPLIT: case OARRAYLIT, OMAPLIT:
n.Type = p.typ() n.Type = p.typ()
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
n.Implicit = p.bool() n.Implicit = p.bool()
case OKEY: case OKEY:
...@@ -635,9 +635,9 @@ func (p *importer) node() *Node { ...@@ -635,9 +635,9 @@ func (p *importer) node() *Node {
// } // }
x := Nod(OCALL, p.typ().Nod, nil) x := Nod(OCALL, p.typ().Nod, nil)
if p.bool() { if p.bool() {
setNodeSeq(&x.List, []*Node{p.node()}) x.List.Set([]*Node{p.node()})
} else { } else {
setNodeSeq(&x.List, p.nodeList()) x.List.Set(p.nodeList())
} }
return x return x
...@@ -667,12 +667,12 @@ func (p *importer) node() *Node { ...@@ -667,12 +667,12 @@ func (p *importer) node() *Node {
case OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, case OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC,
ORECOVER, OPRINT, OPRINTN: ORECOVER, OPRINT, OPRINTN:
n.Left, _ = p.nodesOrNil() n.Left, _ = p.nodesOrNil()
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
n.Isddd = p.bool() n.Isddd = p.bool()
case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OGETG: case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OGETG:
n.Left = p.node() n.Left = p.node()
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
n.Isddd = p.bool() n.Isddd = p.bool()
case OCMPSTR, OCMPIFACE: case OCMPSTR, OCMPIFACE:
...@@ -698,45 +698,45 @@ func (p *importer) node() *Node { ...@@ -698,45 +698,45 @@ func (p *importer) node() *Node {
n.Etype = EType(p.int()) n.Etype = EType(p.int())
case OAS2, OASWB: case OAS2, OASWB:
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
setNodeSeq(&n.Rlist, p.nodeList()) n.Rlist.Set(p.nodeList())
case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV: case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
setNodeSeq(&n.Rlist, p.nodeList()) n.Rlist.Set(p.nodeList())
case ORETURN: case ORETURN:
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
case OPROC, ODEFER: case OPROC, ODEFER:
n.Left = p.node() n.Left = p.node()
case OIF: case OIF:
setNodeSeq(&n.Ninit, p.nodeList()) n.Ninit.Set(p.nodeList())
n.Left = p.node() n.Left = p.node()
n.Nbody.Set(p.nodeList()) n.Nbody.Set(p.nodeList())
setNodeSeq(&n.Rlist, p.nodeList()) n.Rlist.Set(p.nodeList())
case OFOR: case OFOR:
setNodeSeq(&n.Ninit, p.nodeList()) n.Ninit.Set(p.nodeList())
n.Left, n.Right = p.nodesOrNil() n.Left, n.Right = p.nodesOrNil()
n.Nbody.Set(p.nodeList()) n.Nbody.Set(p.nodeList())
case ORANGE: case ORANGE:
if p.bool() { if p.bool() {
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
} }
n.Right = p.node() n.Right = p.node()
n.Nbody.Set(p.nodeList()) n.Nbody.Set(p.nodeList())
case OSELECT, OSWITCH: case OSELECT, OSWITCH:
setNodeSeq(&n.Ninit, p.nodeList()) n.Ninit.Set(p.nodeList())
n.Left, _ = p.nodesOrNil() n.Left, _ = p.nodesOrNil()
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
case OCASE, OXCASE: case OCASE, OXCASE:
if p.bool() { if p.bool() {
setNodeSeq(&n.List, p.nodeList()) n.List.Set(p.nodeList())
} }
n.Nbody.Set(p.nodeList()) n.Nbody.Set(p.nodeList())
......
...@@ -1752,7 +1752,7 @@ func Bvgen(n, res *Node, wantTrue bool) { ...@@ -1752,7 +1752,7 @@ func Bvgen(n, res *Node, wantTrue bool) {
func bvgenjump(n, res *Node, wantTrue, geninit bool) { func bvgenjump(n, res *Node, wantTrue, geninit bool) {
init := n.Ninit init := n.Ninit
if !geninit { if !geninit {
setNodeSeq(&n.Ninit, nil) n.Ninit.Set(nil)
} }
p1 := Gbranch(obj.AJMP, nil, 0) p1 := Gbranch(obj.AJMP, nil, 0)
p2 := Pc p2 := Pc
...@@ -1762,7 +1762,7 @@ func bvgenjump(n, res *Node, wantTrue, geninit bool) { ...@@ -1762,7 +1762,7 @@ func bvgenjump(n, res *Node, wantTrue, geninit bool) {
Bgen(n, wantTrue, 0, p2) Bgen(n, wantTrue, 0, p2)
Thearch.Gmove(Nodbool(false), res) Thearch.Gmove(Nodbool(false), res)
Patch(p3, Pc) Patch(p3, Pc)
setNodeSeq(&n.Ninit, init) n.Ninit.Set(init.Slice())
} }
// bgenx is the backend for Bgen and Bvgen. // bgenx is the backend for Bgen and Bvgen.
...@@ -1920,11 +1920,11 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) { ...@@ -1920,11 +1920,11 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
if Isfloat[nr.Type.Etype] { if Isfloat[nr.Type.Etype] {
// Brcom is not valid on floats when NaN is involved. // Brcom is not valid on floats when NaN is involved.
ll := n.Ninit // avoid re-genning Ninit ll := n.Ninit // avoid re-genning Ninit
setNodeSeq(&n.Ninit, nil) n.Ninit.Set(nil)
if genval { if genval {
bgenx(n, res, true, likely, to) bgenx(n, res, true, likely, to)
Thearch.Gins(Thearch.Optoas(OXOR, Types[TUINT8]), Nodintconst(1), res) // res = !res Thearch.Gins(Thearch.Optoas(OXOR, Types[TUINT8]), Nodintconst(1), res) // res = !res
setNodeSeq(&n.Ninit, ll) n.Ninit.Set(ll.Slice())
return return
} }
p1 := Gbranch(obj.AJMP, nil, 0) p1 := Gbranch(obj.AJMP, nil, 0)
...@@ -1933,7 +1933,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) { ...@@ -1933,7 +1933,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
bgenx(n, res, true, -likely, p2) bgenx(n, res, true, -likely, p2)
Patch(Gbranch(obj.AJMP, nil, 0), to) Patch(Gbranch(obj.AJMP, nil, 0), to)
Patch(p2, Pc) Patch(p2, Pc)
setNodeSeq(&n.Ninit, ll) n.Ninit.Set(ll.Slice())
return return
} }
...@@ -2799,13 +2799,13 @@ func cgen_append(n, res *Node) { ...@@ -2799,13 +2799,13 @@ func cgen_append(n, res *Node) {
Dump("cgen_append-n", n) Dump("cgen_append-n", n)
Dump("cgen_append-res", res) Dump("cgen_append-res", res)
} }
if res.Op != ONAME && !samesafeexpr(res, nodeSeqFirst(n.List)) { if res.Op != ONAME && !samesafeexpr(res, n.List.First()) {
Dump("cgen_append-n", n) Dump("cgen_append-n", n)
Dump("cgen_append-res", res) Dump("cgen_append-res", res)
Fatalf("append not lowered") Fatalf("append not lowered")
} }
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, n1 := range n.List.Slice() {
if it.N().Ullman >= UINF { if n1.Ullman >= UINF {
Fatalf("append with function call arguments") Fatalf("append with function call arguments")
} }
} }
...@@ -2814,7 +2814,7 @@ func cgen_append(n, res *Node) { ...@@ -2814,7 +2814,7 @@ func cgen_append(n, res *Node) {
// //
// If res and src are the same, we can avoid writing to base and cap // If res and src are the same, we can avoid writing to base and cap
// unless we grow the underlying array. // unless we grow the underlying array.
needFullUpdate := !samesafeexpr(res, nodeSeqFirst(n.List)) needFullUpdate := !samesafeexpr(res, n.List.First())
// Copy src triple into base, len, cap. // Copy src triple into base, len, cap.
base := temp(Types[Tptr]) base := temp(Types[Tptr])
...@@ -2822,7 +2822,7 @@ func cgen_append(n, res *Node) { ...@@ -2822,7 +2822,7 @@ func cgen_append(n, res *Node) {
cap := temp(Types[TUINT]) cap := temp(Types[TUINT])
var src Node var src Node
Igen(nodeSeqFirst(n.List), &src, nil) Igen(n.List.First(), &src, nil)
src.Type = Types[Tptr] src.Type = Types[Tptr]
Thearch.Gmove(&src, base) Thearch.Gmove(&src, base)
src.Type = Types[TUINT] src.Type = Types[TUINT]
...@@ -2835,7 +2835,7 @@ func cgen_append(n, res *Node) { ...@@ -2835,7 +2835,7 @@ func cgen_append(n, res *Node) {
var rlen Node var rlen Node
Regalloc(&rlen, Types[TUINT], nil) Regalloc(&rlen, Types[TUINT], nil)
Thearch.Gmove(len, &rlen) Thearch.Gmove(len, &rlen)
Thearch.Ginscon(Thearch.Optoas(OADD, Types[TUINT]), int64(nodeSeqLen(n.List)-1), &rlen) Thearch.Ginscon(Thearch.Optoas(OADD, Types[TUINT]), int64(n.List.Len()-1), &rlen)
p := Thearch.Ginscmp(OLE, Types[TUINT], &rlen, cap, +1) p := Thearch.Ginscmp(OLE, Types[TUINT], &rlen, cap, +1)
// Note: rlen and src are Regrealloc'ed below at the target of the // Note: rlen and src are Regrealloc'ed below at the target of the
// branch we just emitted; do not reuse these Go variables for // branch we just emitted; do not reuse these Go variables for
...@@ -2905,7 +2905,7 @@ func cgen_append(n, res *Node) { ...@@ -2905,7 +2905,7 @@ func cgen_append(n, res *Node) {
dst.Xoffset += int64(Widthptr) dst.Xoffset += int64(Widthptr)
Regalloc(&r1, Types[TUINT], nil) Regalloc(&r1, Types[TUINT], nil)
Thearch.Gmove(len, &r1) Thearch.Gmove(len, &r1)
Thearch.Ginscon(Thearch.Optoas(OADD, Types[TUINT]), int64(nodeSeqLen(n.List)-1), &r1) Thearch.Ginscon(Thearch.Optoas(OADD, Types[TUINT]), int64(n.List.Len()-1), &r1)
Thearch.Gmove(&r1, &dst) Thearch.Gmove(&r1, &dst)
Regfree(&r1) Regfree(&r1)
dst.Xoffset += int64(Widthptr) dst.Xoffset += int64(Widthptr)
......
...@@ -26,30 +26,29 @@ func closurehdr(ntype *Node) { ...@@ -26,30 +26,29 @@ func closurehdr(ntype *Node) {
// references to these variables need to // references to these variables need to
// refer to the variables in the external // refer to the variables in the external
// function declared below; see walkclosure. // function declared below; see walkclosure.
setNodeSeq(&n.List, ntype.List) n.List.Set(ntype.List.Slice())
setNodeSeq(&n.Rlist, ntype.Rlist) n.Rlist.Set(ntype.Rlist.Slice())
setNodeSeq(&ntype.List, nil) ntype.List.Set(nil)
setNodeSeq(&ntype.Rlist, nil) ntype.Rlist.Set(nil)
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, n1 := range n.List.Slice() {
name = it.N().Left name = n1.Left
if name != nil { if name != nil {
name = newname(name.Sym) name = newname(name.Sym)
} }
a = Nod(ODCLFIELD, name, it.N().Right) a = Nod(ODCLFIELD, name, n1.Right)
a.Isddd = it.N().Isddd a.Isddd = n1.Isddd
if name != nil { if name != nil {
name.Isddd = a.Isddd name.Isddd = a.Isddd
} }
appendNodeSeqNode(&ntype.List, a) ntype.List.Append(a)
} }
for _, n2 := range n.Rlist.Slice() {
for it := nodeSeqIterate(n.Rlist); !it.Done(); it.Next() { name = n2.Left
name = it.N().Left
if name != nil { if name != nil {
name = newname(name.Sym) name = newname(name.Sym)
} }
appendNodeSeqNode(&ntype.Rlist, Nod(ODCLFIELD, name, it.N().Right)) ntype.Rlist.Append(Nod(ODCLFIELD, name, n2.Right))
} }
} }
...@@ -177,8 +176,8 @@ func makeclosure(func_ *Node) *Node { ...@@ -177,8 +176,8 @@ func makeclosure(func_ *Node) *Node {
// that begins by reading closure parameters. // that begins by reading closure parameters.
xtype := Nod(OTFUNC, nil, nil) xtype := Nod(OTFUNC, nil, nil)
setNodeSeq(&xtype.List, func_.List) xtype.List.Set(func_.List.Slice())
setNodeSeq(&xtype.Rlist, func_.Rlist) xtype.Rlist.Set(func_.Rlist.Slice())
// create the function // create the function
xfunc := Nod(ODCLFUNC, nil, nil) xfunc := Nod(ODCLFUNC, nil, nil)
...@@ -205,8 +204,8 @@ func makeclosure(func_ *Node) *Node { ...@@ -205,8 +204,8 @@ func makeclosure(func_ *Node) *Node {
func_.Func.Closure = xfunc func_.Func.Closure = xfunc
func_.Nbody.Set(nil) func_.Nbody.Set(nil)
setNodeSeq(&func_.List, nil) func_.List.Set(nil)
setNodeSeq(&func_.Rlist, nil) func_.Rlist.Set(nil)
return xfunc return xfunc
} }
...@@ -426,7 +425,7 @@ func walkclosure(func_ *Node, init *Nodes) *Node { ...@@ -426,7 +425,7 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
typ := Nod(OTSTRUCT, nil, nil) typ := Nod(OTSTRUCT, nil, nil)
setNodeSeq(&typ.List, []*Node{Nod(ODCLFIELD, newname(Lookup(".F")), typenod(Types[TUINTPTR]))}) typ.List.Set([]*Node{Nod(ODCLFIELD, newname(Lookup(".F")), typenod(Types[TUINTPTR]))})
var typ1 *Node var typ1 *Node
for _, v := range func_.Func.Cvars.Slice() { for _, v := range func_.Func.Cvars.Slice() {
if v.Op == OXXX { if v.Op == OXXX {
...@@ -436,13 +435,13 @@ func walkclosure(func_ *Node, init *Nodes) *Node { ...@@ -436,13 +435,13 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
if !v.Name.Byval { if !v.Name.Byval {
typ1 = Nod(OIND, typ1, nil) typ1 = Nod(OIND, typ1, nil)
} }
appendNodeSeqNode(&typ.List, Nod(ODCLFIELD, newname(v.Sym), typ1)) typ.List.Append(Nod(ODCLFIELD, newname(v.Sym), typ1))
} }
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil)) clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = func_.Esc clos.Esc = func_.Esc
clos.Right.Implicit = true clos.Right.Implicit = true
setNodeSeq(&clos.List, append([]*Node{Nod(OCFUNC, func_.Func.Closure.Func.Nname, nil)}, func_.Func.Enter.Slice()...)) clos.List.Set(append([]*Node{Nod(OCFUNC, func_.Func.Closure.Func.Nname, nil)}, func_.Func.Enter.Slice()...))
// Force type conversion from *struct to the func type. // Force type conversion from *struct to the func type.
clos = Nod(OCONVNOP, clos, nil) clos = Nod(OCONVNOP, clos, nil)
...@@ -550,7 +549,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -550,7 +549,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
l = append(l, fld) l = append(l, fld)
} }
setNodeSeq(&xtype.List, l) xtype.List.Set(l)
i = 0 i = 0
l = nil l = nil
var retargs []*Node var retargs []*Node
...@@ -563,7 +562,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -563,7 +562,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
l = append(l, Nod(ODCLFIELD, n, typenod(t.Type))) l = append(l, Nod(ODCLFIELD, n, typenod(t.Type)))
} }
setNodeSeq(&xtype.Rlist, l) xtype.Rlist.Set(l)
xfunc.Func.Dupok = true xfunc.Func.Dupok = true
xfunc.Func.Nname = newfuncname(sym) xfunc.Func.Nname = newfuncname(sym)
...@@ -600,14 +599,14 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -600,14 +599,14 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
} }
call := Nod(OCALL, Nod(OXDOT, ptr, meth), nil) call := Nod(OCALL, Nod(OXDOT, ptr, meth), nil)
setNodeSeq(&call.List, callargs) call.List.Set(callargs)
call.Isddd = ddd call.Isddd = ddd
if t0.Outtuple == 0 { if t0.Outtuple == 0 {
body = append(body, call) body = append(body, call)
} else { } else {
n := Nod(OAS2, nil, nil) n := Nod(OAS2, nil, nil)
setNodeSeq(&n.List, retargs) n.List.Set(retargs)
setNodeSeq(&n.Rlist, []*Node{call}) n.Rlist.Set([]*Node{call})
body = append(body, n) body = append(body, n)
n = Nod(ORETURN, nil, nil) n = Nod(ORETURN, nil, nil)
body = append(body, n) body = append(body, n)
...@@ -640,14 +639,14 @@ func walkpartialcall(n *Node, init *Nodes) *Node { ...@@ -640,14 +639,14 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
} }
typ := Nod(OTSTRUCT, nil, nil) typ := Nod(OTSTRUCT, nil, nil)
setNodeSeq(&typ.List, []*Node{Nod(ODCLFIELD, newname(Lookup("F")), typenod(Types[TUINTPTR]))}) typ.List.Set([]*Node{Nod(ODCLFIELD, newname(Lookup("F")), typenod(Types[TUINTPTR]))})
appendNodeSeqNode(&typ.List, Nod(ODCLFIELD, newname(Lookup("R")), typenod(n.Left.Type))) typ.List.Append(Nod(ODCLFIELD, newname(Lookup("R")), typenod(n.Left.Type)))
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil)) clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = n.Esc clos.Esc = n.Esc
clos.Right.Implicit = true clos.Right.Implicit = true
setNodeSeq(&clos.List, []*Node{Nod(OCFUNC, n.Func.Nname, nil)}) clos.List.Set([]*Node{Nod(OCFUNC, n.Func.Nname, nil)})
appendNodeSeqNode(&clos.List, n.Left) clos.List.Append(n.Left)
// Force type conversion from *struct to the func type. // Force type conversion from *struct to the func type.
clos = Nod(OCONVNOP, clos, nil) clos = Nod(OCONVNOP, clos, nil)
......
...@@ -543,7 +543,7 @@ func evconst(n *Node) { ...@@ -543,7 +543,7 @@ func evconst(n *Node) {
// merge adjacent constants in the argument list. // merge adjacent constants in the argument list.
case OADDSTR: case OADDSTR:
s := nodeSeqSlice(n.List) s := n.List.Slice()
for i1 := 0; i1 < len(s); i1++ { for i1 := 0; i1 < len(s); i1++ {
if Isconst(s[i1], CTSTR) && i1+1 < len(s) && Isconst(s[i1+1], CTSTR) { if Isconst(s[i1], CTSTR) && i1+1 < len(s) && Isconst(s[i1+1], CTSTR) {
// merge from i1 up to but not including i2 // merge from i1 up to but not including i2
...@@ -567,7 +567,7 @@ func evconst(n *Node) { ...@@ -567,7 +567,7 @@ func evconst(n *Node) {
n.Op = OLITERAL n.Op = OLITERAL
n.SetVal(s[0].Val()) n.SetVal(s[0].Val())
} else { } else {
setNodeSeq(&n.List, s) n.List.Set(s)
} }
return return
...@@ -1736,14 +1736,13 @@ func hascallchan(n *Node) bool { ...@@ -1736,14 +1736,13 @@ func hascallchan(n *Node) bool {
if hascallchan(n.Left) || hascallchan(n.Right) { if hascallchan(n.Left) || hascallchan(n.Right) {
return true return true
} }
for _, n1 := range n.List.Slice() {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { if hascallchan(n1) {
if hascallchan(it.N()) {
return true return true
} }
} }
for it := nodeSeqIterate(n.Rlist); !it.Done(); it.Next() { for _, n2 := range n.Rlist.Slice() {
if hascallchan(it.N()) { if hascallchan(n2) {
return true return true
} }
} }
......
...@@ -228,7 +228,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList { ...@@ -228,7 +228,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList {
e := el.N e := el.N
as2 := Nod(OAS2, nil, nil) as2 := Nod(OAS2, nil, nil)
setNodeSeq(&as2.List, vl) setNodeSeq(&as2.List, vl)
setNodeSeqNode(&as2.Rlist, e) as2.Rlist.Set([]*Node{e})
var v *Node var v *Node
for ; vl != nil; vl = vl.Next { for ; vl != nil; vl = vl.Next {
v = vl.N v = vl.N
...@@ -438,17 +438,17 @@ func colasname(n *Node) bool { ...@@ -438,17 +438,17 @@ func colasname(n *Node) bool {
} }
func colasdefn(left Nodes, defn *Node) { func colasdefn(left Nodes, defn *Node) {
for it := nodeSeqIterate(left); !it.Done(); it.Next() { for _, n1 := range left.Slice() {
if it.N().Sym != nil { if n1.Sym != nil {
it.N().Sym.Flags |= SymUniq n1.Sym.Flags |= SymUniq
} }
} }
nnew := 0 nnew := 0
nerr := 0 nerr := 0
var n *Node var n *Node
for it := nodeSeqIterate(left); !it.Done(); it.Next() { for i2, n2 := range left.Slice() {
n = it.N() n = n2
if isblank(n) { if isblank(n) {
continue continue
} }
...@@ -474,8 +474,8 @@ func colasdefn(left Nodes, defn *Node) { ...@@ -474,8 +474,8 @@ func colasdefn(left Nodes, defn *Node) {
n = newname(n.Sym) n = newname(n.Sym)
declare(n, dclcontext) declare(n, dclcontext)
n.Name.Defn = defn n.Name.Defn = defn
appendNodeSeqNode(&defn.Ninit, Nod(ODCL, n, nil)) defn.Ninit.Append(Nod(ODCL, n, nil))
*it.P() = n left.Slice()[i2] = n
} }
if nnew == 0 && nerr == 0 { if nnew == 0 && nerr == 0 {
...@@ -492,11 +492,11 @@ func colas(left *NodeList, right *NodeList, lno int32) *Node { ...@@ -492,11 +492,11 @@ func colas(left *NodeList, right *NodeList, lno int32) *Node {
colasdefn(as.List, as) colasdefn(as.List, as)
// make the tree prettier; not necessary // make the tree prettier; not necessary
if nodeSeqLen(as.List) == 1 && nodeSeqLen(as.Rlist) == 1 { if as.List.Len() == 1 && as.Rlist.Len() == 1 {
as.Left = nodeSeqFirst(as.List) as.Left = as.List.First()
as.Right = nodeSeqFirst(as.Rlist) as.Right = as.Rlist.First()
setNodeSeq(&as.List, nil) as.List.Set(nil)
setNodeSeq(&as.Rlist, nil) as.Rlist.Set(nil)
as.Op = OAS as.Op = OAS
} }
...@@ -570,7 +570,7 @@ func funcargs(nt *Node) { ...@@ -570,7 +570,7 @@ func funcargs(nt *Node) {
// re-start the variable generation number // re-start the variable generation number
// we want to use small numbers for the return variables, // we want to use small numbers for the return variables,
// so let them have the chunk starting at 1. // so let them have the chunk starting at 1.
vargen = nodeSeqLen(nt.Rlist) vargen = nt.Rlist.Len()
// declare the receiver and in arguments. // declare the receiver and in arguments.
// no n->defn because type checking of func header // no n->defn because type checking of func header
...@@ -592,8 +592,7 @@ func funcargs(nt *Node) { ...@@ -592,8 +592,7 @@ func funcargs(nt *Node) {
} }
var n *Node var n *Node
for it := nodeSeqIterate(nt.List); !it.Done(); it.Next() { for _, n = range nt.List.Slice() {
n = it.N()
if n.Op != ODCLFIELD { if n.Op != ODCLFIELD {
Fatalf("funcargs in %v", Oconv(n.Op, 0)) Fatalf("funcargs in %v", Oconv(n.Op, 0))
} }
...@@ -609,12 +608,10 @@ func funcargs(nt *Node) { ...@@ -609,12 +608,10 @@ func funcargs(nt *Node) {
} }
// declare the out arguments. // declare the out arguments.
gen := nodeSeqLen(nt.List) gen := nt.List.Len()
var i int = 0 var i int = 0
var nn *Node var nn *Node
for it := nodeSeqIterate(nt.Rlist); !it.Done(); it.Next() { for _, n = range nt.Rlist.Slice() {
n = it.N()
if n.Op != ODCLFIELD { if n.Op != ODCLFIELD {
Fatalf("funcargs out %v", Oconv(n.Op, 0)) Fatalf("funcargs out %v", Oconv(n.Op, 0))
} }
...@@ -964,10 +961,10 @@ func tointerface0(t *Type, l []*Node) *Type { ...@@ -964,10 +961,10 @@ func tointerface0(t *Type, l []*Node) *Type {
} }
tp := &t.Type tp := &t.Type
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l {
f := interfacefield(it.N()) f := interfacefield(n)
if it.N().Left == nil && f.Type.Etype == TINTER { if n.Left == nil && f.Type.Etype == TINTER {
// embedded interface, inline methods // embedded interface, inline methods
for t1 := f.Type.Type; t1 != nil; t1 = t1.Down { for t1 := f.Type.Type; t1 != nil; t1 = t1.Down {
f = typ(TFIELD) f = typ(TFIELD)
...@@ -1536,8 +1533,8 @@ func checknowritebarrierrec() { ...@@ -1536,8 +1533,8 @@ func checknowritebarrierrec() {
} }
func (c *nowritebarrierrecChecker) visitcodelist(l Nodes) { func (c *nowritebarrierrecChecker) visitcodelist(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l.Slice() {
c.visitcode(it.N()) c.visitcode(n)
} }
} }
......
This diff is collapsed.
...@@ -107,8 +107,8 @@ func dumppkg(p *Pkg) { ...@@ -107,8 +107,8 @@ func dumppkg(p *Pkg) {
// Look for anything we need for the inline body // Look for anything we need for the inline body
func reexportdeplist(ll Nodes) { func reexportdeplist(ll Nodes) {
for it := nodeSeqIterate(ll); !it.Done(); it.Next() { for _, n := range ll.Slice() {
reexportdep(it.N()) reexportdep(n)
} }
} }
......
...@@ -800,10 +800,10 @@ func stmtfmt(n *Node) string { ...@@ -800,10 +800,10 @@ func stmtfmt(n *Node) string {
// block starting with the init statements. // block starting with the init statements.
// if we can just say "for" n->ninit; ... then do so // if we can just say "for" n->ninit; ... then do so
simpleinit := nodeSeqLen(n.Ninit) == 1 && nodeSeqLen(nodeSeqFirst(n.Ninit).Ninit) == 0 && stmtwithinit(n.Op) simpleinit := n.Ninit.Len() == 1 && n.Ninit.First().Ninit.Len() == 0 && stmtwithinit(n.Op)
// otherwise, print the inits as separate statements // otherwise, print the inits as separate statements
complexinit := nodeSeqLen(n.Ninit) != 0 && !simpleinit && (fmtmode != FErr) complexinit := n.Ninit.Len() != 0 && !simpleinit && (fmtmode != FErr)
// but if it was for if/for/switch, put in an extra surrounding block to limit the scope // but if it was for if/for/switch, put in an extra surrounding block to limit the scope
extrablock := complexinit && stmtwithinit(n.Op) extrablock := complexinit && stmtwithinit(n.Op)
...@@ -885,11 +885,11 @@ func stmtfmt(n *Node) string { ...@@ -885,11 +885,11 @@ func stmtfmt(n *Node) string {
case OIF: case OIF:
if simpleinit { if simpleinit {
f += fmt.Sprintf("if %v; %v { %v }", nodeSeqFirst(n.Ninit), n.Left, n.Nbody) f += fmt.Sprintf("if %v; %v { %v }", n.Ninit.First(), n.Left, n.Nbody)
} else { } else {
f += fmt.Sprintf("if %v { %v }", n.Left, n.Nbody) f += fmt.Sprintf("if %v { %v }", n.Left, n.Nbody)
} }
if nodeSeqLen(n.Rlist) != 0 { if n.Rlist.Len() != 0 {
f += fmt.Sprintf(" else { %v }", n.Rlist) f += fmt.Sprintf(" else { %v }", n.Rlist)
} }
...@@ -901,7 +901,7 @@ func stmtfmt(n *Node) string { ...@@ -901,7 +901,7 @@ func stmtfmt(n *Node) string {
f += "for" f += "for"
if simpleinit { if simpleinit {
f += fmt.Sprintf(" %v;", nodeSeqFirst(n.Ninit)) f += fmt.Sprintf(" %v;", n.Ninit.First())
} else if n.Right != nil { } else if n.Right != nil {
f += " ;" f += " ;"
} }
...@@ -924,7 +924,7 @@ func stmtfmt(n *Node) string { ...@@ -924,7 +924,7 @@ func stmtfmt(n *Node) string {
break break
} }
if nodeSeqLen(n.List) == 0 { if n.List.Len() == 0 {
f += fmt.Sprintf("for range %v { %v }", n.Right, n.Nbody) f += fmt.Sprintf("for range %v { %v }", n.Right, n.Nbody)
break break
} }
...@@ -939,7 +939,7 @@ func stmtfmt(n *Node) string { ...@@ -939,7 +939,7 @@ func stmtfmt(n *Node) string {
f += Oconv(n.Op, obj.FmtSharp) f += Oconv(n.Op, obj.FmtSharp)
if simpleinit { if simpleinit {
f += fmt.Sprintf(" %v;", nodeSeqFirst(n.Ninit)) f += fmt.Sprintf(" %v;", n.Ninit.First())
} }
if n.Left != nil { if n.Left != nil {
f += Nconv(n.Left, 0) f += Nconv(n.Left, 0)
...@@ -948,7 +948,7 @@ func stmtfmt(n *Node) string { ...@@ -948,7 +948,7 @@ func stmtfmt(n *Node) string {
f += fmt.Sprintf(" { %v }", n.List) f += fmt.Sprintf(" { %v }", n.List)
case OCASE, OXCASE: case OCASE, OXCASE:
if nodeSeqLen(n.List) != 0 { if n.List.Len() != 0 {
f += fmt.Sprintf("case %v: %v", Hconv(n.List, obj.FmtComma), n.Nbody) f += fmt.Sprintf("case %v: %v", Hconv(n.List, obj.FmtComma), n.Nbody)
} else { } else {
f += fmt.Sprintf("default: %v", n.Nbody) f += fmt.Sprintf("default: %v", n.Nbody)
...@@ -1391,7 +1391,7 @@ func exprfmt(n *Node, prec int) string { ...@@ -1391,7 +1391,7 @@ func exprfmt(n *Node, prec int) string {
return f return f
case OMAKEMAP, OMAKECHAN, OMAKESLICE: case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if nodeSeqLen(n.List) != 0 { // pre-typecheck if n.List.Len() != 0 { // pre-typecheck
return fmt.Sprintf("make(%v, %v)", n.Type, Hconv(n.List, obj.FmtComma)) return fmt.Sprintf("make(%v, %v)", n.Type, Hconv(n.List, obj.FmtComma))
} }
if n.Right != nil { if n.Right != nil {
...@@ -1450,11 +1450,11 @@ func exprfmt(n *Node, prec int) string { ...@@ -1450,11 +1450,11 @@ func exprfmt(n *Node, prec int) string {
case OADDSTR: case OADDSTR:
var f string var f string
i := 0 i := 0
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, n1 := range n.List.Slice() {
if i != 0 { if i != 0 {
f += " + " f += " + "
} }
f += exprfmt(it.N(), nprec) f += exprfmt(n1, nprec)
i++ i++
} }
...@@ -1523,7 +1523,7 @@ func nodedump(n *Node, flag int) string { ...@@ -1523,7 +1523,7 @@ func nodedump(n *Node, flag int) string {
return buf.String() return buf.String()
} }
if nodeSeqLen(n.Ninit) != 0 { if n.Ninit.Len() != 0 {
fmt.Fprintf(&buf, "%v-init%v", Oconv(n.Op, 0), n.Ninit) fmt.Fprintf(&buf, "%v-init%v", Oconv(n.Op, 0), n.Ninit)
indent(&buf) indent(&buf)
} }
...@@ -1576,12 +1576,12 @@ func nodedump(n *Node, flag int) string { ...@@ -1576,12 +1576,12 @@ func nodedump(n *Node, flag int) string {
if n.Right != nil { if n.Right != nil {
buf.WriteString(Nconv(n.Right, 0)) buf.WriteString(Nconv(n.Right, 0))
} }
if nodeSeqLen(n.List) != 0 { if n.List.Len() != 0 {
indent(&buf) indent(&buf)
fmt.Fprintf(&buf, "%v-list%v", Oconv(n.Op, 0), n.List) fmt.Fprintf(&buf, "%v-list%v", Oconv(n.Op, 0), n.List)
} }
if nodeSeqLen(n.Rlist) != 0 { if n.Rlist.Len() != 0 {
indent(&buf) indent(&buf)
fmt.Fprintf(&buf, "%v-rlist%v", Oconv(n.Op, 0), n.Rlist) fmt.Fprintf(&buf, "%v-rlist%v", Oconv(n.Op, 0), n.Rlist)
} }
...@@ -1711,7 +1711,7 @@ func (n Nodes) String() string { ...@@ -1711,7 +1711,7 @@ func (n Nodes) String() string {
// Fmt '%H': NodeList. // Fmt '%H': NodeList.
// Flags: all those of %N plus ',': separate with comma's instead of semicolons. // Flags: all those of %N plus ',': separate with comma's instead of semicolons.
func Hconv(l Nodes, flag int) string { func Hconv(l Nodes, flag int) string {
if nodeSeqLen(l) == 0 && fmtmode == FDbg { if l.Len() == 0 && fmtmode == FDbg {
return "<nil>" return "<nil>"
} }
......
...@@ -216,8 +216,8 @@ func stmtlabel(n *Node) *Label { ...@@ -216,8 +216,8 @@ func stmtlabel(n *Node) *Label {
// compile statements // compile statements
func Genlist(l Nodes) { func Genlist(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l.Slice() {
gen(it.N()) gen(n)
} }
} }
...@@ -440,7 +440,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) { ...@@ -440,7 +440,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) {
r1.Type = byteptr r1.Type = byteptr
r2.Type = byteptr r2.Type = byteptr
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type))) setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, fn.Type.ParamsP(), call.List.Slice(), 0, nil)) call.List.Set(ascompatte(OCALLFUNC, call, false, fn.Type.ParamsP(), call.List.Slice(), 0, nil))
gen(call) gen(call)
Regfree(&r1) Regfree(&r1)
Regfree(&r2) Regfree(&r2)
...@@ -526,7 +526,7 @@ func Cgen_As2dottype(n, res, resok *Node) { ...@@ -526,7 +526,7 @@ func Cgen_As2dottype(n, res, resok *Node) {
dowidth(fn.Type) dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil) call := Nod(OCALLFUNC, fn, nil)
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type))) setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, fn.Type.ParamsP(), call.List.Slice(), 0, nil)) call.List.Set(ascompatte(OCALLFUNC, call, false, fn.Type.ParamsP(), call.List.Slice(), 0, nil))
gen(call) gen(call)
Regfree(&r1) Regfree(&r1)
Regfree(&r2) Regfree(&r2)
...@@ -638,7 +638,7 @@ func gen(n *Node) { ...@@ -638,7 +638,7 @@ func gen(n *Node) {
goto ret goto ret
} }
if nodeSeqLen(n.Ninit) > 0 { if n.Ninit.Len() > 0 {
Genlist(n.Ninit) Genlist(n.Ninit)
} }
...@@ -845,7 +845,7 @@ func gen(n *Node) { ...@@ -845,7 +845,7 @@ func gen(n *Node) {
Cgen_as_wb(n.Left, n.Right, true) Cgen_as_wb(n.Left, n.Right, true)
case OAS2DOTTYPE: case OAS2DOTTYPE:
cgen_dottype(nodeSeqFirst(n.Rlist), nodeSeqFirst(n.List), nodeSeqSecond(n.List), needwritebarrier(nodeSeqFirst(n.List), nodeSeqFirst(n.Rlist))) cgen_dottype(n.Rlist.First(), n.List.First(), n.List.Second(), needwritebarrier(n.List.First(), n.Rlist.First()))
case OCALLMETH: case OCALLMETH:
cgen_callmeth(n, 0) cgen_callmeth(n, 0)
......
This diff is collapsed.
This diff is collapsed.
...@@ -684,7 +684,7 @@ func (p *parser) labeled_stmt(label *Node) *Node { ...@@ -684,7 +684,7 @@ func (p *parser) labeled_stmt(label *Node) *Node {
label.Name.Defn = ls label.Name.Defn = ls
l := []*Node{label} l := []*Node{label}
if ls != nil { if ls != nil {
if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 { if ls.Op == OBLOCK && ls.Ninit.Len() == 0 {
l = append(l, ls.List.Slice()...) l = append(l, ls.List.Slice()...)
} else { } else {
l = append(l, ls) l = append(l, ls)
...@@ -726,7 +726,7 @@ func (p *parser) case_(tswitch *Node) *Node { ...@@ -726,7 +726,7 @@ func (p *parser) case_(tswitch *Node) *Node {
// type switch - declare variable // type switch - declare variable
nn := newname(n.Sym) nn := newname(n.Sym)
declare(nn, dclcontext) declare(nn, dclcontext)
setNodeSeq(&stmt.Rlist, []*Node{nn}) stmt.Rlist.Set([]*Node{nn})
// keep track of the instances for reporting unused // keep track of the instances for reporting unused
nn.Name.Defn = tswitch nn.Name.Defn = tswitch
...@@ -752,9 +752,9 @@ func (p *parser) case_(tswitch *Node) *Node { ...@@ -752,9 +752,9 @@ func (p *parser) case_(tswitch *Node) *Node {
} else { } else {
n = Nod(OAS2, nil, nil) n = Nod(OAS2, nil, nil)
setNodeSeq(&n.List, cases) setNodeSeq(&n.List, cases)
setNodeSeq(&n.Rlist, []*Node{rhs}) n.Rlist.Set([]*Node{rhs})
} }
setNodeSeq(&stmt.List, []*Node{n}) stmt.List.Set([]*Node{n})
p.want(':') // consume ':' after declaring select cases for correct lineno p.want(':') // consume ':' after declaring select cases for correct lineno
return stmt return stmt
...@@ -770,7 +770,7 @@ func (p *parser) case_(tswitch *Node) *Node { ...@@ -770,7 +770,7 @@ func (p *parser) case_(tswitch *Node) *Node {
// done in casebody() // done in casebody()
markdcl() // matching popdcl in caseblock markdcl() // matching popdcl in caseblock
stmt := Nod(OXCASE, nil, nil) stmt := Nod(OXCASE, nil, nil)
setNodeSeq(&stmt.List, []*Node{colas(cases, list1(rhs), lno)}) stmt.List.Set([]*Node{colas(cases, list1(rhs), lno)})
p.want(':') // consume ':' after declaring select cases for correct lineno p.want(':') // consume ':' after declaring select cases for correct lineno
return stmt return stmt
...@@ -794,7 +794,7 @@ func (p *parser) case_(tswitch *Node) *Node { ...@@ -794,7 +794,7 @@ func (p *parser) case_(tswitch *Node) *Node {
// type switch - declare variable // type switch - declare variable
nn := newname(n.Sym) nn := newname(n.Sym)
declare(nn, dclcontext) declare(nn, dclcontext)
setNodeSeq(&stmt.Rlist, []*Node{nn}) stmt.Rlist.Set([]*Node{nn})
// keep track of the instances for reporting unused // keep track of the instances for reporting unused
nn.Name.Defn = tswitch nn.Name.Defn = tswitch
...@@ -918,7 +918,7 @@ func (p *parser) for_header() *Node { ...@@ -918,7 +918,7 @@ func (p *parser) for_header() *Node {
} }
h := Nod(OFOR, nil, nil) h := Nod(OFOR, nil, nil)
if init != nil { if init != nil {
setNodeSeq(&h.Ninit, []*Node{init}) h.Ninit.Set([]*Node{init})
} }
h.Left = cond h.Left = cond
h.Right = post h.Right = post
...@@ -1022,7 +1022,7 @@ func (p *parser) if_header() *Node { ...@@ -1022,7 +1022,7 @@ func (p *parser) if_header() *Node {
init, cond, _ := p.header(false) init, cond, _ := p.header(false)
h := Nod(OIF, nil, nil) h := Nod(OIF, nil, nil)
if init != nil { if init != nil {
setNodeSeq(&h.Ninit, []*Node{init}) h.Ninit.Set([]*Node{init})
} }
h.Left = cond h.Left = cond
return h return h
...@@ -1047,13 +1047,13 @@ func (p *parser) if_stmt() *Node { ...@@ -1047,13 +1047,13 @@ func (p *parser) if_stmt() *Node {
if p.got(LELSE) { if p.got(LELSE) {
if p.tok == LIF { if p.tok == LIF {
setNodeSeq(&stmt.Rlist, []*Node{p.if_stmt()}) stmt.Rlist.Set([]*Node{p.if_stmt()})
} else { } else {
cs := p.compound_stmt(true) cs := p.compound_stmt(true)
if cs.Op == OBLOCK && nodeSeqLen(cs.Ninit) == 0 { if cs.Op == OBLOCK && cs.Ninit.Len() == 0 {
setNodeSeq(&stmt.Rlist, cs.List) stmt.Rlist.Set(cs.List.Slice())
} else { } else {
setNodeSeq(&stmt.Rlist, []*Node{cs}) stmt.Rlist.Set([]*Node{cs})
} }
} }
} }
...@@ -1553,7 +1553,7 @@ func (p *parser) complitexpr() *Node { ...@@ -1553,7 +1553,7 @@ func (p *parser) complitexpr() *Node {
p.xnest-- p.xnest--
p.want('}') p.want('}')
setNodeSeq(&n.List, l) n.List.Set(l)
return n return n
} }
...@@ -1842,7 +1842,7 @@ func (p *parser) interfacetype() *Node { ...@@ -1842,7 +1842,7 @@ func (p *parser) interfacetype() *Node {
p.want('}') p.want('}')
t := Nod(OTINTER, nil, nil) t := Nod(OTINTER, nil, nil)
setNodeSeq(&t.List, l) t.List.Set(l)
return t return t
} }
...@@ -2514,7 +2514,7 @@ func (p *parser) stmt() *Node { ...@@ -2514,7 +2514,7 @@ func (p *parser) stmt() *Node {
stmt := Nod(ORETURN, nil, nil) stmt := Nod(ORETURN, nil, nil)
setNodeSeq(&stmt.List, results) setNodeSeq(&stmt.List, results)
if nodeSeqLen(stmt.List) == 0 && Curfn != nil { if stmt.List.Len() == 0 && Curfn != nil {
for _, ln := range Curfn.Func.Dcl { for _, ln := range Curfn.Func.Dcl {
if ln.Class == PPARAM { if ln.Class == PPARAM {
continue continue
...@@ -2549,7 +2549,7 @@ func (p *parser) stmt_list() (l *NodeList) { ...@@ -2549,7 +2549,7 @@ func (p *parser) stmt_list() (l *NodeList) {
if s == missing_stmt { if s == missing_stmt {
break break
} }
if s != nil && s.Op == OBLOCK && nodeSeqLen(s.Ninit) == 0 { if s != nil && s.Op == OBLOCK && s.Ninit.Len() == 0 {
appendNodeSeq(&l, s.List) appendNodeSeq(&l, s.List)
} else { } else {
appendNodeSeqNode(&l, s) appendNodeSeqNode(&l, s)
......
...@@ -87,11 +87,11 @@ func instrument(fn *Node) { ...@@ -87,11 +87,11 @@ func instrument(fn *Node) {
} }
func instrumentlist(l Nodes, init *Nodes) { func instrumentlist(l Nodes, init *Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for i := range l.Slice() {
var instr Nodes var instr Nodes
instrumentnode(it.P(), &instr, 0, 0) instrumentnode(&l.Slice()[i], &instr, 0, 0)
if init == nil { if init == nil {
it.N().Ninit.AppendNodes(&instr) l.Slice()[i].Ninit.AppendNodes(&instr)
} else { } else {
init.AppendNodes(&instr) init.AppendNodes(&instr)
} }
...@@ -121,7 +121,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) { ...@@ -121,7 +121,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
// nil it out and handle it separately before putting it back. // nil it out and handle it separately before putting it back.
l := n.Ninit l := n.Ninit
setNodeSeq(&n.Ninit, nil) n.Ninit.Set(nil)
instrumentlist(l, nil) instrumentlist(l, nil)
instrumentnode(&n, &l, wr, skip) // recurse with nil n->ninit instrumentnode(&n, &l, wr, skip) // recurse with nil n->ninit
appendinit(&n, l) appendinit(&n, l)
...@@ -167,7 +167,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) { ...@@ -167,7 +167,7 @@ func instrumentnode(np **Node, init *Nodes, wr int, skip int) {
out = append(outn.Slice(), it.N()) out = append(outn.Slice(), it.N())
} }
} }
setNodeSeq(&n.List, out) n.List.Set(out)
goto ret goto ret
case ODEFER: case ODEFER:
...@@ -595,8 +595,8 @@ func foreachnode(n *Node, f func(*Node, interface{}), c interface{}) { ...@@ -595,8 +595,8 @@ func foreachnode(n *Node, f func(*Node, interface{}), c interface{}) {
} }
func foreachlist(l Nodes, f func(*Node, interface{}), c interface{}) { func foreachlist(l Nodes, f func(*Node, interface{}), c interface{}) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l.Slice() {
foreachnode(it.N(), f, c) foreachnode(n, f, c)
} }
} }
...@@ -619,7 +619,7 @@ func hascallspred(n *Node, c interface{}) { ...@@ -619,7 +619,7 @@ func hascallspred(n *Node, c interface{}) {
// appendinit is like addinit in subr.go // appendinit is like addinit in subr.go
// but appends rather than prepends. // but appends rather than prepends.
func appendinit(np **Node, init Nodes) { func appendinit(np **Node, init Nodes) {
if nodeSeqLen(init) == 0 { if init.Len() == 0 {
return return
} }
...@@ -635,6 +635,6 @@ func appendinit(np **Node, init Nodes) { ...@@ -635,6 +635,6 @@ func appendinit(np **Node, init Nodes) {
*np = n *np = n
} }
appendNodeSeq(&n.Ninit, init) n.Ninit.AppendNodes(&init)
n.Ullman = UINF n.Ullman = UINF
} }
...@@ -31,11 +31,10 @@ func typecheckrange(n *Node) { ...@@ -31,11 +31,10 @@ func typecheckrange(n *Node) {
if t == nil { if t == nil {
goto out goto out
} }
// delicate little dance. see typecheckas2 // delicate little dance. see typecheckas2
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for i1, n1 := range n.List.Slice() {
if it.N().Name == nil || it.N().Name.Defn != n { if n1.Name == nil || n1.Name.Defn != n {
typecheck(it.P(), Erv|Easgn) typecheck(&n.List.Slice()[i1], Erv|Easgn)
} }
} }
...@@ -66,7 +65,7 @@ func typecheckrange(n *Node) { ...@@ -66,7 +65,7 @@ func typecheckrange(n *Node) {
t1 = t.Type t1 = t.Type
t2 = nil t2 = nil
if nodeSeqLen(n.List) == 2 { if n.List.Len() == 2 {
toomany = 1 toomany = 1
} }
...@@ -75,17 +74,17 @@ func typecheckrange(n *Node) { ...@@ -75,17 +74,17 @@ func typecheckrange(n *Node) {
t2 = runetype t2 = runetype
} }
if nodeSeqLen(n.List) > 2 || toomany != 0 { if n.List.Len() > 2 || toomany != 0 {
Yyerror("too many variables in range") Yyerror("too many variables in range")
} }
v1 = nil v1 = nil
if nodeSeqLen(n.List) != 0 { if n.List.Len() != 0 {
v1 = nodeSeqFirst(n.List) v1 = n.List.First()
} }
v2 = nil v2 = nil
if nodeSeqLen(n.List) > 1 { if n.List.Len() > 1 {
v2 = nodeSeqSecond(n.List) v2 = n.List.Second()
} }
// this is not only a optimization but also a requirement in the spec. // this is not only a optimization but also a requirement in the spec.
...@@ -94,7 +93,7 @@ func typecheckrange(n *Node) { ...@@ -94,7 +93,7 @@ func typecheckrange(n *Node) {
// present." // present."
if isblank(v2) { if isblank(v2) {
if v1 != nil { if v1 != nil {
setNodeSeq(&n.List, []*Node{v1}) n.List.Set([]*Node{v1})
} }
v2 = nil v2 = nil
} }
...@@ -120,10 +119,9 @@ func typecheckrange(n *Node) { ...@@ -120,10 +119,9 @@ func typecheckrange(n *Node) {
// second half of dance // second half of dance
out: out:
n.Typecheck = 1 n.Typecheck = 1
for i2, n2 := range n.List.Slice() {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { if n2.Typecheck == 0 {
if it.N().Typecheck == 0 { typecheck(&n.List.Slice()[i2], Erv|Easgn)
typecheck(it.P(), Erv|Easgn)
} }
} }
...@@ -147,17 +145,17 @@ func walkrange(n *Node) { ...@@ -147,17 +145,17 @@ func walkrange(n *Node) {
n.Right = nil n.Right = nil
var v1 *Node var v1 *Node
if nodeSeqLen(n.List) != 0 { if n.List.Len() != 0 {
v1 = nodeSeqFirst(n.List) v1 = n.List.First()
} }
var v2 *Node var v2 *Node
if nodeSeqLen(n.List) > 1 && !isblank(nodeSeqSecond(n.List)) { if n.List.Len() > 1 && !isblank(n.List.Second()) {
v2 = nodeSeqSecond(n.List) v2 = n.List.Second()
} }
// n->list has no meaning anymore, clear it // n->list has no meaning anymore, clear it
// to avoid erroneous processing by racewalk. // to avoid erroneous processing by racewalk.
setNodeSeq(&n.List, nil) n.List.Set(nil)
var body []*Node var body []*Node
var init []*Node var init []*Node
...@@ -195,8 +193,8 @@ func walkrange(n *Node) { ...@@ -195,8 +193,8 @@ func walkrange(n *Node) {
body = []*Node{Nod(OAS, v1, hv1)} body = []*Node{Nod(OAS, v1, hv1)}
} else { } else {
a := Nod(OAS2, nil, nil) a := Nod(OAS2, nil, nil)
setNodeSeq(&a.List, []*Node{v1, v2}) a.List.Set([]*Node{v1, v2})
setNodeSeq(&a.Rlist, []*Node{hv1, Nod(OIND, hp, nil)}) a.Rlist.Set([]*Node{hv1, Nod(OIND, hp, nil)})
body = []*Node{a} body = []*Node{a}
// Advance pointer as part of increment. // Advance pointer as part of increment.
...@@ -215,7 +213,7 @@ func walkrange(n *Node) { ...@@ -215,7 +213,7 @@ func walkrange(n *Node) {
tmp.Right.Typecheck = 1 tmp.Right.Typecheck = 1
a = Nod(OAS, hp, tmp) a = Nod(OAS, hp, tmp)
typecheck(&a, Etop) typecheck(&a, Etop)
setNodeSeq(&n.Right.Ninit, []*Node{a}) n.Right.Ninit.Set([]*Node{a})
} }
// orderstmt allocated the iterator for us. // orderstmt allocated the iterator for us.
...@@ -250,8 +248,8 @@ func walkrange(n *Node) { ...@@ -250,8 +248,8 @@ func walkrange(n *Node) {
val := Nod(ODOT, hit, valname) val := Nod(ODOT, hit, valname)
val = Nod(OIND, val, nil) val = Nod(OIND, val, nil)
a := Nod(OAS2, nil, nil) a := Nod(OAS2, nil, nil)
setNodeSeq(&a.List, []*Node{v1, v2}) a.List.Set([]*Node{v1, v2})
setNodeSeq(&a.Rlist, []*Node{key, val}) a.Rlist.Set([]*Node{key, val})
body = []*Node{a} body = []*Node{a}
} }
...@@ -271,9 +269,9 @@ func walkrange(n *Node) { ...@@ -271,9 +269,9 @@ func walkrange(n *Node) {
n.Left = Nod(ONE, hb, Nodbool(false)) n.Left = Nod(ONE, hb, Nodbool(false))
a := Nod(OAS2RECV, nil, nil) a := Nod(OAS2RECV, nil, nil)
a.Typecheck = 1 a.Typecheck = 1
setNodeSeq(&a.List, []*Node{hv1, hb}) a.List.Set([]*Node{hv1, hb})
setNodeSeq(&a.Rlist, []*Node{Nod(ORECV, ha, nil)}) a.Rlist.Set([]*Node{Nod(ORECV, ha, nil)})
setNodeSeq(&n.Left.Ninit, []*Node{a}) n.Left.Ninit.Set([]*Node{a})
if v1 == nil { if v1 == nil {
body = nil body = nil
} else { } else {
...@@ -296,13 +294,13 @@ func walkrange(n *Node) { ...@@ -296,13 +294,13 @@ func walkrange(n *Node) {
} else { } else {
hv2 = temp(runetype) hv2 = temp(runetype)
a = Nod(OAS2, nil, nil) a = Nod(OAS2, nil, nil)
setNodeSeq(&a.List, []*Node{hv1, hv2}) a.List.Set([]*Node{hv1, hv2})
fn := syslook("stringiter2") fn := syslook("stringiter2")
setNodeSeq(&a.Rlist, []*Node{mkcall1(fn, fn.Type.Results(), nil, ha, hv1)}) a.Rlist.Set([]*Node{mkcall1(fn, fn.Type.Results(), nil, ha, hv1)})
} }
n.Left = Nod(ONE, hv1, Nodintconst(0)) n.Left = Nod(ONE, hv1, Nodintconst(0))
setNodeSeq(&n.Left.Ninit, []*Node{Nod(OAS, ohv1, hv1), a}) n.Left.Ninit.Set([]*Node{Nod(OAS, ohv1, hv1), a})
body = nil body = nil
if v1 != nil { if v1 != nil {
...@@ -315,7 +313,7 @@ func walkrange(n *Node) { ...@@ -315,7 +313,7 @@ func walkrange(n *Node) {
n.Op = OFOR n.Op = OFOR
typechecklist(init, Etop) typechecklist(init, Etop)
appendNodeSeq(&n.Ninit, init) n.Ninit.Append(init...)
typechecklist(n.Left.Ninit.Slice(), Etop) typechecklist(n.Left.Ninit.Slice(), Etop)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
typecheck(&n.Right, Etop) typecheck(&n.Right, Etop)
......
This diff is collapsed.
...@@ -30,8 +30,8 @@ func init1(n *Node, out *[]*Node) { ...@@ -30,8 +30,8 @@ func init1(n *Node, out *[]*Node) {
} }
init1(n.Left, out) init1(n.Left, out)
init1(n.Right, out) init1(n.Right, out)
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, n1 := range n.List.Slice() {
init1(it.N(), out) init1(n1, out)
} }
if n.Left != nil && n.Type != nil && n.Left.Op == OTYPE && n.Class == PFUNC { if n.Left != nil && n.Type != nil && n.Left.Op == OTYPE && n.Class == PFUNC {
...@@ -128,8 +128,8 @@ func init1(n *Node, out *[]*Node) { ...@@ -128,8 +128,8 @@ func init1(n *Node, out *[]*Node) {
break break
} }
defn.Initorder = InitPending defn.Initorder = InitPending
for it := nodeSeqIterate(defn.Rlist); !it.Done(); it.Next() { for _, n2 := range defn.Rlist.Slice() {
init1(it.N(), out) init1(n2, out)
} }
if Debug['%'] != 0 { if Debug['%'] != 0 {
Dump("nonstatic", defn) Dump("nonstatic", defn)
...@@ -192,7 +192,7 @@ func init2(n *Node, out *[]*Node) { ...@@ -192,7 +192,7 @@ func init2(n *Node, out *[]*Node) {
return return
} }
if n.Op == ONAME && nodeSeqLen(n.Ninit) != 0 { if n.Op == ONAME && n.Ninit.Len() != 0 {
Fatalf("name %v with ninit: %v\n", n.Sym, Nconv(n, obj.FmtSign)) Fatalf("name %v with ninit: %v\n", n.Sym, Nconv(n, obj.FmtSign))
} }
...@@ -213,23 +213,21 @@ func init2(n *Node, out *[]*Node) { ...@@ -213,23 +213,21 @@ func init2(n *Node, out *[]*Node) {
} }
func init2list(l Nodes, out *[]*Node) { func init2list(l Nodes, out *[]*Node) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l.Slice() {
init2(it.N(), out) init2(n, out)
} }
} }
func initreorder(l []*Node, out *[]*Node) { func initreorder(l []*Node, out *[]*Node) {
var n *Node var n *Node
for _, n = range l {
for it := nodeSeqIterate(l); !it.Done(); it.Next() {
n = it.N()
switch n.Op { switch n.Op {
case ODCLFUNC, ODCLCONST, ODCLTYPE: case ODCLFUNC, ODCLCONST, ODCLTYPE:
continue continue
} }
initreorder(n.Ninit.Slice(), out) initreorder(n.Ninit.Slice(), out)
setNodeSeq(&n.Ninit, nil) n.Ninit.Set(nil)
init1(n, out) init1(n, out)
} }
} }
...@@ -558,9 +556,8 @@ func getdyn(n *Node, top int) int { ...@@ -558,9 +556,8 @@ func getdyn(n *Node, top int) int {
case OSTRUCTLIT: case OSTRUCTLIT:
break break
} }
for _, n1 := range n.List.Slice() {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { value := n1.Right
value := it.N().Right
mode |= getdyn(value, 0) mode |= getdyn(value, 0)
if mode == MODEDYNAM|MODECONST { if mode == MODEDYNAM|MODECONST {
break break
...@@ -571,8 +568,7 @@ func getdyn(n *Node, top int) int { ...@@ -571,8 +568,7 @@ func getdyn(n *Node, top int) int {
} }
func structlit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) { func structlit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, r := range n.List.Slice() {
r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
Fatalf("structlit: rhs not OKEY: %v", r) Fatalf("structlit: rhs not OKEY: %v", r)
} }
...@@ -636,8 +632,7 @@ func structlit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) { ...@@ -636,8 +632,7 @@ func structlit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
} }
func arraylit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) { func arraylit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, r := range n.List.Slice() {
r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
Fatalf("arraylit: rhs not OKEY: %v", r) Fatalf("arraylit: rhs not OKEY: %v", r)
} }
...@@ -784,7 +779,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -784,7 +779,7 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
a = Nod(OADDR, a, nil) a = Nod(OADDR, a, nil)
} else { } else {
a = Nod(ONEW, nil, nil) a = Nod(ONEW, nil, nil)
setNodeSeq(&a.List, []*Node{typenod(t)}) a.List.Set([]*Node{typenod(t)})
} }
a = Nod(OAS, vauto, a) a = Nod(OAS, vauto, a)
...@@ -809,10 +804,8 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -809,10 +804,8 @@ func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
orderstmtinplace(&a) orderstmtinplace(&a)
walkstmt(&a) walkstmt(&a)
init.Append(a) init.Append(a)
// put dynamics into slice (6) // put dynamics into slice (6)
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, r := range n.List.Slice() {
r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
Fatalf("slicelit: rhs not OKEY: %v", r) Fatalf("slicelit: rhs not OKEY: %v", r)
} }
...@@ -858,13 +851,12 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -858,13 +851,12 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) {
nerr := nerrors nerr := nerrors
a := Nod(OMAKE, nil, nil) a := Nod(OMAKE, nil, nil)
setNodeSeq(&a.List, []*Node{typenod(n.Type)}) a.List.Set([]*Node{typenod(n.Type)})
litas(var_, a, init) litas(var_, a, init)
// count the initializers // count the initializers
b := 0 b := 0
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, r := range n.List.Slice() {
r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
Fatalf("maplit: rhs not OKEY: %v", r) Fatalf("maplit: rhs not OKEY: %v", r)
} }
...@@ -907,9 +899,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -907,9 +899,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) {
vstat := staticname(tarr, ctxt) vstat := staticname(tarr, ctxt)
b := int64(0) b := int64(0)
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, r := range n.List.Slice() {
r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
Fatalf("maplit: rhs not OKEY: %v", r) Fatalf("maplit: rhs not OKEY: %v", r)
} }
...@@ -965,7 +955,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -965,7 +955,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) {
a = Nod(OFOR, nil, nil) a = Nod(OFOR, nil, nil)
a.Nbody.Set([]*Node{r}) a.Nbody.Set([]*Node{r})
setNodeSeq(&a.Ninit, []*Node{Nod(OAS, index, Nodintconst(0))}) a.Ninit.Set([]*Node{Nod(OAS, index, Nodintconst(0))})
a.Left = Nod(OLT, index, Nodintconst(tarr.Bound)) a.Left = Nod(OLT, index, Nodintconst(tarr.Bound))
a.Right = Nod(OAS, index, Nod(OADD, index, Nodintconst(1))) a.Right = Nod(OAS, index, Nod(OADD, index, Nodintconst(1)))
...@@ -976,9 +966,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -976,9 +966,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) {
// put in dynamic entries one-at-a-time // put in dynamic entries one-at-a-time
var key, val *Node var key, val *Node
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, r := range n.List.Slice() {
r := it.N()
if r.Op != OKEY { if r.Op != OKEY {
Fatalf("maplit: rhs not OKEY: %v", r) Fatalf("maplit: rhs not OKEY: %v", r)
} }
...@@ -1065,7 +1053,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -1065,7 +1053,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) {
Fatalf("anylit: not struct") Fatalf("anylit: not struct")
} }
if simplename(var_) && nodeSeqLen(n.List) > 4 { if simplename(var_) && n.List.Len() > 4 {
if ctxt == 0 { if ctxt == 0 {
// lay out static data // lay out static data
vstat := staticname(t, ctxt) vstat := staticname(t, ctxt)
...@@ -1091,7 +1079,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -1091,7 +1079,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) {
} }
// initialize of not completely specified // initialize of not completely specified
if simplename(var_) || nodeSeqLen(n.List) < structcount(t) { if simplename(var_) || n.List.Len() < structcount(t) {
a := Nod(OAS, var_, nil) a := Nod(OAS, var_, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
...@@ -1109,7 +1097,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -1109,7 +1097,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) {
break break
} }
if simplename(var_) && nodeSeqLen(n.List) > 4 { if simplename(var_) && n.List.Len() > 4 {
if ctxt == 0 { if ctxt == 0 {
// lay out static data // lay out static data
vstat := staticname(t, ctxt) vstat := staticname(t, ctxt)
...@@ -1135,7 +1123,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) { ...@@ -1135,7 +1123,7 @@ func anylit(ctxt int, n *Node, var_ *Node, init *Nodes) {
} }
// initialize of not completely specified // initialize of not completely specified
if simplename(var_) || int64(nodeSeqLen(n.List)) < t.Bound { if simplename(var_) || int64(n.List.Len()) < t.Bound {
a := Nod(OAS, var_, nil) a := Nod(OAS, var_, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
...@@ -1257,8 +1245,7 @@ func initplan(n *Node) { ...@@ -1257,8 +1245,7 @@ func initplan(n *Node) {
Fatalf("initplan") Fatalf("initplan")
case OARRAYLIT: case OARRAYLIT:
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, a := range n.List.Slice() {
a := it.N()
if a.Op != OKEY || !Smallintconst(a.Left) { if a.Op != OKEY || !Smallintconst(a.Left) {
Fatalf("initplan arraylit") Fatalf("initplan arraylit")
} }
...@@ -1266,8 +1253,7 @@ func initplan(n *Node) { ...@@ -1266,8 +1253,7 @@ func initplan(n *Node) {
} }
case OSTRUCTLIT: case OSTRUCTLIT:
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, a := range n.List.Slice() {
a := it.N()
if a.Op != OKEY || a.Left.Type == nil { if a.Op != OKEY || a.Left.Type == nil {
Fatalf("initplan structlit") Fatalf("initplan structlit")
} }
...@@ -1275,8 +1261,7 @@ func initplan(n *Node) { ...@@ -1275,8 +1261,7 @@ func initplan(n *Node) {
} }
case OMAPLIT: case OMAPLIT:
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, a := range n.List.Slice() {
a := it.N()
if a.Op != OKEY { if a.Op != OKEY {
Fatalf("initplan maplit") Fatalf("initplan maplit")
} }
...@@ -1351,8 +1336,8 @@ func iszero(n *Node) bool { ...@@ -1351,8 +1336,8 @@ func iszero(n *Node) bool {
// fall through // fall through
case OSTRUCTLIT: case OSTRUCTLIT:
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for _, n1 := range n.List.Slice() {
if !iszero(it.N().Right) { if !iszero(n1.Right) {
return false return false
} }
} }
......
...@@ -510,8 +510,8 @@ func (s *state) stmts(a Nodes) { ...@@ -510,8 +510,8 @@ func (s *state) stmts(a Nodes) {
// ssaStmtList converts the statement n to SSA and adds it to s. // ssaStmtList converts the statement n to SSA and adds it to s.
func (s *state) stmtList(l Nodes) { func (s *state) stmtList(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l.Slice() {
s.stmt(it.N()) s.stmt(n)
} }
} }
...@@ -559,9 +559,9 @@ func (s *state) stmt(n *Node) { ...@@ -559,9 +559,9 @@ func (s *state) stmt(n *Node) {
s.call(n.Left, callGo) s.call(n.Left, callGo)
case OAS2DOTTYPE: case OAS2DOTTYPE:
res, resok := s.dottype(nodeSeqFirst(n.Rlist), true) res, resok := s.dottype(n.Rlist.First(), true)
s.assign(nodeSeqFirst(n.List), res, needwritebarrier(nodeSeqFirst(n.List), nodeSeqFirst(n.Rlist)), false, n.Lineno) s.assign(n.List.First(), res, needwritebarrier(n.List.First(), n.Rlist.First()), false, n.Lineno)
s.assign(nodeSeqSecond(n.List), resok, false, false, n.Lineno) s.assign(n.List.Second(), resok, false, false, n.Lineno)
return return
case ODCL: case ODCL:
...@@ -702,7 +702,7 @@ func (s *state) stmt(n *Node) { ...@@ -702,7 +702,7 @@ func (s *state) stmt(n *Node) {
bThen := s.f.NewBlock(ssa.BlockPlain) bThen := s.f.NewBlock(ssa.BlockPlain)
bEnd := s.f.NewBlock(ssa.BlockPlain) bEnd := s.f.NewBlock(ssa.BlockPlain)
var bElse *ssa.Block var bElse *ssa.Block
if nodeSeqLen(n.Rlist) != 0 { if n.Rlist.Len() != 0 {
bElse = s.f.NewBlock(ssa.BlockPlain) bElse = s.f.NewBlock(ssa.BlockPlain)
s.condBranch(n.Left, bThen, bElse, n.Likely) s.condBranch(n.Left, bThen, bElse, n.Likely)
} else { } else {
...@@ -715,7 +715,7 @@ func (s *state) stmt(n *Node) { ...@@ -715,7 +715,7 @@ func (s *state) stmt(n *Node) {
b.AddEdgeTo(bEnd) b.AddEdgeTo(bEnd)
} }
if nodeSeqLen(n.Rlist) != 0 { if n.Rlist.Len() != 0 {
s.startBlock(bElse) s.startBlock(bElse)
s.stmtList(n.Rlist) s.stmtList(n.Rlist)
if b := s.endBlock(); b != nil { if b := s.endBlock(); b != nil {
...@@ -2025,14 +2025,14 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -2025,14 +2025,14 @@ func (s *state) expr(n *Node) *ssa.Value {
pt := Ptrto(et) pt := Ptrto(et)
// Evaluate slice // Evaluate slice
slice := s.expr(nodeSeqFirst(n.List)) slice := s.expr(n.List.First())
// Allocate new blocks // Allocate new blocks
grow := s.f.NewBlock(ssa.BlockPlain) grow := s.f.NewBlock(ssa.BlockPlain)
assign := s.f.NewBlock(ssa.BlockPlain) assign := s.f.NewBlock(ssa.BlockPlain)
// Decide if we need to grow // Decide if we need to grow
nargs := int64(nodeSeqLen(n.List) - 1) nargs := int64(n.List.Len() - 1)
p := s.newValue1(ssa.OpSlicePtr, pt, slice) p := s.newValue1(ssa.OpSlicePtr, pt, slice)
l := s.newValue1(ssa.OpSliceLen, Types[TINT], slice) l := s.newValue1(ssa.OpSliceLen, Types[TINT], slice)
c := s.newValue1(ssa.OpSliceCap, Types[TINT], slice) c := s.newValue1(ssa.OpSliceCap, Types[TINT], slice)
......
...@@ -536,7 +536,7 @@ func treecopy(n *Node, lineno int32) *Node { ...@@ -536,7 +536,7 @@ func treecopy(n *Node, lineno int32) *Node {
m.Orig = m m.Orig = m
m.Left = treecopy(n.Left, lineno) m.Left = treecopy(n.Left, lineno)
m.Right = treecopy(n.Right, lineno) m.Right = treecopy(n.Right, lineno)
setNodeSeq(&m.List, listtreecopy(n.List.Slice(), lineno)) m.List.Set(listtreecopy(n.List.Slice(), lineno))
if lineno != 0 { if lineno != 0 {
m.Lineno = lineno m.Lineno = lineno
} }
...@@ -1379,7 +1379,7 @@ func ullmancalc(n *Node) { ...@@ -1379,7 +1379,7 @@ func ullmancalc(n *Node) {
var ul int var ul int
var ur int var ur int
if nodeSeqLen(n.Ninit) != 0 { if n.Ninit.Len() != 0 {
ul = UINF ul = UINF
goto out goto out
} }
...@@ -1497,7 +1497,7 @@ func safeexpr(n *Node, init *Nodes) *Node { ...@@ -1497,7 +1497,7 @@ func safeexpr(n *Node, init *Nodes) *Node {
return nil return nil
} }
if nodeSeqLen(n.Ninit) != 0 { if n.Ninit.Len() != 0 {
walkstmtlist(n.Ninit.Slice()) walkstmtlist(n.Ninit.Slice())
init.AppendNodes(&n.Ninit) init.AppendNodes(&n.Ninit)
} }
...@@ -1968,8 +1968,8 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -1968,8 +1968,8 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
l = append(l, pad) l = append(l, pad)
} }
setNodeSeq(&t.List, append(l, in...)) t.List.Set(append(l, in...))
setNodeSeq(&t.Rlist, out) t.Rlist.Set(out)
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
fn.Func.Nname = newname(newnam) fn.Func.Nname = newname(newnam)
...@@ -2008,7 +2008,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2008,7 +2008,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
v.U = method.Sym.Name v.U = method.Sym.Name
l = append(l, nodlit(v)) // method name l = append(l, nodlit(v)) // method name
call := Nod(OCALL, syslook("panicwrap"), nil) call := Nod(OCALL, syslook("panicwrap"), nil)
setNodeSeq(&call.List, l) call.List.Set(l)
n.Nbody.Set([]*Node{call}) n.Nbody.Set([]*Node{call})
fn.Nbody.Append(n) fn.Nbody.Append(n)
} }
...@@ -2031,11 +2031,11 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2031,11 +2031,11 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
} else { } else {
fn.Func.Wrapper = true // ignore frame for panic+recover matching fn.Func.Wrapper = true // ignore frame for panic+recover matching
call := Nod(OCALL, dot, nil) call := Nod(OCALL, dot, nil)
setNodeSeq(&call.List, args) call.List.Set(args)
call.Isddd = isddd call.Isddd = isddd
if method.Type.Outtuple > 0 { if method.Type.Outtuple > 0 {
n := Nod(ORETURN, nil, nil) n := Nod(ORETURN, nil, nil)
setNodeSeq(&n.List, []*Node{call}) n.List.Set([]*Node{call})
call = n call = n
} }
...@@ -2069,10 +2069,10 @@ func hashmem(t *Type) *Node { ...@@ -2069,10 +2069,10 @@ func hashmem(t *Type) *Node {
n := newname(sym) n := newname(sym)
n.Class = PFUNC n.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t)))) tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
appendNodeSeqNode(&tfn.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
typecheck(&tfn, Etype) typecheck(&tfn, Etype)
n.Type = tfn.Type n.Type = tfn.Type
return n return n
...@@ -2218,15 +2218,15 @@ func Simsimtype(t *Type) EType { ...@@ -2218,15 +2218,15 @@ func Simsimtype(t *Type) EType {
func listtreecopy(l []*Node, lineno int32) []*Node { func listtreecopy(l []*Node, lineno int32) []*Node {
var out []*Node var out []*Node
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for _, n := range l {
out = append(out, treecopy(it.N(), lineno)) out = append(out, treecopy(n, lineno))
} }
return out return out
} }
func liststmt(l []*Node) *Node { func liststmt(l []*Node) *Node {
n := Nod(OBLOCK, nil, nil) n := Nod(OBLOCK, nil, nil)
setNodeSeq(&n.List, l) n.List.Set(l)
if nodeSeqLen(l) != 0 { if nodeSeqLen(l) != 0 {
n.Lineno = nodeSeqFirst(l).Lineno n.Lineno = nodeSeqFirst(l).Lineno
} }
...@@ -2573,7 +2573,7 @@ func addinit(np **Node, init []*Node) { ...@@ -2573,7 +2573,7 @@ func addinit(np **Node, init []*Node) {
*np = n *np = n
} }
setNodeSeq(&n.Ninit, append(nodeSeqSlice(init), nodeSeqSlice(n.Ninit)...)) n.Ninit.Set(append(nodeSeqSlice(init), n.Ninit.Slice()...))
n.Ullman = UINF n.Ullman = UINF
} }
......
This diff is collapsed.
...@@ -429,6 +429,26 @@ func (n *Nodes) Slice() []*Node { ...@@ -429,6 +429,26 @@ func (n *Nodes) Slice() []*Node {
return *n.slice return *n.slice
} }
// Len returns the number of entries in Nodes.
func (n *Nodes) Len() int {
if n.slice == nil {
return 0
}
return len(*n.slice)
}
// First returns the first element of Nodes.
// It panics if Nodes has no elements.
func (n *Nodes) First() *Node {
return (*n.slice)[0]
}
// Second returns the second element of Nodes.
// It panics if Nodes has fewer than two elements.
func (n *Nodes) Second() *Node {
return (*n.slice)[1]
}
// NodeList returns the entries in Nodes as a NodeList. // NodeList returns the entries in Nodes as a NodeList.
// Changes to the NodeList entries (as in l.N = n) will *not* be // Changes to the NodeList entries (as in l.N = n) will *not* be
// reflected in the Nodes. // reflected in the Nodes.
......
This diff is collapsed.
...@@ -26,12 +26,12 @@ func unsafenmagic(nn *Node) *Node { ...@@ -26,12 +26,12 @@ func unsafenmagic(nn *Node) *Node {
return nil return nil
} }
if nodeSeqLen(args) == 0 { if args.Len() == 0 {
Yyerror("missing argument for %v", s) Yyerror("missing argument for %v", s)
return nil return nil
} }
r := nodeSeqFirst(args) r := args.First()
var v int64 var v int64
if s.Name == "Sizeof" { if s.Name == "Sizeof" {
...@@ -129,7 +129,7 @@ bad: ...@@ -129,7 +129,7 @@ bad:
goto ret goto ret
yes: yes:
if nodeSeqLen(args) > 1 { if args.Len() > 1 {
Yyerror("extra arguments for %v", s) Yyerror("extra arguments for %v", s)
} }
......
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