fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
- appendNodeSeqNode(&tfn.List, n)
+ tfn.List.Append(n)
np := n.Left
n = Nod(ODCLFIELD, newname(Lookup("h")), typenod(Types[TUINTPTR]))
- appendNodeSeqNode(&tfn.List, n)
+ tfn.List.Append(n)
nh := n.Left
n = Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])) // return value
- appendNodeSeqNode(&tfn.Rlist, n)
+ tfn.Rlist.Append(n)
funchdr(fn)
typecheck(&fn.Func.Nname.Name.Param.Ntype, Etype)
n := Nod(ORANGE, nil, Nod(OIND, np, nil))
ni := newname(Lookup("i"))
ni.Type = Types[TINT]
- setNodeSeq(&n.List, []*Node{ni})
+ n.List.Set([]*Node{ni})
n.Colas = true
colasdefn(n.List, n)
- ni = nodeSeqFirst(n.List)
+ ni = n.List.First()
// h = hashel(&p[i], h)
call := Nod(OCALL, hashel, nil)
nx.Bounded = true
na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap
- appendNodeSeqNode(&call.List, na)
- appendNodeSeqNode(&call.List, nh)
+ call.List.Append(na)
+ call.List.Append(nh)
n.Nbody.Append(Nod(OAS, nh, call))
fn.Nbody.Append(n)
nx := Nod(OXDOT, np, newname(f.Sym)) // TODO: fields from other packages?
na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap
- appendNodeSeqNode(&call.List, na)
- appendNodeSeqNode(&call.List, nh)
+ call.List.Append(na)
+ call.List.Append(nh)
fn.Nbody.Append(Nod(OAS, nh, call))
f = f.Down
continue
nx := Nod(OXDOT, np, newname(f.Sym)) // TODO: fields from other packages?
na := Nod(OADDR, nx, nil)
na.Etype = 1 // no escape to heap
- appendNodeSeqNode(&call.List, na)
- appendNodeSeqNode(&call.List, nh)
- appendNodeSeqNode(&call.List, Nodintconst(size))
+ call.List.Append(na)
+ call.List.Append(nh)
+ call.List.Append(Nodintconst(size))
fn.Nbody.Append(Nod(OAS, nh, call))
f = next
}
r := Nod(ORETURN, nil, nil)
- appendNodeSeqNode(&r.List, nh)
+ r.List.Append(nh)
fn.Nbody.Append(r)
if Debug['r'] != 0 {
n := newname(sym)
n.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil)
- appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
- appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
- appendNodeSeqNode(&tfn.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
+ tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
+ tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
+ tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
typecheck(&tfn, Etype)
n.Type = tfn.Type
return n
fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
- appendNodeSeqNode(&tfn.List, n)
+ tfn.List.Append(n)
np := n.Left
n = Nod(ODCLFIELD, newname(Lookup("q")), typenod(Ptrto(t)))
- appendNodeSeqNode(&tfn.List, n)
+ tfn.List.Append(n)
nq := n.Left
n = Nod(ODCLFIELD, nil, typenod(Types[TBOOL]))
- appendNodeSeqNode(&tfn.Rlist, n)
+ tfn.Rlist.Append(n)
funchdr(fn)
ni := newname(Lookup("i"))
ni.Type = Types[TINT]
- setNodeSeq(&nrange.List, []*Node{ni})
+ nrange.List.Set([]*Node{ni})
nrange.Colas = true
colasdefn(nrange.List, nrange)
- ni = nodeSeqFirst(nrange.List)
+ ni = nrange.List.First()
// if p[i] != q[i] { return false }
nx := Nod(OINDEX, np, ni)
nif := Nod(OIF, nil, nil)
nif.Left = Nod(ONE, nx, ny)
r := Nod(ORETURN, nil, nil)
- appendNodeSeqNode(&r.List, Nodbool(false))
+ r.List.Append(Nodbool(false))
nif.Nbody.Append(r)
nrange.Nbody.Append(nif)
fn.Nbody.Append(nrange)
// return true
ret := Nod(ORETURN, nil, nil)
- appendNodeSeqNode(&ret.List, Nodbool(true))
+ ret.List.Append(Nodbool(true))
fn.Nbody.Append(ret)
case TSTRUCT:
}
ret := Nod(ORETURN, nil, nil)
- appendNodeSeqNode(&ret.List, and)
+ ret.List.Append(and)
fn.Nbody.Append(ret)
}
typecheck(&ny, Erv)
call := Nod(OCALL, eqmemfunc(size, nx.Type.Type, &needsize), nil)
- appendNodeSeqNode(&call.List, nx)
- appendNodeSeqNode(&call.List, ny)
+ call.List.Append(nx)
+ call.List.Append(ny)
if needsize != 0 {
- appendNodeSeqNode(&call.List, Nodintconst(size))
+ call.List.Append(Nodintconst(size))
}
return call
// expressions
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.nodesOrNil(n.Left, n.Right)
p.nodeList(n.Nbody)
case ORANGE:
- if p.bool(nodeSeqLen(n.List) != 0) {
+ if p.bool(n.List.Len() != 0) {
p.nodeList(n.List)
}
p.node(n.Right)
p.nodeList(n.List)
case OCASE, OXCASE:
- if p.bool(nodeSeqLen(n.List) != 0) {
+ if p.bool(n.List.Len() != 0) {
p.nodeList(n.List)
}
p.nodeList(n.Nbody)
// expressions
case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if p.bool() {
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
}
n.Left, n.Right = p.nodesOrNil()
n.Type = p.typ()
n.Right = p.node()
case OADDSTR:
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
case OPTRLIT:
n.Left = p.node()
case OSTRUCTLIT:
n.Type = p.typ()
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
n.Implicit = p.bool()
case OARRAYLIT, OMAPLIT:
n.Type = p.typ()
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
n.Implicit = p.bool()
case OKEY:
// }
x := Nod(OCALL, p.typ().Nod, nil)
if p.bool() {
- setNodeSeq(&x.List, []*Node{p.node()})
+ x.List.Set([]*Node{p.node()})
} else {
- setNodeSeq(&x.List, p.nodeList())
+ x.List.Set(p.nodeList())
}
return x
case OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC,
ORECOVER, OPRINT, OPRINTN:
n.Left, _ = p.nodesOrNil()
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
n.Isddd = p.bool()
case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OGETG:
n.Left = p.node()
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
n.Isddd = p.bool()
case OCMPSTR, OCMPIFACE:
n.Etype = EType(p.int())
case OAS2, OASWB:
- setNodeSeq(&n.List, p.nodeList())
- setNodeSeq(&n.Rlist, p.nodeList())
+ n.List.Set(p.nodeList())
+ n.Rlist.Set(p.nodeList())
case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
- setNodeSeq(&n.List, p.nodeList())
- setNodeSeq(&n.Rlist, p.nodeList())
+ n.List.Set(p.nodeList())
+ n.Rlist.Set(p.nodeList())
case ORETURN:
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
case OPROC, ODEFER:
n.Left = p.node()
case OIF:
- setNodeSeq(&n.Ninit, p.nodeList())
+ n.Ninit.Set(p.nodeList())
n.Left = p.node()
n.Nbody.Set(p.nodeList())
- setNodeSeq(&n.Rlist, p.nodeList())
+ n.Rlist.Set(p.nodeList())
case OFOR:
- setNodeSeq(&n.Ninit, p.nodeList())
+ n.Ninit.Set(p.nodeList())
n.Left, n.Right = p.nodesOrNil()
n.Nbody.Set(p.nodeList())
case ORANGE:
if p.bool() {
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
}
n.Right = p.node()
n.Nbody.Set(p.nodeList())
case OSELECT, OSWITCH:
- setNodeSeq(&n.Ninit, p.nodeList())
+ n.Ninit.Set(p.nodeList())
n.Left, _ = p.nodesOrNil()
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
case OCASE, OXCASE:
if p.bool() {
- setNodeSeq(&n.List, p.nodeList())
+ n.List.Set(p.nodeList())
}
n.Nbody.Set(p.nodeList())
func bvgenjump(n, res *Node, wantTrue, geninit bool) {
init := n.Ninit
if !geninit {
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
}
p1 := Gbranch(obj.AJMP, nil, 0)
p2 := Pc
Bgen(n, wantTrue, 0, p2)
Thearch.Gmove(Nodbool(false), res)
Patch(p3, Pc)
- setNodeSeq(&n.Ninit, init)
+ n.Ninit.Set(init.Slice())
}
// bgenx is the backend for Bgen and Bvgen.
if Isfloat[nr.Type.Etype] {
// Brcom is not valid on floats when NaN is involved.
ll := n.Ninit // avoid re-genning Ninit
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
if genval {
bgenx(n, res, true, likely, to)
Thearch.Gins(Thearch.Optoas(OXOR, Types[TUINT8]), Nodintconst(1), res) // res = !res
- setNodeSeq(&n.Ninit, ll)
+ n.Ninit.Set(ll.Slice())
return
}
p1 := Gbranch(obj.AJMP, nil, 0)
bgenx(n, res, true, -likely, p2)
Patch(Gbranch(obj.AJMP, nil, 0), to)
Patch(p2, Pc)
- setNodeSeq(&n.Ninit, ll)
+ n.Ninit.Set(ll.Slice())
return
}
Dump("cgen_append-n", n)
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-res", res)
Fatalf("append not lowered")
}
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Ullman >= UINF {
+ for _, n1 := range n.List.Slice() {
+ if n1.Ullman >= UINF {
Fatalf("append with function call arguments")
}
}
//
// If res and src are the same, we can avoid writing to base and cap
// 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.
base := temp(Types[Tptr])
cap := temp(Types[TUINT])
var src Node
- Igen(nodeSeqFirst(n.List), &src, nil)
+ Igen(n.List.First(), &src, nil)
src.Type = Types[Tptr]
Thearch.Gmove(&src, base)
src.Type = Types[TUINT]
var rlen Node
Regalloc(&rlen, Types[TUINT], nil)
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)
// Note: rlen and src are Regrealloc'ed below at the target of the
// branch we just emitted; do not reuse these Go variables for
dst.Xoffset += int64(Widthptr)
Regalloc(&r1, Types[TUINT], nil)
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)
Regfree(&r1)
dst.Xoffset += int64(Widthptr)
// references to these variables need to
// refer to the variables in the external
// function declared below; see walkclosure.
- setNodeSeq(&n.List, ntype.List)
+ n.List.Set(ntype.List.Slice())
- setNodeSeq(&n.Rlist, ntype.Rlist)
- setNodeSeq(&ntype.List, nil)
- setNodeSeq(&ntype.Rlist, nil)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- name = it.N().Left
+ n.Rlist.Set(ntype.Rlist.Slice())
+ ntype.List.Set(nil)
+ ntype.Rlist.Set(nil)
+ for _, n1 := range n.List.Slice() {
+ name = n1.Left
if name != nil {
name = newname(name.Sym)
}
- a = Nod(ODCLFIELD, name, it.N().Right)
- a.Isddd = it.N().Isddd
+ a = Nod(ODCLFIELD, name, n1.Right)
+ a.Isddd = n1.Isddd
if name != nil {
name.Isddd = a.Isddd
}
- appendNodeSeqNode(&ntype.List, a)
+ ntype.List.Append(a)
}
-
- for it := nodeSeqIterate(n.Rlist); !it.Done(); it.Next() {
- name = it.N().Left
+ for _, n2 := range n.Rlist.Slice() {
+ name = n2.Left
if name != nil {
name = newname(name.Sym)
}
- appendNodeSeqNode(&ntype.Rlist, Nod(ODCLFIELD, name, it.N().Right))
+ ntype.Rlist.Append(Nod(ODCLFIELD, name, n2.Right))
}
}
// that begins by reading closure parameters.
xtype := Nod(OTFUNC, nil, nil)
- setNodeSeq(&xtype.List, func_.List)
- setNodeSeq(&xtype.Rlist, func_.Rlist)
+ xtype.List.Set(func_.List.Slice())
+ xtype.Rlist.Set(func_.Rlist.Slice())
// create the function
xfunc := Nod(ODCLFUNC, nil, nil)
func_.Func.Closure = xfunc
func_.Nbody.Set(nil)
- setNodeSeq(&func_.List, nil)
- setNodeSeq(&func_.Rlist, nil)
+ func_.List.Set(nil)
+ func_.Rlist.Set(nil)
return xfunc
}
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
for _, v := range func_.Func.Cvars.Slice() {
if v.Op == OXXX {
if !v.Name.Byval {
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.Esc = func_.Esc
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.
clos = Nod(OCONVNOP, clos, nil)
l = append(l, fld)
}
- setNodeSeq(&xtype.List, l)
+ xtype.List.Set(l)
i = 0
l = nil
var retargs []*Node
l = append(l, Nod(ODCLFIELD, n, typenod(t.Type)))
}
- setNodeSeq(&xtype.Rlist, l)
+ xtype.Rlist.Set(l)
xfunc.Func.Dupok = true
xfunc.Func.Nname = newfuncname(sym)
}
call := Nod(OCALL, Nod(OXDOT, ptr, meth), nil)
- setNodeSeq(&call.List, callargs)
+ call.List.Set(callargs)
call.Isddd = ddd
if t0.Outtuple == 0 {
body = append(body, call)
} else {
n := Nod(OAS2, nil, nil)
- setNodeSeq(&n.List, retargs)
- setNodeSeq(&n.Rlist, []*Node{call})
+ n.List.Set(retargs)
+ n.Rlist.Set([]*Node{call})
body = append(body, n)
n = Nod(ORETURN, nil, nil)
body = append(body, n)
}
typ := Nod(OTSTRUCT, nil, nil)
- setNodeSeq(&typ.List, []*Node{Nod(ODCLFIELD, newname(Lookup("F")), typenod(Types[TUINTPTR]))})
- appendNodeSeqNode(&typ.List, Nod(ODCLFIELD, newname(Lookup("R")), typenod(n.Left.Type)))
+ typ.List.Set([]*Node{Nod(ODCLFIELD, newname(Lookup("F")), typenod(Types[TUINTPTR]))})
+ typ.List.Append(Nod(ODCLFIELD, newname(Lookup("R")), typenod(n.Left.Type)))
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = n.Esc
clos.Right.Implicit = true
- setNodeSeq(&clos.List, []*Node{Nod(OCFUNC, n.Func.Nname, nil)})
- appendNodeSeqNode(&clos.List, n.Left)
+ clos.List.Set([]*Node{Nod(OCFUNC, n.Func.Nname, nil)})
+ clos.List.Append(n.Left)
// Force type conversion from *struct to the func type.
clos = Nod(OCONVNOP, clos, nil)
// merge adjacent constants in the argument list.
case OADDSTR:
- s := nodeSeqSlice(n.List)
+ s := n.List.Slice()
for i1 := 0; i1 < len(s); i1++ {
if Isconst(s[i1], CTSTR) && i1+1 < len(s) && Isconst(s[i1+1], CTSTR) {
// merge from i1 up to but not including i2
n.Op = OLITERAL
n.SetVal(s[0].Val())
} else {
- setNodeSeq(&n.List, s)
+ n.List.Set(s)
}
return
if hascallchan(n.Left) || hascallchan(n.Right) {
return true
}
-
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if hascallchan(it.N()) {
+ for _, n1 := range n.List.Slice() {
+ if hascallchan(n1) {
return true
}
}
- for it := nodeSeqIterate(n.Rlist); !it.Done(); it.Next() {
- if hascallchan(it.N()) {
+ for _, n2 := range n.Rlist.Slice() {
+ if hascallchan(n2) {
return true
}
}
e := el.N
as2 := Nod(OAS2, nil, nil)
setNodeSeq(&as2.List, vl)
- setNodeSeqNode(&as2.Rlist, e)
+ as2.Rlist.Set([]*Node{e})
var v *Node
for ; vl != nil; vl = vl.Next {
v = vl.N
}
func colasdefn(left Nodes, defn *Node) {
- for it := nodeSeqIterate(left); !it.Done(); it.Next() {
- if it.N().Sym != nil {
- it.N().Sym.Flags |= SymUniq
+ for _, n1 := range left.Slice() {
+ if n1.Sym != nil {
+ n1.Sym.Flags |= SymUniq
}
}
nnew := 0
nerr := 0
var n *Node
- for it := nodeSeqIterate(left); !it.Done(); it.Next() {
- n = it.N()
+ for i2, n2 := range left.Slice() {
+ n = n2
if isblank(n) {
continue
}
n = newname(n.Sym)
declare(n, dclcontext)
n.Name.Defn = defn
- appendNodeSeqNode(&defn.Ninit, Nod(ODCL, n, nil))
- *it.P() = n
+ defn.Ninit.Append(Nod(ODCL, n, nil))
+ left.Slice()[i2] = n
}
if nnew == 0 && nerr == 0 {
colasdefn(as.List, as)
// make the tree prettier; not necessary
- if nodeSeqLen(as.List) == 1 && nodeSeqLen(as.Rlist) == 1 {
- as.Left = nodeSeqFirst(as.List)
- as.Right = nodeSeqFirst(as.Rlist)
- setNodeSeq(&as.List, nil)
- setNodeSeq(&as.Rlist, nil)
+ if as.List.Len() == 1 && as.Rlist.Len() == 1 {
+ as.Left = as.List.First()
+ as.Right = as.Rlist.First()
+ as.List.Set(nil)
+ as.Rlist.Set(nil)
as.Op = OAS
}
// re-start the variable generation number
// we want to use small numbers for the return variables,
// so let them have the chunk starting at 1.
- vargen = nodeSeqLen(nt.Rlist)
+ vargen = nt.Rlist.Len()
// declare the receiver and in arguments.
// no n->defn because type checking of func header
}
var n *Node
- for it := nodeSeqIterate(nt.List); !it.Done(); it.Next() {
- n = it.N()
+ for _, n = range nt.List.Slice() {
if n.Op != ODCLFIELD {
Fatalf("funcargs in %v", Oconv(n.Op, 0))
}
}
// declare the out arguments.
- gen := nodeSeqLen(nt.List)
+ gen := nt.List.Len()
var i int = 0
var nn *Node
- for it := nodeSeqIterate(nt.Rlist); !it.Done(); it.Next() {
- n = it.N()
-
+ for _, n = range nt.Rlist.Slice() {
if n.Op != ODCLFIELD {
Fatalf("funcargs out %v", Oconv(n.Op, 0))
}
}
tp := &t.Type
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- f := interfacefield(it.N())
+ for _, n := range l {
+ f := interfacefield(n)
- if it.N().Left == nil && f.Type.Etype == TINTER {
+ if n.Left == nil && f.Type.Etype == TINTER {
// embedded interface, inline methods
for t1 := f.Type.Type; t1 != nil; t1 = t1.Down {
f = typ(TFIELD)
}
func (c *nowritebarrierrecChecker) visitcodelist(l Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- c.visitcode(it.N())
+ for _, n := range l.Slice() {
+ c.visitcode(n)
}
}
}
func (v *bottomUpVisitor) visitcodelist(l Nodes, min uint32) uint32 {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- min = v.visitcode(it.N(), min)
+ for _, n := range l.Slice() {
+ min = v.visitcode(n, min)
}
return min
}
var nonlooping Label
func escloopdepthlist(e *EscState, l Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- escloopdepth(e, it.N())
+ for _, n := range l.Slice() {
+ escloopdepth(e, n)
}
}
}
func esclist(e *EscState, l Nodes, up *Node) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- esc(e, it.N(), up)
+ for _, n := range l.Slice() {
+ esc(e, n, up)
}
}
// must happen before processing of switch body,
// so before recursion.
if n.Op == OSWITCH && n.Left != nil && n.Left.Op == OTYPESW {
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { // cases
+ for _, n1 := range n.List.Slice() { // cases
// it.N().Rlist is the variable per case
- if nodeSeqLen(it.N().Rlist) != 0 {
- e.nodeEscState(nodeSeqFirst(it.N().Rlist)).Escloopdepth = e.loopdepth
+ if n1.Rlist.Len() != 0 {
+ e.nodeEscState(n1.Rlist.First()).Escloopdepth = e.loopdepth
}
}
}
n.Left.Sym.Label = nil
case ORANGE:
- if nodeSeqLen(n.List) >= 2 {
+ if n.List.Len() >= 2 {
// Everything but fixed array is a dereference.
// If fixed array is really the address of fixed array,
// dereferenced (see #12588)
if Isfixedarray(n.Type) &&
!(Isptr[n.Right.Type.Etype] && Eqtype(n.Right.Type.Type, n.Type)) {
- escassign(e, nodeSeqSecond(n.List), n.Right)
+ escassign(e, n.List.Second(), n.Right)
} else {
- escassignDereference(e, nodeSeqSecond(n.List), n.Right)
+ escassignDereference(e, n.List.Second(), n.Right)
}
}
case OSWITCH:
if n.Left != nil && n.Left.Op == OTYPESW {
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
+ for _, n2 := range n.List.Slice() {
// cases
// n.Left.Right is the argument of the .(type),
// it.N().Rlist is the variable per case
- if nodeSeqLen(it.N().Rlist) != 0 {
- escassign(e, nodeSeqFirst(it.N().Rlist), n.Left.Right)
+ if n2.Rlist.Len() != 0 {
+ escassign(e, n2.Rlist.First(), n.Left.Right)
}
}
}
escassign(e, n.Left, n.Right)
case OAS2: // x,y = a,b
- if nodeSeqLen(n.List) == nodeSeqLen(n.Rlist) {
+ if n.List.Len() == n.Rlist.Len() {
lrit := nodeSeqIterate(n.Rlist)
- for llit := nodeSeqIterate(n.List); !llit.Done(); llit.Next() {
- escassign(e, llit.N(), lrit.N())
+ for _, n3 := range n.List.Slice() {
+ escassign(e, n3, lrit.N())
lrit.Next()
}
}
case OAS2RECV, // v, ok = <-ch
OAS2MAPR, // v, ok = m[k]
OAS2DOTTYPE: // v, ok = x.(type)
- escassign(e, nodeSeqFirst(n.List), nodeSeqFirst(n.Rlist))
+ escassign(e, n.List.First(), n.Rlist.First())
case OSEND: // ch <- x
escassign(e, &e.theSink, n.Right)
escassign(e, &e.theSink, n.Left.Left)
escassign(e, &e.theSink, n.Left.Right) // ODDDARG for call
- for it := nodeSeqIterate(n.Left.List); !it.Done(); it.Next() {
- escassign(e, &e.theSink, it.N())
+ for _, n4 := range n.Left.List.Slice() {
+ escassign(e, &e.theSink, n4)
}
case OCALLMETH, OCALLFUNC, OCALLINTER:
// esccall already done on n->rlist->n. tie it's escretval to n->list
case OAS2FUNC: // x,y = f()
- lrit := nodeSeqIterate(e.nodeEscState(nodeSeqFirst(n.Rlist)).Escretval)
+ lrit := nodeSeqIterate(e.nodeEscState(n.Rlist.First()).Escretval)
var llit nodeSeqIterator
for llit = nodeSeqIterate(n.List); !lrit.Done() && !llit.Done(); llit.Next() {
case ORETURN:
ll := n.List
- if nodeSeqLen(n.List) == 1 && Curfn.Type.Outtuple > 1 {
+ if n.List.Len() == 1 && Curfn.Type.Outtuple > 1 {
// OAS2FUNC in disguise
// esccall already done on n->list->n
// tie n->list->n->escretval to curfn->dcl PPARAMOUT's
- ll = e.nodeEscState(nodeSeqFirst(n.List)).Escretval
+ ll = e.nodeEscState(n.List.First()).Escretval
}
llit := nodeSeqIterate(ll)
}
} else {
// append(slice1, slice2...) -- slice2 itself does not escape, but contents do.
- slice2 := nodeSeqSecond(n.List)
+ slice2 := n.List.Second()
escassignDereference(e, &e.theSink, slice2) // lose track of assign of dereference
if Debug['m'] > 2 {
Warnl(n.Lineno, "%v special treatment of append(slice1, slice2...) %v", e.curfnSym(n), Nconv(n, obj.FmtShort))
}
}
- escassignDereference(e, &e.theSink, nodeSeqFirst(n.List)) // The original elements are now leaked, too
+ escassignDereference(e, &e.theSink, n.List.First()) // The original elements are now leaked, too
case OCOPY:
escassignDereference(e, &e.theSink, n.Right) // lose track of assign of dereference
// Slice itself is not leaked until proven otherwise
e.track(n)
}
-
// Link values to array/slice
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- escassign(e, n, it.N().Right)
+ for _, n5 := range n.List.Slice() {
+ escassign(e, n, n5.Right)
}
// Link values to struct.
case OSTRUCTLIT:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- escassign(e, n, it.N().Right)
+ for _, n6 := range n.List.Slice() {
+ escassign(e, n, n6.Right)
}
case OPTRLIT:
case OMAPLIT:
e.track(n)
-
// Keys and values make it to memory, lose track.
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- escassign(e, &e.theSink, it.N().Left)
- escassign(e, &e.theSink, it.N().Right)
+ for _, n7 := range n.List.Slice() {
+ escassign(e, &e.theSink, n7.Left)
+ escassign(e, &e.theSink, n7.Right)
}
// Link addresses of captured variables to closure.
// Flowing multiple returns to a single dst happens when
// analyzing "go f(g())": here g() flows to sink (issue 4529).
case OCALLMETH, OCALLFUNC, OCALLINTER:
- for it := nodeSeqIterate(e.nodeEscState(src).Escretval); !it.Done(); it.Next() {
- escflows(e, dst, it.N())
+ for _, n := range e.nodeEscState(src).Escretval.Slice() {
+ escflows(e, dst, n)
}
// A non-pointer escaping from a struct does not concern us.
case OAPPEND:
// Append returns first argument.
// Subsequent arguments are already leaked because they are operands to append.
- escassign(e, dst, nodeSeqFirst(src.List))
+ escassign(e, dst, src.List.First())
case OINDEX:
// Index of array preserves input value.
}
ll := n.List
- if nodeSeqLen(n.List) == 1 {
- a := nodeSeqFirst(n.List)
+ if n.List.Len() == 1 {
+ a := n.List.First()
if a.Type.Etype == TSTRUCT && a.Type.Funarg { // f(g()).
ll = e.nodeEscState(a).Escretval
}
if indirect {
// We know nothing!
// Leak all the parameters
- for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
- escassign(e, &e.theSink, it.N())
+ for _, n1 := range ll.Slice() {
+ escassign(e, &e.theSink, n1)
if Debug['m'] > 2 {
- fmt.Printf("%v::esccall:: indirect call <- %v, untracked\n", linestr(lineno), Nconv(it.N(), obj.FmtShort))
+ fmt.Printf("%v::esccall:: indirect call <- %v, untracked\n", linestr(lineno), Nconv(n1, obj.FmtShort))
}
}
// Set up bogus outputs
// function in same mutually recursive group. Incorporate into flow graph.
// print("esc local fn: %N\n", fn->ntype);
- if fn.Name.Defn.Esc == EscFuncUnknown || nodeSeqLen(nE.Escretval) != 0 {
+ if fn.Name.Defn.Esc == EscFuncUnknown || nE.Escretval.Len() != 0 {
Fatalf("graph inconsistency")
}
-
// set up out list on this call node
- for it := nodeSeqIterate(fn.Name.Param.Ntype.Rlist); !it.Done(); it.Next() {
- appendNodeSeqNode(&nE.Escretval, it.N().Left) // type.rlist -> dclfield -> ONAME (PPARAMOUT)
+ for _, n2 := range fn.Name.Param.Ntype.Rlist.Slice() {
+ nE.Escretval.Append(n2.Left) // type.rlist -> dclfield -> ONAME (PPARAMOUT)
}
// Receiver.
}
// Imported or completely analyzed function. Use the escape tags.
- if nodeSeqLen(nE.Escretval) != 0 {
+ if nE.Escretval.Len() != 0 {
Fatalf("esc already decorated call %v\n", Nconv(n, obj.FmtSign))
}
}
case OAPPEND:
- escwalk(e, level, dst, nodeSeqFirst(src.List))
+ escwalk(e, level, dst, src.List.First())
case ODDDARG:
if leaks {
if Isfixedarray(src.Type) {
break
}
- for it := nodeSeqIterate(src.List); !it.Done(); it.Next() {
- escwalk(e, level.dec(), dst, it.N().Right)
+ for _, n1 := range src.List.Slice() {
+ escwalk(e, level.dec(), dst, n1.Right)
}
fallthrough
// See e.g. #10466
// This can only happen with functions returning a single result.
case OCALLMETH, OCALLFUNC, OCALLINTER:
- if nodeSeqLen(srcE.Escretval) != 0 {
+ if srcE.Escretval.Len() != 0 {
if Debug['m'] > 1 {
fmt.Printf("%v:[%d] dst %v escwalk replace src: %v with %v\n",
linestr(lineno), e.loopdepth,
- Nconv(dst, obj.FmtShort), Nconv(src, obj.FmtShort), Nconv(nodeSeqFirst(srcE.Escretval), obj.FmtShort))
+ Nconv(dst, obj.FmtShort), Nconv(src, obj.FmtShort), Nconv(srcE.Escretval.First(), obj.FmtShort))
}
- src = nodeSeqFirst(srcE.Escretval)
+ src = srcE.Escretval.First()
srcE = e.nodeEscState(src)
}
}
// Look for anything we need for the inline body
func reexportdeplist(ll Nodes) {
- for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
- reexportdep(it.N())
+ for _, n := range ll.Slice() {
+ reexportdep(n)
}
}
// block starting with the init statements.
// 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
- 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
extrablock := complexinit && stmtwithinit(n.Op)
case OIF:
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 {
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 += "for"
if simpleinit {
- f += fmt.Sprintf(" %v;", nodeSeqFirst(n.Ninit))
+ f += fmt.Sprintf(" %v;", n.Ninit.First())
} else if n.Right != nil {
f += " ;"
}
break
}
- if nodeSeqLen(n.List) == 0 {
+ if n.List.Len() == 0 {
f += fmt.Sprintf("for range %v { %v }", n.Right, n.Nbody)
break
}
f += Oconv(n.Op, obj.FmtSharp)
if simpleinit {
- f += fmt.Sprintf(" %v;", nodeSeqFirst(n.Ninit))
+ f += fmt.Sprintf(" %v;", n.Ninit.First())
}
if n.Left != nil {
f += Nconv(n.Left, 0)
f += fmt.Sprintf(" { %v }", n.List)
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)
} else {
f += fmt.Sprintf("default: %v", n.Nbody)
return f
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))
}
if n.Right != nil {
case OADDSTR:
var f string
i := 0
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
+ for _, n1 := range n.List.Slice() {
if i != 0 {
f += " + "
}
- f += exprfmt(it.N(), nprec)
+ f += exprfmt(n1, nprec)
i++
}
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)
indent(&buf)
}
if n.Right != nil {
buf.WriteString(Nconv(n.Right, 0))
}
- if nodeSeqLen(n.List) != 0 {
+ if n.List.Len() != 0 {
indent(&buf)
fmt.Fprintf(&buf, "%v-list%v", Oconv(n.Op, 0), n.List)
}
- if nodeSeqLen(n.Rlist) != 0 {
+ if n.Rlist.Len() != 0 {
indent(&buf)
fmt.Fprintf(&buf, "%v-rlist%v", Oconv(n.Op, 0), n.Rlist)
}
// Fmt '%H': NodeList.
// Flags: all those of %N plus ',': separate with comma's instead of semicolons.
func Hconv(l Nodes, flag int) string {
- if nodeSeqLen(l) == 0 && fmtmode == FDbg {
+ if l.Len() == 0 && fmtmode == FDbg {
return "<nil>"
}
// compile statements
func Genlist(l Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- gen(it.N())
+ for _, n := range l.Slice() {
+ gen(n)
}
}
r1.Type = byteptr
r2.Type = byteptr
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)
Regfree(&r1)
Regfree(&r2)
dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil)
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)
Regfree(&r1)
Regfree(&r2)
goto ret
}
- if nodeSeqLen(n.Ninit) > 0 {
+ if n.Ninit.Len() > 0 {
Genlist(n.Ninit)
}
Cgen_as_wb(n.Left, n.Right, true)
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:
cgen_callmeth(n, 0)
// Look for anything we want to punt on.
func ishairylist(ll Nodes, budget *int) bool {
- for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
- if ishairy(it.N(), budget) {
+ for _, n := range ll.Slice() {
+ if ishairy(n, budget) {
return true
}
}
// the exportlist.
func inlcopylist(ll []*Node) []*Node {
s := make([]*Node, 0, nodeSeqLen(ll))
- for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
- s = append(s, inlcopy(it.N()))
+ for _, n := range ll {
+ s = append(s, inlcopy(n))
}
return s
}
}
m.Left = inlcopy(n.Left)
m.Right = inlcopy(n.Right)
- setNodeSeq(&m.List, inlcopylist(n.List.Slice()))
- setNodeSeq(&m.Rlist, inlcopylist(n.Rlist.Slice()))
- setNodeSeq(&m.Ninit, inlcopylist(n.Ninit.Slice()))
+ m.List.Set(inlcopylist(n.List.Slice()))
+ m.Rlist.Set(inlcopylist(n.Rlist.Slice()))
+ m.Ninit.Set(inlcopylist(n.Ninit.Slice()))
m.Nbody.Set(inlcopylist(n.Nbody.Slice()))
return m
n.Op = OBLOCK
// n->ninit stays
- setNodeSeq(&n.List, n.Nbody)
+ n.List.Set(n.Nbody.Slice())
n.Nbody.Set(nil)
- setNodeSeq(&n.Rlist, nil)
+ n.Rlist.Set(nil)
}
// Turn an OINLCALL into a single valued expression.
func inlconv2expr(np **Node) {
n := *np
- r := nodeSeqFirst(n.Rlist)
- addinit(&r, append(nodeSeqSlice(n.Ninit), n.Nbody.Slice()...))
+ r := n.Rlist.First()
+ addinit(&r, append(n.Ninit.Slice(), n.Nbody.Slice()...))
*np = r
}
// order will be preserved Used in return, oas2func and call
// statements.
func inlconv2list(n *Node) []*Node {
- if n.Op != OINLCALL || nodeSeqLen(n.Rlist) == 0 {
+ if n.Op != OINLCALL || n.Rlist.Len() == 0 {
Fatalf("inlconv2list %v\n", Nconv(n, obj.FmtSign))
}
- s := nodeSeqSlice(n.Rlist)
- addinit(&s[0], append(nodeSeqSlice(n.Ninit), n.Nbody.Slice()...))
+ s := n.Rlist.Slice()
+ addinit(&s[0], append(n.Ninit.Slice(), n.Nbody.Slice()...))
return s
}
func inlnodelist(l Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- inlnode(it.P())
+ for i := range l.Slice() {
+ inlnode(&l.Slice()[i])
}
}
lno := setlineno(n)
inlnodelist(n.Ninit)
- for it := nodeSeqIterate(n.Ninit); !it.Done(); it.Next() {
- if it.N().Op == OINLCALL {
- inlconv2stmt(it.N())
+ for _, n1 := range n.Ninit.Slice() {
+ if n1.Op == OINLCALL {
+ inlconv2stmt(n1)
}
}
inlnodelist(n.List)
switch n.Op {
case OBLOCK:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op == OINLCALL {
- inlconv2stmt(it.N())
+ for _, n2 := range n.List.Slice() {
+ if n2.Op == OINLCALL {
+ inlconv2stmt(n2)
}
}
OCALLINTER,
OAPPEND,
OCOMPLEX:
- if nodeSeqLen(n.List) == 1 && nodeSeqFirst(n.List).Op == OINLCALL && nodeSeqLen(nodeSeqFirst(n.List).Rlist) > 1 {
- setNodeSeq(&n.List, inlconv2list(nodeSeqFirst(n.List)))
+ if n.List.Len() == 1 && n.List.First().Op == OINLCALL && n.List.First().Rlist.Len() > 1 {
+ n.List.Set(inlconv2list(n.List.First()))
break
}
fallthrough
default:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op == OINLCALL {
- inlconv2expr(it.P())
+ for i3, n3 := range n.List.Slice() {
+ if n3.Op == OINLCALL {
+ inlconv2expr(&n.List.Slice()[i3])
}
}
}
inlnodelist(n.Rlist)
switch n.Op {
case OAS2FUNC:
- if nodeSeqFirst(n.Rlist).Op == OINLCALL {
- setNodeSeq(&n.Rlist, inlconv2list(nodeSeqFirst(n.Rlist)))
+ if n.Rlist.First().Op == OINLCALL {
+ n.Rlist.Set(inlconv2list(n.Rlist.First()))
n.Op = OAS2
n.Typecheck = 0
typecheck(np, Etop)
fallthrough
default:
- for it := nodeSeqIterate(n.Rlist); !it.Done(); it.Next() {
- if it.N().Op == OINLCALL {
+ for i4, n4 := range n.Rlist.Slice() {
+ if n4.Op == OINLCALL {
if n.Op == OIF {
- inlconv2stmt(it.N())
+ inlconv2stmt(n4)
} else {
- inlconv2expr(it.P())
+ inlconv2expr(&n.Rlist.Slice()[i4])
}
}
}
typecheck(&ln.Name.Inlvar, Erv)
if ln.Class&^PHEAP != PAUTO {
- appendNodeSeqNode(&ninit, Nod(ODCL, ln.Name.Inlvar, nil)) // otherwise gen won't emit the allocations for heapallocs
+ ninit.Append(Nod(ODCL, ln.Name.Inlvar, nil)) // otherwise gen won't emit the allocations for heapallocs
}
}
}
i++
}
- appendNodeSeqNode(&ninit, Nod(ODCL, m, nil))
+ ninit.Append(Nod(ODCL, m, nil))
inlretvars = list(inlretvars, m)
}
as = Nod(OAS, tinlvar(t), n.Left.Left)
if as != nil {
typecheck(&as, Etop)
- appendNodeSeqNode(&ninit, as)
+ ninit.Append(as)
}
}
// check if argument is actually a returned tuple from call.
multiret := 0
- if nodeSeqLen(n.List) == 1 {
- switch nodeSeqFirst(n.List).Op {
+ if n.List.Len() == 1 {
+ switch n.List.First().Op {
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH:
- if nodeSeqFirst(n.List).Left.Type.Outtuple > 1 {
- multiret = nodeSeqFirst(n.List).Left.Type.Outtuple - 1
+ if n.List.First().Left.Type.Outtuple > 1 {
+ multiret = n.List.First().Left.Type.Outtuple - 1
}
}
}
if variadic {
- varargcount = nodeSeqLen(n.List) + multiret
+ varargcount = n.List.Len() + multiret
if n.Left.Op != ODOTMETH {
varargcount -= fn.Type.Thistuple
}
// assign arguments to the parameters' temp names
as = Nod(OAS2, nil, nil)
- setNodeSeq(&as.Rlist, n.List)
+ as.Rlist.Set(n.List.Slice())
it := nodeSeqIterate(n.List)
// TODO: if len(nlist) == 1 but multiple args, check that n->list->n is a call?
if fn.Type.Thistuple != 0 && n.Left.Op != ODOTMETH {
// non-method call to method
- if nodeSeqLen(n.List) == 0 {
+ if n.List.Len() == 0 {
Fatalf("non-method call to method without first arg: %v", Nconv(n, obj.FmtSign))
}
if t == nil {
Fatalf("method call unknown receiver type: %v", Nconv(n, obj.FmtSign))
}
- appendNodeSeqNode(&as.List, tinlvar(t))
+ as.List.Append(tinlvar(t))
it.Next() // track argument count.
}
// append ordinary arguments to LHS.
- chkargcount := nodeSeqLen(n.List) > 1
+ chkargcount := n.List.Len() > 1
var vararg *Node // the slice argument to a variadic call
var varargs []*Node // the list of LHS names to put in vararg.
for i = 0; i < varargcount && it.Len() != 0; i++ {
m = argvar(varargtype, i)
varargs = append(varargs, m)
- appendNodeSeqNode(&as.List, m)
+ as.List.Append(m)
}
break
}
- appendNodeSeqNode(&as.List, tinlvar(t))
+ as.List.Append(tinlvar(t))
}
} else {
// match arguments except final variadic (unless the call is dotted itself)
if variadic && t.Isddd {
break
}
- appendNodeSeqNode(&as.List, tinlvar(t))
+ as.List.Append(tinlvar(t))
t = t.Down
it.Next()
}
for i = 0; i < varargcount && !it.Done(); i++ {
m = argvar(varargtype, i)
varargs = append(varargs, m)
- appendNodeSeqNode(&as.List, m)
+ as.List.Append(m)
it.Next()
}
}
}
- if nodeSeqLen(as.Rlist) != 0 {
+ if as.Rlist.Len() != 0 {
typecheck(&as, Etop)
- appendNodeSeqNode(&ninit, as)
+ ninit.Append(as)
}
// turn the variadic args into a slice.
vararrtype.Bound = int64(varargcount)
as.Right = Nod(OCOMPLIT, nil, typenod(varargtype))
- setNodeSeq(&as.Right.List, varargs)
+ as.Right.List.Set(varargs)
as.Right = Nod(OSLICE, as.Right, Nod(OKEY, nil, nil))
}
typecheck(&as, Etop)
- appendNodeSeqNode(&ninit, as)
+ ninit.Append(as)
}
// zero the outparams
for ll := inlretvars; ll != nil; ll = ll.Next {
as = Nod(OAS, ll.N, nil)
typecheck(&as, Etop)
- appendNodeSeqNode(&ninit, as)
+ ninit.Append(as)
}
inlretlabel = newlabel_inl()
call := Nod(OINLCALL, nil, nil)
- setNodeSeq(&call.Ninit, ninit)
+ call.Ninit.Set(ninit.Slice())
call.Nbody.Set(body)
setNodeSeq(&call.Rlist, inlretvars)
call.Type = n.Type
// Hide the args from setlno -- the parameters to the inlined
// call already have good line numbers that should be preserved.
args := as.Rlist
- setNodeSeq(&as.Rlist, nil)
+ as.Rlist.Set(nil)
setlno(call, n.Lineno)
- setNodeSeq(&as.Rlist, args)
+ as.Rlist.Set(args.Slice())
//dumplist("call body", body);
// to input/output parameters with ones to the tmpnames, and
// substituting returns with assignments to the output.
func inlsubstlist(ll Nodes) []*Node {
- s := make([]*Node, 0, nodeSeqLen(ll))
- for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
- s = append(s, inlsubst(it.N()))
+ s := make([]*Node, 0, ll.Len())
+ for _, n := range ll.Slice() {
+ s = append(s, inlsubst(n))
}
return s
}
case ORETURN:
m := Nod(OGOTO, inlretlabel, nil)
- setNodeSeq(&m.Ninit, inlsubstlist(n.Ninit))
+ m.Ninit.Set(inlsubstlist(n.Ninit))
- if inlretvars != nil && nodeSeqLen(n.List) != 0 {
+ if inlretvars != nil && n.List.Len() != 0 {
as := Nod(OAS2, nil, nil)
// shallow copy or OINLCALL->rlist will be the same list, and later walk and typecheck may clobber that.
for ll := inlretvars; ll != nil; ll = ll.Next {
- appendNodeSeqNode(&as.List, ll.N)
+ as.List.Append(ll.N)
}
- setNodeSeq(&as.Rlist, inlsubstlist(n.List))
+ as.Rlist.Set(inlsubstlist(n.List))
typecheck(&as, Etop)
- appendNodeSeqNode(&m.Ninit, as)
+ m.Ninit.Append(as)
}
typechecklist(m.Ninit.Slice(), Etop)
case OGOTO, OLABEL:
m := Nod(OXXX, nil, nil)
*m = *n
- setNodeSeq(&m.Ninit, nil)
+ m.Ninit.Set(nil)
p := fmt.Sprintf("%s·%d", n.Left.Sym.Name, inlgen)
m.Left = newname(Lookup(p))
m := Nod(OXXX, nil, nil)
*m = *n
- setNodeSeq(&m.Ninit, nil)
+ m.Ninit.Set(nil)
if n.Op == OCLOSURE {
Fatalf("cannot inline function containing closure: %v", Nconv(n, obj.FmtSign))
m.Left = inlsubst(n.Left)
m.Right = inlsubst(n.Right)
- setNodeSeq(&m.List, inlsubstlist(n.List))
- setNodeSeq(&m.Rlist, inlsubstlist(n.Rlist))
- setNodeSeq(&m.Ninit, append(nodeSeqSlice(m.Ninit), inlsubstlist(n.Ninit)...))
+ m.List.Set(inlsubstlist(n.List))
+ m.Rlist.Set(inlsubstlist(n.Rlist))
+ m.Ninit.Set(append(m.Ninit.Slice(), inlsubstlist(n.Ninit)...))
m.Nbody.Set(inlsubstlist(n.Nbody))
return m
// Plaster over linenumbers
func setlnolist(ll Nodes, lno int32) {
- for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
- setlno(it.N(), lno)
+ for _, n := range ll.Slice() {
+ setlno(n, lno)
}
}
// Orderstmtlist orders each of the statements in the list.
func orderstmtlist(l Nodes, order *Order) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- orderstmt(it.N(), order)
+ for _, n := range l.Slice() {
+ orderstmt(n, order)
}
}
// Orderinit moves n's init list to order->out.
func orderinit(n *Node, order *Order) {
orderstmtlist(n.Ninit, order)
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
}
// Ismulticall reports whether the list l is f() for a multi-value function.
// Such an f() could appear as the lone argument to a multi-arg function.
func ismulticall(l Nodes) bool {
// one arg only
- if nodeSeqLen(l) != 1 {
+ if l.Len() != 1 {
return false
}
- n := nodeSeqFirst(l)
+ n := l.First()
// must be call
switch n.Op {
func ordercallargs(l Nodes, order *Order) Nodes {
if ismulticall(l) {
// return f() where f() is multiple values.
- return copyret(nodeSeqFirst(l), order)
+ return copyret(l.First(), order)
} else {
orderexprlist(l, order)
return l
var post []*Node
var m *Node
var a *Node
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op == OINDEXMAP {
- m = it.N()
+ for i1, n1 := range n.List.Slice() {
+ if n1.Op == OINDEXMAP {
+ m = n1
if !istemp(m.Left) {
m.Left = ordercopyexpr(m.Left, m.Left.Type, order, 0)
}
if !istemp(m.Right) {
m.Right = ordercopyexpr(m.Right, m.Right.Type, order, 0)
}
- *it.P() = ordertemp(m.Type, order, false)
- a = Nod(OAS, m, it.N())
+ n.List.Slice()[i1] = ordertemp(m.Type, order, false)
+ a = Nod(OAS, m, n.List.Slice()[i1])
typecheck(&a, Etop)
post = append(post, a)
- } else if instrumenting && n.Op == OAS2FUNC && !isblank(it.N()) {
- m = it.N()
- *it.P() = ordertemp(m.Type, order, false)
- a = Nod(OAS, m, it.N())
+ } else if instrumenting && n.Op == OAS2FUNC && !isblank(n.List.Slice()[i1]) {
+ m = n.List.Slice()[i1]
+ n.List.Slice()[i1] = ordertemp(m.Type, order, false)
+ a = Nod(OAS, m, n.List.Slice()[i1])
typecheck(&a, Etop)
post = append(post, a)
}
t := marktemp(order)
orderexprlist(n.List, order)
- r := nodeSeqFirst(n.Rlist)
+ r := n.Rlist.First()
orderexpr(&r.Left, order, nil)
orderexpr(&r.Right, order, nil)
t := marktemp(order)
orderexprlist(n.List, order)
- ordercall(nodeSeqFirst(n.Rlist), order)
+ ordercall(n.Rlist.First(), order)
ordermapassign(n, order)
cleantemp(t, order)
t := marktemp(order)
orderexprlist(n.List, order)
- orderexpr(&nodeSeqFirst(n.Rlist).Left, order, nil) // i in i.(T)
- if isblank(nodeSeqFirst(n.List)) {
+ orderexpr(&n.Rlist.First().Left, order, nil) // i in i.(T)
+ if isblank(n.List.First()) {
order.out = append(order.out, n)
} else {
- typ := nodeSeqFirst(n.Rlist).Type
+ typ := n.Rlist.First().Type
tmp1 := ordertemp(typ, order, haspointers(typ))
order.out = append(order.out, n)
- r := Nod(OAS, nodeSeqFirst(n.List), tmp1)
+ r := Nod(OAS, n.List.First(), tmp1)
typecheck(&r, Etop)
ordermapassign(r, order)
- setNodeSeq(&n.List, []*Node{tmp1, nodeSeqSecond(n.List)})
+ n.List.Set([]*Node{tmp1, n.List.Second()})
}
cleantemp(t, order)
t := marktemp(order)
orderexprlist(n.List, order)
- orderexpr(&nodeSeqFirst(n.Rlist).Left, order, nil) // arg to recv
- ch := nodeSeqFirst(n.Rlist).Left.Type
+ orderexpr(&n.Rlist.First().Left, order, nil) // arg to recv
+ ch := n.Rlist.First().Left.Type
tmp1 := ordertemp(ch.Type, order, haspointers(ch.Type))
var tmp2 *Node
- if !isblank(nodeSeqSecond(n.List)) {
- tmp2 = ordertemp(nodeSeqSecond(n.List).Type, order, false)
+ if !isblank(n.List.Second()) {
+ tmp2 = ordertemp(n.List.Second().Type, order, false)
} else {
tmp2 = ordertemp(Types[TBOOL], order, false)
}
order.out = append(order.out, n)
- r := Nod(OAS, nodeSeqFirst(n.List), tmp1)
+ r := Nod(OAS, n.List.First(), tmp1)
typecheck(&r, Etop)
ordermapassign(r, order)
- r = Nod(OAS, nodeSeqSecond(n.List), tmp2)
+ r = Nod(OAS, n.List.Second(), tmp2)
typecheck(&r, Etop)
ordermapassign(r, order)
- setNodeSeq(&n.List, []*Node{tmp1, tmp2})
+ n.List.Set([]*Node{tmp1, tmp2})
cleantemp(t, order)
// Special: does not save n onto out.
n.Nbody.Set(append(l, n.Nbody.Slice()...))
l = nil
cleantempnopop(t, order, &l)
- setNodeSeq(&n.Rlist, append(l, nodeSeqSlice(n.Rlist)...))
+ n.Rlist.Set(append(l, n.Rlist.Slice()...))
poptemp(t, order)
orderblockNodes(&n.Nbody)
- setNodeSeq(&n.Rlist, orderblock(n.Rlist))
+ n.Rlist.Set(orderblock(n.Rlist))
order.out = append(order.out, n)
// Special: argument will be converted to interface using convT2E
if n.Right.Op == OSTRARRAYBYTE {
n.Right.Op = OSTRARRAYBYTETMP
}
- if nodeSeqLen(n.List) < 2 || isblank(nodeSeqSecond(n.List)) {
+ if n.List.Len() < 2 || isblank(n.List.Second()) {
// for i := range x will only use x once, to compute len(x).
// No need to copy it.
break
// n->alloc is the temp for the iterator.
prealloc[n] = ordertemp(Types[TUINT8], order, true)
}
-
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- orderexprinplace(it.P(), order)
+ for i1 := range n.List.Slice() {
+ orderexprinplace(&n.List.Slice()[i1], order)
}
orderblockNodes(&n.Nbody)
order.out = append(order.out, n)
var tmp1 *Node
var tmp2 *Node
var r *Node
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op != OXCASE {
- Fatalf("order select case %v", Oconv(it.N().Op, 0))
+ for _, n2 := range n.List.Slice() {
+ if n2.Op != OXCASE {
+ Fatalf("order select case %v", Oconv(n2.Op, 0))
}
- r = it.N().Left
- setlineno(it.N())
+ r = n2.Left
+ setlineno(n2)
// Append any new body prologue to ninit.
// The next loop will insert ninit into nbody.
- if nodeSeqLen(it.N().Ninit) != 0 {
+ if n2.Ninit.Len() != 0 {
Fatalf("order select ninit")
}
if r != nil {
if itinit.Len() != 0 && itinit.N().Op == ODCL && itinit.N().Left == r.Left {
itinit.Next()
}
- if itinit.Len() != 0 && itinit.N().Op == ODCL && nodeSeqLen(r.List) != 0 && itinit.N().Left == nodeSeqFirst(r.List) {
+ if itinit.Len() != 0 && itinit.N().Op == ODCL && r.List.Len() != 0 && itinit.N().Left == r.List.First() {
itinit.Next()
}
if itinit.Done() {
- setNodeSeq(&r.Ninit, nil)
+ r.Ninit.Set(nil)
}
}
- if nodeSeqLen(r.Ninit) != 0 {
+ if r.Ninit.Len() != 0 {
Yyerror("ninit on select recv")
dumplist("ninit", r.Ninit)
}
if r.Colas {
tmp2 = Nod(ODCL, tmp1, nil)
typecheck(&tmp2, Etop)
- appendNodeSeqNode(&it.N().Ninit, tmp2)
+ n2.Ninit.Append(tmp2)
}
r.Left = ordertemp(r.Right.Left.Type.Type, order, haspointers(r.Right.Left.Type.Type))
tmp2 = Nod(OAS, tmp1, r.Left)
typecheck(&tmp2, Etop)
- appendNodeSeqNode(&it.N().Ninit, tmp2)
+ n2.Ninit.Append(tmp2)
}
- if nodeSeqLen(r.List) != 0 && isblank(nodeSeqFirst(r.List)) {
- setNodeSeq(&r.List, nil)
+ if r.List.Len() != 0 && isblank(r.List.First()) {
+ r.List.Set(nil)
}
- if nodeSeqLen(r.List) != 0 {
- tmp1 = nodeSeqFirst(r.List)
+ if r.List.Len() != 0 {
+ tmp1 = r.List.First()
if r.Colas {
tmp2 = Nod(ODCL, tmp1, nil)
typecheck(&tmp2, Etop)
- appendNodeSeqNode(&it.N().Ninit, tmp2)
+ n2.Ninit.Append(tmp2)
}
setNodeSeq(&r.List, list1(ordertemp(tmp1.Type, order, false)))
- tmp2 = Nod(OAS, tmp1, nodeSeqFirst(r.List))
+ tmp2 = Nod(OAS, tmp1, r.List.First())
typecheck(&tmp2, Etop)
- appendNodeSeqNode(&it.N().Ninit, tmp2)
+ n2.Ninit.Append(tmp2)
}
-
- setNodeSeq(&it.N().Ninit, orderblock(it.N().Ninit))
+ n2.Ninit.Set(orderblock(n2.Ninit))
case OSEND:
- if nodeSeqLen(r.Ninit) != 0 {
+ if r.Ninit.Len() != 0 {
Yyerror("ninit on select send")
dumplist("ninit", r.Ninit)
}
}
}
- orderblockNodes(&it.N().Nbody)
+ orderblockNodes(&n2.Nbody)
}
-
// Now that we have accumulated all the temporaries, clean them.
// Also insert any ninit queued during the previous loop.
// (The temporary cleaning must follow that ninit work.)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- s := nodeSeqSlice(it.N().Ninit)
+ for _, n3 := range n.List.Slice() {
+ s := n3.Ninit.Slice()
cleantempnopop(t, order, &s)
- it.N().Nbody.Set(append(s, it.N().Nbody.Slice()...))
- setNodeSeq(&it.N().Ninit, nil)
+ n3.Nbody.Set(append(s, n3.Nbody.Slice()...))
+ n3.Ninit.Set(nil)
}
order.out = append(order.out, n)
t := marktemp(order)
orderexpr(&n.Left, order, nil)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op != OXCASE {
- Fatalf("order switch case %v", Oconv(it.N().Op, 0))
+ for _, n4 := range n.List.Slice() {
+ if n4.Op != OXCASE {
+ Fatalf("order switch case %v", Oconv(n4.Op, 0))
}
- orderexprlistinplace(it.N().List, order)
- orderblockNodes(&it.N().Nbody)
+ orderexprlistinplace(n4.List, order)
+ orderblockNodes(&n4.Nbody)
}
order.out = append(order.out, n)
// Orderexprlist orders the expression list l into order.
func orderexprlist(l Nodes, order *Order) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- orderexpr(it.P(), order, nil)
+ for i := range l.Slice() {
+ orderexpr(&l.Slice()[i], order, nil)
}
}
// Orderexprlist orders the expression list l but saves
// the side effects on the individual expression ninit lists.
func orderexprlistinplace(l Nodes, order *Order) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- orderexprinplace(it.P(), order)
+ for i := range l.Slice() {
+ orderexprinplace(&l.Slice()[i], order)
}
}
case OADDSTR:
orderexprlist(n.List, order)
- if nodeSeqLen(n.List) > 5 {
+ if n.List.Len() > 5 {
t := typ(TARRAY)
- t.Bound = int64(nodeSeqLen(n.List))
+ t.Bound = int64(n.List.Len())
t.Type = Types[TSTRING]
prealloc[n] = ordertemp(t, order, false)
}
hasbyte := false
haslit := false
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- hasbyte = hasbyte || it.N().Op == OARRAYBYTESTR
- haslit = haslit || it.N().Op == OLITERAL && len(it.N().Val().U.(string)) != 0
+ for _, n1 := range n.List.Slice() {
+ hasbyte = hasbyte || n1.Op == OARRAYBYTESTR
+ haslit = haslit || n1.Op == OLITERAL && len(n1.Val().U.(string)) != 0
}
if haslit && hasbyte {
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op == OARRAYBYTESTR {
- it.N().Op = OARRAYBYTESTRTMP
+ for _, n2 := range n.List.Slice() {
+ if n2.Op == OARRAYBYTESTR {
+ n2.Op = OARRAYBYTESTRTMP
}
}
}
var s []*Node
cleantempnopop(mark, order, &s)
- setNodeSeq(&n.Right.Ninit, append(s, nodeSeqSlice(n.Right.Ninit)...))
+ n.Right.Ninit.Set(append(s, n.Right.Ninit.Slice()...))
orderexprinplace(&n.Right, order)
case OCALLFUNC,
case OAPPEND:
setNodeSeq(&n.List, ordercallargs(n.List, order))
- if lhs == nil || lhs.Op != ONAME && !samesafeexpr(lhs, nodeSeqFirst(n.List)) {
+ if lhs == nil || lhs.Op != ONAME && !samesafeexpr(lhs, n.List.First()) {
n = ordercopyexpr(n, n.Type, order, 0)
}
label.Name.Defn = ls
l := []*Node{label}
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()...)
} else {
l = append(l, ls)
// type switch - declare variable
nn := newname(n.Sym)
declare(nn, dclcontext)
- setNodeSeq(&stmt.Rlist, []*Node{nn})
+ stmt.Rlist.Set([]*Node{nn})
// keep track of the instances for reporting unused
nn.Name.Defn = tswitch
} else {
n = Nod(OAS2, nil, nil)
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
return stmt
// done in casebody()
markdcl() // matching popdcl in caseblock
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
return stmt
// type switch - declare variable
nn := newname(n.Sym)
declare(nn, dclcontext)
- setNodeSeq(&stmt.Rlist, []*Node{nn})
+ stmt.Rlist.Set([]*Node{nn})
// keep track of the instances for reporting unused
nn.Name.Defn = tswitch
}
h := Nod(OFOR, nil, nil)
if init != nil {
- setNodeSeq(&h.Ninit, []*Node{init})
+ h.Ninit.Set([]*Node{init})
}
h.Left = cond
h.Right = post
init, cond, _ := p.header(false)
h := Nod(OIF, nil, nil)
if init != nil {
- setNodeSeq(&h.Ninit, []*Node{init})
+ h.Ninit.Set([]*Node{init})
}
h.Left = cond
return h
if p.got(LELSE) {
if p.tok == LIF {
- setNodeSeq(&stmt.Rlist, []*Node{p.if_stmt()})
+ stmt.Rlist.Set([]*Node{p.if_stmt()})
} else {
cs := p.compound_stmt(true)
- if cs.Op == OBLOCK && nodeSeqLen(cs.Ninit) == 0 {
- setNodeSeq(&stmt.Rlist, cs.List)
+ if cs.Op == OBLOCK && cs.Ninit.Len() == 0 {
+ stmt.Rlist.Set(cs.List.Slice())
} else {
- setNodeSeq(&stmt.Rlist, []*Node{cs})
+ stmt.Rlist.Set([]*Node{cs})
}
}
}
p.xnest--
p.want('}')
- setNodeSeq(&n.List, l)
+ n.List.Set(l)
return n
}
p.want('}')
t := Nod(OTINTER, nil, nil)
- setNodeSeq(&t.List, l)
+ t.List.Set(l)
return t
}
stmt := Nod(ORETURN, nil, nil)
setNodeSeq(&stmt.List, results)
- if nodeSeqLen(stmt.List) == 0 && Curfn != nil {
+ if stmt.List.Len() == 0 && Curfn != nil {
for _, ln := range Curfn.Func.Dcl {
if ln.Class == PPARAM {
continue
if s == missing_stmt {
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)
} else {
appendNodeSeqNode(&l, s)
}
func instrumentlist(l Nodes, init *Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
+ for i := range l.Slice() {
var instr Nodes
- instrumentnode(it.P(), &instr, 0, 0)
+ instrumentnode(&l.Slice()[i], &instr, 0, 0)
if init == nil {
- it.N().Ninit.AppendNodes(&instr)
+ l.Slice()[i].Ninit.AppendNodes(&instr)
} else {
init.AppendNodes(&instr)
}
// nil it out and handle it separately before putting it back.
l := n.Ninit
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
instrumentlist(l, nil)
instrumentnode(&n, &l, wr, skip) // recurse with nil n->ninit
appendinit(&n, l)
out = append(outn.Slice(), it.N())
}
}
- setNodeSeq(&n.List, out)
+ n.List.Set(out)
goto ret
case ODEFER:
}
func foreachlist(l Nodes, f func(*Node, interface{}), c interface{}) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- foreachnode(it.N(), f, c)
+ for _, n := range l.Slice() {
+ foreachnode(n, f, c)
}
}
// appendinit is like addinit in subr.go
// but appends rather than prepends.
func appendinit(np **Node, init Nodes) {
- if nodeSeqLen(init) == 0 {
+ if init.Len() == 0 {
return
}
*np = n
}
- appendNodeSeq(&n.Ninit, init)
+ n.Ninit.AppendNodes(&init)
n.Ullman = UINF
}
if t == nil {
goto out
}
-
// delicate little dance. see typecheckas2
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Name == nil || it.N().Name.Defn != n {
- typecheck(it.P(), Erv|Easgn)
+ for i1, n1 := range n.List.Slice() {
+ if n1.Name == nil || n1.Name.Defn != n {
+ typecheck(&n.List.Slice()[i1], Erv|Easgn)
}
}
t1 = t.Type
t2 = nil
- if nodeSeqLen(n.List) == 2 {
+ if n.List.Len() == 2 {
toomany = 1
}
t2 = runetype
}
- if nodeSeqLen(n.List) > 2 || toomany != 0 {
+ if n.List.Len() > 2 || toomany != 0 {
Yyerror("too many variables in range")
}
v1 = nil
- if nodeSeqLen(n.List) != 0 {
- v1 = nodeSeqFirst(n.List)
+ if n.List.Len() != 0 {
+ v1 = n.List.First()
}
v2 = nil
- if nodeSeqLen(n.List) > 1 {
- v2 = nodeSeqSecond(n.List)
+ if n.List.Len() > 1 {
+ v2 = n.List.Second()
}
// this is not only a optimization but also a requirement in the spec.
// present."
if isblank(v2) {
if v1 != nil {
- setNodeSeq(&n.List, []*Node{v1})
+ n.List.Set([]*Node{v1})
}
v2 = nil
}
// second half of dance
out:
n.Typecheck = 1
-
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Typecheck == 0 {
- typecheck(it.P(), Erv|Easgn)
+ for i2, n2 := range n.List.Slice() {
+ if n2.Typecheck == 0 {
+ typecheck(&n.List.Slice()[i2], Erv|Easgn)
}
}
n.Right = nil
var v1 *Node
- if nodeSeqLen(n.List) != 0 {
- v1 = nodeSeqFirst(n.List)
+ if n.List.Len() != 0 {
+ v1 = n.List.First()
}
var v2 *Node
- if nodeSeqLen(n.List) > 1 && !isblank(nodeSeqSecond(n.List)) {
- v2 = nodeSeqSecond(n.List)
+ if n.List.Len() > 1 && !isblank(n.List.Second()) {
+ v2 = n.List.Second()
}
// n->list has no meaning anymore, clear it
// to avoid erroneous processing by racewalk.
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
var body []*Node
var init []*Node
body = []*Node{Nod(OAS, v1, hv1)}
} else {
a := Nod(OAS2, nil, nil)
- setNodeSeq(&a.List, []*Node{v1, v2})
- setNodeSeq(&a.Rlist, []*Node{hv1, Nod(OIND, hp, nil)})
+ a.List.Set([]*Node{v1, v2})
+ a.Rlist.Set([]*Node{hv1, Nod(OIND, hp, nil)})
body = []*Node{a}
// Advance pointer as part of increment.
tmp.Right.Typecheck = 1
a = Nod(OAS, hp, tmp)
typecheck(&a, Etop)
- setNodeSeq(&n.Right.Ninit, []*Node{a})
+ n.Right.Ninit.Set([]*Node{a})
}
// orderstmt allocated the iterator for us.
val := Nod(ODOT, hit, valname)
val = Nod(OIND, val, nil)
a := Nod(OAS2, nil, nil)
- setNodeSeq(&a.List, []*Node{v1, v2})
- setNodeSeq(&a.Rlist, []*Node{key, val})
+ a.List.Set([]*Node{v1, v2})
+ a.Rlist.Set([]*Node{key, val})
body = []*Node{a}
}
n.Left = Nod(ONE, hb, Nodbool(false))
a := Nod(OAS2RECV, nil, nil)
a.Typecheck = 1
- setNodeSeq(&a.List, []*Node{hv1, hb})
- setNodeSeq(&a.Rlist, []*Node{Nod(ORECV, ha, nil)})
- setNodeSeq(&n.Left.Ninit, []*Node{a})
+ a.List.Set([]*Node{hv1, hb})
+ a.Rlist.Set([]*Node{Nod(ORECV, ha, nil)})
+ n.Left.Ninit.Set([]*Node{a})
if v1 == nil {
body = nil
} else {
} else {
hv2 = temp(runetype)
a = Nod(OAS2, nil, nil)
- setNodeSeq(&a.List, []*Node{hv1, hv2})
+ a.List.Set([]*Node{hv1, hv2})
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))
- setNodeSeq(&n.Left.Ninit, []*Node{Nod(OAS, ohv1, hv1), a})
+ n.Left.Ninit.Set([]*Node{Nod(OAS, ohv1, hv1), a})
body = nil
if v1 != nil {
n.Op = OFOR
typechecklist(init, Etop)
- appendNodeSeq(&n.Ninit, init)
+ n.Ninit.Append(init...)
typechecklist(n.Left.Ninit.Slice(), Etop)
typecheck(&n.Left, Erv)
typecheck(&n.Right, Etop)
lno := setlineno(sel)
count := 0
typechecklist(sel.Ninit.Slice(), Etop)
- for it := nodeSeqIterate(sel.List); !it.Done(); it.Next() {
+ for _, n1 := range sel.List.Slice() {
count++
- ncase = it.N()
+ ncase = n1
setlineno(ncase)
if ncase.Op != OXCASE {
Fatalf("typecheckselect %v", Oconv(ncase.Op, 0))
}
- if nodeSeqLen(ncase.List) == 0 {
+ if ncase.List.Len() == 0 {
// default
if def != nil {
Yyerror("multiple defaults in select (first at %v)", def.Line())
} else {
def = ncase
}
- } else if nodeSeqLen(ncase.List) > 1 {
+ } else if ncase.List.Len() > 1 {
Yyerror("select cases cannot be lists")
} else {
it2 := nodeSeqIterate(ncase.List)
n = typecheck(it2.P(), Etop)
ncase.Left = n
- setNodeSeq(&ncase.List, nil)
+ ncase.List.Set(nil)
setlineno(n)
switch n.Op {
default:
// convert x, ok = <-c into OSELRECV2(x, <-c) with ntest=ok
case OAS2RECV:
- if nodeSeqFirst(n.Rlist).Op != ORECV {
+ if n.Rlist.First().Op != ORECV {
Yyerror("select assignment must have receive on right hand side")
break
}
n.Op = OSELRECV2
- n.Left = nodeSeqFirst(n.List)
- setNodeSeq(&n.List, []*Node{nodeSeqSecond(n.List)})
- n.Right = nodeSeqFirst(n.Rlist)
- setNodeSeq(&n.Rlist, nil)
+ n.Left = n.List.First()
+ n.List.Set([]*Node{n.List.Second()})
+ n.Right = n.Rlist.First()
+ n.Rlist.Set(nil)
// convert <-c into OSELRECV(N, <-c)
case ORECV:
}
func walkselect(sel *Node) {
- if nodeSeqLen(sel.List) == 0 && sel.Xoffset != 0 {
+ if sel.List.Len() == 0 && sel.Xoffset != 0 {
Fatalf("double walkselect") // already rewrote
}
lno := setlineno(sel)
- i := nodeSeqLen(sel.List)
+ i := sel.List.Len()
// optimization: zero-case select
var init []*Node
// TODO(rsc): Reenable optimization once order.go can handle it.
// golang.org/issue/7672.
if i == 1 {
- cas := nodeSeqFirst(sel.List)
+ cas := sel.List.First()
setlineno(cas)
- l := nodeSeqSlice(cas.Ninit)
+ l := cas.Ninit.Slice()
if cas.Left != nil { // not default:
n := cas.Left
- l = append(l, nodeSeqSlice(n.Ninit)...)
- setNodeSeq(&n.Ninit, nil)
+ l = append(l, n.Ninit.Slice()...)
+ n.Ninit.Set(nil)
var ch *Node
switch n.Op {
default:
case OSELRECV, OSELRECV2:
ch = n.Right.Left
- if n.Op == OSELRECV || nodeSeqLen(n.List) == 0 {
+ if n.Op == OSELRECV || n.List.Len() == 0 {
if n.Left == nil {
n = n.Right
} else {
}
n.Op = OAS2
- setNodeSeq(&n.List, append([]*Node{n.Left}, nodeSeqSlice(n.List)...))
- setNodeSeq(&n.Rlist, []*Node{n.Right})
+ n.List.Set(append([]*Node{n.Left}, n.List.Slice()...))
+ n.Rlist.Set([]*Node{n.Right})
n.Right = nil
n.Left = nil
n.Typecheck = 0
typecheck(&n.Right, Erv)
case OSELRECV, OSELRECV2:
- if n.Op == OSELRECV2 && nodeSeqLen(n.List) == 0 {
+ if n.Op == OSELRECV2 && n.List.Len() == 0 {
n.Op = OSELRECV
}
if n.Op == OSELRECV2 {
}
// optimization: two-case select but one is default: single non-blocking op.
- if i == 2 && (nodeSeqFirst(sel.List).Left == nil || nodeSeqSecond(sel.List).Left == nil) {
+ if i == 2 && (sel.List.First().Left == nil || sel.List.Second().Left == nil) {
var cas *Node
var dflt *Node
- if nodeSeqFirst(sel.List).Left == nil {
- cas = nodeSeqSecond(sel.List)
- dflt = nodeSeqFirst(sel.List)
+ if sel.List.First().Left == nil {
+ cas = sel.List.Second()
+ dflt = sel.List.First()
} else {
- dflt = nodeSeqSecond(sel.List)
+ dflt = sel.List.Second()
cas = nodeSeqFirst(sel.List.Slice())
}
n := cas.Left
setlineno(n)
r := Nod(OIF, nil, nil)
- setNodeSeq(&r.Ninit, cas.Ninit)
+ r.Ninit.Set(cas.Ninit.Slice())
switch n.Op {
default:
Fatalf("select %v", Oconv(n.Op, 0))
case OSELRECV:
r = Nod(OIF, nil, nil)
- setNodeSeq(&r.Ninit, cas.Ninit)
+ r.Ninit.Set(cas.Ninit.Slice())
ch := n.Right.Left
r.Left = mkcall1(chanfn("selectnbrecv", 2, ch.Type), Types[TBOOL], &r.Ninit, typename(ch.Type), n.Left, ch)
case OSELRECV2:
r = Nod(OIF, nil, nil)
- setNodeSeq(&r.Ninit, cas.Ninit)
+ r.Ninit.Set(cas.Ninit.Slice())
ch := n.Right.Left
- r.Left = mkcall1(chanfn("selectnbrecv2", 2, ch.Type), Types[TBOOL], &r.Ninit, typename(ch.Type), n.Left, nodeSeqFirst(n.List), ch)
+ r.Left = mkcall1(chanfn("selectnbrecv2", 2, ch.Type), Types[TBOOL], &r.Ninit, typename(ch.Type), n.Left, n.List.First(), ch)
}
typecheck(&r.Left, Erv)
r.Nbody.Set(cas.Nbody.Slice())
- setNodeSeq(&r.Rlist, append(nodeSeqSlice(dflt.Ninit), dflt.Nbody.Slice()...))
+ r.Rlist.Set(append(dflt.Ninit.Slice(), dflt.Nbody.Slice()...))
sel.Nbody.Set([]*Node{r})
goto out
}
- init = nodeSeqSlice(sel.Ninit)
- setNodeSeq(&sel.Ninit, nil)
+ init = sel.Ninit.Slice()
+ sel.Ninit.Set(nil)
// generate sel-struct
setlineno(sel)
r = mkcall("newselect", nil, nil, var_, Nodintconst(selv.Type.Width), Nodintconst(sel.Xoffset))
typecheck(&r, Etop)
init = append(init, r)
-
// register cases
- for it := nodeSeqIterate(sel.List); !it.Done(); it.Next() {
- cas = it.N()
+ for _, cas = range sel.List.Slice() {
setlineno(cas)
n = cas.Left
r = Nod(OIF, nil, nil)
- setNodeSeq(&r.Ninit, cas.Ninit)
- setNodeSeq(&cas.Ninit, nil)
+ r.Ninit.Set(cas.Ninit.Slice())
+ cas.Ninit.Set(nil)
if n != nil {
- appendNodeSeq(&r.Ninit, n.Ninit)
- setNodeSeq(&n.Ninit, nil)
+ r.Ninit.AppendNodes(&n.Ninit)
+ n.Ninit.Set(nil)
}
if n == nil {
// selectrecv2(sel *byte, hchan *chan any, elem *any, received *bool) (selected bool);
case OSELRECV2:
- r.Left = mkcall1(chanfn("selectrecv2", 2, n.Right.Left.Type), Types[TBOOL], &r.Ninit, var_, n.Right.Left, n.Left, nodeSeqFirst(n.List))
+ r.Left = mkcall1(chanfn("selectrecv2", 2, n.Right.Left.Type), Types[TBOOL], &r.Ninit, var_, n.Right.Left, n.Left, n.List.First())
}
}
sel.Nbody.Set(init)
out:
- setNodeSeq(&sel.List, nil)
+ sel.List.Set(nil)
walkstmtlist(sel.Nbody.Slice())
lineno = lno
}
// and then cache; and also cache Select per size.
sudog := Nod(OTSTRUCT, nil, nil)
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("g")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("selectdone")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("next")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("prev")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("elem")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("nrelease")), typenod(Types[TINT32])))
- appendNodeSeqNode(&sudog.List, Nod(ODCLFIELD, newname(Lookup("waitlink")), typenod(Ptrto(Types[TUINT8]))))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("g")), typenod(Ptrto(Types[TUINT8]))))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("selectdone")), typenod(Ptrto(Types[TUINT8]))))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("next")), typenod(Ptrto(Types[TUINT8]))))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("prev")), typenod(Ptrto(Types[TUINT8]))))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("elem")), typenod(Ptrto(Types[TUINT8]))))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("nrelease")), typenod(Types[TINT32])))
+ sudog.List.Append(Nod(ODCLFIELD, newname(Lookup("waitlink")), typenod(Ptrto(Types[TUINT8]))))
typecheck(&sudog, Etype)
sudog.Type.Noalg = true
sudog.Type.Local = true
scase := Nod(OTSTRUCT, nil, nil)
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("elem")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("chan")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("pc")), typenod(Types[TUINTPTR])))
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("kind")), typenod(Types[TUINT16])))
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("so")), typenod(Types[TUINT16])))
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("receivedp")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&scase.List, Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("elem")), typenod(Ptrto(Types[TUINT8]))))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("chan")), typenod(Ptrto(Types[TUINT8]))))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("pc")), typenod(Types[TUINTPTR])))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("kind")), typenod(Types[TUINT16])))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("so")), typenod(Types[TUINT16])))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("receivedp")), typenod(Ptrto(Types[TUINT8]))))
+ scase.List.Append(Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
typecheck(&scase, Etype)
scase.Type.Noalg = true
scase.Type.Local = true
sel := Nod(OTSTRUCT, nil, nil)
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("tcase")), typenod(Types[TUINT16])))
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("ncase")), typenod(Types[TUINT16])))
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("pollorder")), typenod(Ptrto(Types[TUINT8]))))
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("lockorder")), typenod(Ptrto(Types[TUINT8]))))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("tcase")), typenod(Types[TUINT16])))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("ncase")), typenod(Types[TUINT16])))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("pollorder")), typenod(Ptrto(Types[TUINT8]))))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("lockorder")), typenod(Ptrto(Types[TUINT8]))))
arr := Nod(OTARRAY, Nodintconst(int64(size)), scase)
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("scase")), arr))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("scase")), arr))
arr = Nod(OTARRAY, Nodintconst(int64(size)), typenod(Ptrto(Types[TUINT8])))
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("lockorderarr")), arr))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("lockorderarr")), arr))
arr = Nod(OTARRAY, Nodintconst(int64(size)), typenod(Types[TUINT16]))
- appendNodeSeqNode(&sel.List, Nod(ODCLFIELD, newname(Lookup("pollorderarr")), arr))
+ sel.List.Append(Nod(ODCLFIELD, newname(Lookup("pollorderarr")), arr))
typecheck(&sel, Etype)
sel.Type.Noalg = true
sel.Type.Local = true
}
init1(n.Left, out)
init1(n.Right, out)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- init1(it.N(), out)
+ for _, n1 := range n.List.Slice() {
+ init1(n1, out)
}
if n.Left != nil && n.Type != nil && n.Left.Op == OTYPE && n.Class == PFUNC {
break
}
defn.Initorder = InitPending
- for it := nodeSeqIterate(defn.Rlist); !it.Done(); it.Next() {
- init1(it.N(), out)
+ for _, n2 := range defn.Rlist.Slice() {
+ init1(n2, out)
}
if Debug['%'] != 0 {
Dump("nonstatic", defn)
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))
}
}
func init2list(l Nodes, out *[]*Node) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- init2(it.N(), out)
+ for _, n := range l.Slice() {
+ init2(n, out)
}
}
func initreorder(l []*Node, out *[]*Node) {
var n *Node
-
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- n = it.N()
+ for _, n = range l {
switch n.Op {
case ODCLFUNC, ODCLCONST, ODCLTYPE:
continue
}
initreorder(n.Ninit.Slice(), out)
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
init1(n, out)
}
}
case OSTRUCTLIT:
break
}
-
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- value := it.N().Right
+ for _, n1 := range n.List.Slice() {
+ value := n1.Right
mode |= getdyn(value, 0)
if mode == MODEDYNAM|MODECONST {
break
}
func structlit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- r := it.N()
+ for _, r := range n.List.Slice() {
if r.Op != OKEY {
Fatalf("structlit: rhs not OKEY: %v", r)
}
}
func arraylit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- r := it.N()
+ for _, r := range n.List.Slice() {
if r.Op != OKEY {
Fatalf("arraylit: rhs not OKEY: %v", r)
}
a = Nod(OADDR, a, nil)
} else {
a = Nod(ONEW, nil, nil)
- setNodeSeq(&a.List, []*Node{typenod(t)})
+ a.List.Set([]*Node{typenod(t)})
}
a = Nod(OAS, vauto, a)
orderstmtinplace(&a)
walkstmt(&a)
init.Append(a)
-
// put dynamics into slice (6)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- r := it.N()
+ for _, r := range n.List.Slice() {
if r.Op != OKEY {
Fatalf("slicelit: rhs not OKEY: %v", r)
}
nerr := nerrors
a := Nod(OMAKE, nil, nil)
- setNodeSeq(&a.List, []*Node{typenod(n.Type)})
+ a.List.Set([]*Node{typenod(n.Type)})
litas(var_, a, init)
// count the initializers
b := 0
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- r := it.N()
+ for _, r := range n.List.Slice() {
if r.Op != OKEY {
Fatalf("maplit: rhs not OKEY: %v", r)
}
vstat := staticname(tarr, ctxt)
b := int64(0)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- r := it.N()
-
+ for _, r := range n.List.Slice() {
if r.Op != OKEY {
Fatalf("maplit: rhs not OKEY: %v", r)
}
a = Nod(OFOR, nil, nil)
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.Right = Nod(OAS, index, Nod(OADD, index, Nodintconst(1)))
// put in dynamic entries one-at-a-time
var key, val *Node
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- r := it.N()
-
+ for _, r := range n.List.Slice() {
if r.Op != OKEY {
Fatalf("maplit: rhs not OKEY: %v", r)
}
Fatalf("anylit: not struct")
}
- if simplename(var_) && nodeSeqLen(n.List) > 4 {
+ if simplename(var_) && n.List.Len() > 4 {
if ctxt == 0 {
// lay out static data
vstat := staticname(t, ctxt)
}
// 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)
typecheck(&a, Etop)
walkexpr(&a, init)
break
}
- if simplename(var_) && nodeSeqLen(n.List) > 4 {
+ if simplename(var_) && n.List.Len() > 4 {
if ctxt == 0 {
// lay out static data
vstat := staticname(t, ctxt)
}
// 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)
typecheck(&a, Etop)
walkexpr(&a, init)
Fatalf("initplan")
case OARRAYLIT:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- a := it.N()
+ for _, a := range n.List.Slice() {
if a.Op != OKEY || !Smallintconst(a.Left) {
Fatalf("initplan arraylit")
}
}
case OSTRUCTLIT:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- a := it.N()
+ for _, a := range n.List.Slice() {
if a.Op != OKEY || a.Left.Type == nil {
Fatalf("initplan structlit")
}
}
case OMAPLIT:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- a := it.N()
+ for _, a := range n.List.Slice() {
if a.Op != OKEY {
Fatalf("initplan maplit")
}
// fall through
case OSTRUCTLIT:
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if !iszero(it.N().Right) {
+ for _, n1 := range n.List.Slice() {
+ if !iszero(n1.Right) {
return false
}
}
// ssaStmtList converts the statement n to SSA and adds it to s.
func (s *state) stmtList(l Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- s.stmt(it.N())
+ for _, n := range l.Slice() {
+ s.stmt(n)
}
}
s.call(n.Left, callGo)
case OAS2DOTTYPE:
- res, resok := s.dottype(nodeSeqFirst(n.Rlist), true)
- s.assign(nodeSeqFirst(n.List), res, needwritebarrier(nodeSeqFirst(n.List), nodeSeqFirst(n.Rlist)), false, n.Lineno)
- s.assign(nodeSeqSecond(n.List), resok, false, false, n.Lineno)
+ res, resok := s.dottype(n.Rlist.First(), true)
+ s.assign(n.List.First(), res, needwritebarrier(n.List.First(), n.Rlist.First()), false, n.Lineno)
+ s.assign(n.List.Second(), resok, false, false, n.Lineno)
return
case ODCL:
bThen := s.f.NewBlock(ssa.BlockPlain)
bEnd := s.f.NewBlock(ssa.BlockPlain)
var bElse *ssa.Block
- if nodeSeqLen(n.Rlist) != 0 {
+ if n.Rlist.Len() != 0 {
bElse = s.f.NewBlock(ssa.BlockPlain)
s.condBranch(n.Left, bThen, bElse, n.Likely)
} else {
b.AddEdgeTo(bEnd)
}
- if nodeSeqLen(n.Rlist) != 0 {
+ if n.Rlist.Len() != 0 {
s.startBlock(bElse)
s.stmtList(n.Rlist)
if b := s.endBlock(); b != nil {
pt := Ptrto(et)
// Evaluate slice
- slice := s.expr(nodeSeqFirst(n.List))
+ slice := s.expr(n.List.First())
// Allocate new blocks
grow := s.f.NewBlock(ssa.BlockPlain)
assign := s.f.NewBlock(ssa.BlockPlain)
// 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)
l := s.newValue1(ssa.OpSliceLen, Types[TINT], slice)
c := s.newValue1(ssa.OpSliceCap, Types[TINT], slice)
m.Orig = m
m.Left = treecopy(n.Left, 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 {
m.Lineno = lineno
}
var ul int
var ur int
- if nodeSeqLen(n.Ninit) != 0 {
+ if n.Ninit.Len() != 0 {
ul = UINF
goto out
}
return nil
}
- if nodeSeqLen(n.Ninit) != 0 {
+ if n.Ninit.Len() != 0 {
walkstmtlist(n.Ninit.Slice())
init.AppendNodes(&n.Ninit)
}
l = append(l, pad)
}
- setNodeSeq(&t.List, append(l, in...))
- setNodeSeq(&t.Rlist, out)
+ t.List.Set(append(l, in...))
+ t.Rlist.Set(out)
fn := Nod(ODCLFUNC, nil, nil)
fn.Func.Nname = newname(newnam)
v.U = method.Sym.Name
l = append(l, nodlit(v)) // method name
call := Nod(OCALL, syslook("panicwrap"), nil)
- setNodeSeq(&call.List, l)
+ call.List.Set(l)
n.Nbody.Set([]*Node{call})
fn.Nbody.Append(n)
}
} else {
fn.Func.Wrapper = true // ignore frame for panic+recover matching
call := Nod(OCALL, dot, nil)
- setNodeSeq(&call.List, args)
+ call.List.Set(args)
call.Isddd = isddd
if method.Type.Outtuple > 0 {
n := Nod(ORETURN, nil, nil)
- setNodeSeq(&n.List, []*Node{call})
+ n.List.Set([]*Node{call})
call = n
}
n := newname(sym)
n.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil)
- appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
- appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
- appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
- appendNodeSeqNode(&tfn.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
+ tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
+ tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
+ tfn.List.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
+ tfn.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
typecheck(&tfn, Etype)
n.Type = tfn.Type
return n
func listtreecopy(l []*Node, lineno int32) []*Node {
var out []*Node
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- out = append(out, treecopy(it.N(), lineno))
+ for _, n := range l {
+ out = append(out, treecopy(n, lineno))
}
return out
}
func liststmt(l []*Node) *Node {
n := Nod(OBLOCK, nil, nil)
- setNodeSeq(&n.List, l)
+ n.List.Set(l)
if nodeSeqLen(l) != 0 {
n.Lineno = nodeSeqFirst(l).Lineno
}
*np = n
}
- setNodeSeq(&n.Ninit, append(nodeSeqSlice(init), nodeSeqSlice(n.Ninit)...))
+ n.Ninit.Set(append(nodeSeqSlice(init), n.Ninit.Slice()...))
n.Ullman = UINF
}
n.Type = t
var def *Node
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- ncase := it.N()
+ for _, ncase := range n.List.Slice() {
setlineno(n)
- if nodeSeqLen(ncase.List) == 0 {
+ if ncase.List.Len() == 0 {
// default
if def != nil {
Yyerror("multiple defaults in switch (first at %v)", def.Line())
def = ncase
}
} else {
- for it2 := nodeSeqIterate(ncase.List); !it2.Done(); it2.Next() {
- setlineno(it2.N())
- typecheck(it2.P(), Erv|Etype)
- if it2.N().Type == nil || t == nil {
+ for i1, n1 := range ncase.List.Slice() {
+ setlineno(n1)
+ typecheck(&ncase.List.Slice()[i1], Erv|Etype)
+ if ncase.List.Slice()[i1].Type == nil || t == nil {
continue
}
setlineno(ncase)
switch top {
// expression switch
case Erv:
- defaultlit(it2.P(), t)
+ defaultlit(&ncase.List.Slice()[i1], t)
switch {
- case it2.N().Op == OTYPE:
- Yyerror("type %v is not an expression", it2.N().Type)
- case it2.N().Type != nil && assignop(it2.N().Type, t, nil) == 0 && assignop(t, it2.N().Type, nil) == 0:
+ case ncase.List.Slice()[i1].Op == OTYPE:
+ Yyerror("type %v is not an expression", ncase.List.Slice()[i1].Type)
+ case ncase.List.Slice()[i1].Type != nil && assignop(ncase.List.Slice()[i1].Type, t, nil) == 0 && assignop(t, ncase.List.Slice()[i1].Type, nil) == 0:
if n.Left != nil {
- Yyerror("invalid case %v in switch on %v (mismatched types %v and %v)", it2.N(), n.Left, it2.N().Type, t)
+ Yyerror("invalid case %v in switch on %v (mismatched types %v and %v)", ncase.List.Slice()[i1], n.Left, ncase.List.Slice()[i1].Type, t)
} else {
- Yyerror("invalid case %v in switch (mismatched types %v and bool)", it2.N(), it2.N().Type)
+ Yyerror("invalid case %v in switch (mismatched types %v and bool)", ncase.List.Slice()[i1], ncase.List.Slice()[i1].Type)
}
- case nilonly != "" && !isnil(it2.N()):
- Yyerror("invalid case %v in switch (can only compare %s %v to nil)", it2.N(), nilonly, n.Left)
- case Isinter(t) && !Isinter(it2.N().Type) && algtype1(it2.N().Type, nil) == ANOEQ:
- Yyerror("invalid case %v in switch (incomparable type)", Nconv(it2.N(), obj.FmtLong))
+ case nilonly != "" && !isnil(ncase.List.Slice()[i1]):
+ Yyerror("invalid case %v in switch (can only compare %s %v to nil)", ncase.List.Slice()[i1], nilonly, n.Left)
+ case Isinter(t) && !Isinter(ncase.List.Slice()[i1].Type) && algtype1(ncase.List.Slice()[i1].Type, nil) == ANOEQ:
+ Yyerror("invalid case %v in switch (incomparable type)", Nconv(ncase.List.Slice()[i1], obj.FmtLong))
}
// type switch
var missing, have *Type
var ptr int
switch {
- case it2.N().Op == OLITERAL && Istype(it2.N().Type, TNIL):
- case it2.N().Op != OTYPE && it2.N().Type != nil: // should this be ||?
- Yyerror("%v is not a type", Nconv(it2.N(), obj.FmtLong))
+ case ncase.List.Slice()[i1].Op == OLITERAL && Istype(ncase.List.Slice()[i1].Type, TNIL):
+ case ncase.List.Slice()[i1].Op != OTYPE && ncase.List.Slice()[i1].Type != nil: // should this be ||?
+ Yyerror("%v is not a type", Nconv(ncase.List.Slice()[i1], obj.FmtLong))
// reset to original type
- *it2.P() = n.Left.Right
- case it2.N().Type.Etype != TINTER && t.Etype == TINTER && !implements(it2.N().Type, t, &missing, &have, &ptr):
+ ncase.List.Slice()[i1] = n.Left.Right
+ case ncase.List.Slice()[i1].Type.Etype != TINTER && t.Etype == TINTER && !implements(ncase.List.Slice()[i1].Type, t, &missing, &have, &ptr):
if have != nil && !missing.Broke && !have.Broke {
- Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, obj.FmtLong), it2.N().Type, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort), missing.Sym, Tconv(missing.Type, obj.FmtShort))
+ Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, obj.FmtLong), ncase.List.Slice()[i1].Type, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort), missing.Sym, Tconv(missing.Type, obj.FmtShort))
} else if !missing.Broke {
- Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, obj.FmtLong), it2.N().Type, missing.Sym)
+ Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, obj.FmtLong), ncase.List.Slice()[i1].Type, missing.Sym)
}
}
}
if top == Etype && n.Type != nil {
ll := ncase.List
- if nodeSeqLen(ncase.Rlist) != 0 {
- nvar := nodeSeqFirst(ncase.Rlist)
- if nodeSeqLen(ll) == 1 && nodeSeqFirst(ll).Type != nil && !Istype(nodeSeqFirst(ll).Type, TNIL) {
+ if ncase.Rlist.Len() != 0 {
+ nvar := ncase.Rlist.First()
+ if ll.Len() == 1 && ll.First().Type != nil && !Istype(ll.First().Type, TNIL) {
// single entry type switch
- nvar.Name.Param.Ntype = typenod(nodeSeqFirst(ll).Type)
+ nvar.Name.Param.Ntype = typenod(ll.First().Type)
} else {
// multiple entry type switch or default
nvar.Name.Param.Ntype = typenod(n.Type)
// enumerate the cases, and lop off the default case
cc := caseClauses(sw, s.kind)
- setNodeSeq(&sw.List, nil)
+ sw.List.Set(nil)
var def *Node
if len(cc) > 0 && cc[0].typ == caseKindDefault {
def = cc[0].node.Right
}
typecheck(&a.Left, Erv)
a.Nbody.Set([]*Node{s.walkCases(cc[:half])})
- setNodeSeq(&a.Rlist, []*Node{s.walkCases(cc[half:])})
+ a.Rlist.Set([]*Node{s.walkCases(cc[half:])})
return a
}
// It makes labels between cases and statements
// and deals with fallthrough, break, and unreachable statements.
func casebody(sw *Node, typeswvar *Node) {
- if nodeSeqLen(sw.List) == 0 {
+ if sw.List.Len() == 0 {
return
}
Fatalf("casebody %v", Oconv(n.Op, 0))
}
n.Op = OCASE
- needvar := nodeSeqLen(n.List) != 1 || nodeSeqFirst(n.List).Op == OLITERAL
+ needvar := n.List.Len() != 1 || n.List.First().Op == OLITERAL
jmp := Nod(OGOTO, newCaseLabel(), nil)
- if nodeSeqLen(n.List) == 0 {
+ if n.List.Len() == 0 {
if def != nil {
Yyerror("more than one default case")
}
def = n
}
- if nodeSeqLen(n.List) == 1 {
+ if n.List.Len() == 1 {
// one case -- reuse OCASE node
- n.Left = nodeSeqFirst(n.List)
+ n.Left = n.List.First()
n.Right = jmp
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
cas = append(cas, n)
} else {
// expand multi-valued cases
- for lcit := nodeSeqIterate(n.List); !lcit.Done(); lcit.Next() {
- cas = append(cas, Nod(OCASE, lcit.N(), jmp))
+ for _, n1 := range n.List.Slice() {
+ cas = append(cas, Nod(OCASE, n1, jmp))
}
}
stat = append(stat, Nod(OLABEL, jmp.Left, nil))
- if typeswvar != nil && needvar && nodeSeqLen(n.Rlist) != 0 {
+ if typeswvar != nil && needvar && n.Rlist.Len() != 0 {
l := []*Node{
- Nod(ODCL, nodeSeqFirst(n.Rlist), nil),
- Nod(OAS, nodeSeqFirst(n.Rlist), typeswvar),
+ Nod(ODCL, n.Rlist.First(), nil),
+ Nod(OAS, n.Rlist.First(), typeswvar),
}
typecheckslice(l, Etop)
stat = append(stat, l...)
cas = append(cas, def)
}
- setNodeSeq(&sw.List, cas)
+ sw.List.Set(cas)
sw.Nbody.Set(stat)
lineno = lno
}
// Kind is the kind of switch statement.
func caseClauses(sw *Node, kind int) []*caseClause {
var cc []*caseClause
- for it := nodeSeqIterate(sw.List); !it.Done(); it.Next() {
- n := it.N()
+ for _, n := range sw.List.Slice() {
c := new(caseClause)
cc = append(cc, c)
c.ordinal = len(cc)
sw.Left = nil
if cond == nil {
- setNodeSeq(&sw.List, nil)
+ sw.List.Set(nil)
return
}
if cond.Right == nil {
casebody(sw, s.facename)
cc := caseClauses(sw, switchKindType)
- setNodeSeq(&sw.List, nil)
+ sw.List.Set(nil)
var def *Node
if len(cc) > 0 && cc[0].typ == caseKindDefault {
def = cc[0].node.Right
i.Nbody.Set([]*Node{Nod(OGOTO, lbl, nil)})
// Wrap default case with label.
blk := Nod(OBLOCK, nil, nil)
- setNodeSeq(&blk.List, []*Node{Nod(OLABEL, lbl, nil), def})
+ blk.List.Set([]*Node{Nod(OLABEL, lbl, nil), def})
def = blk
}
typecheck(&i.Left, Erv)
if nerrors == 0 {
cas = append(cas, def)
sw.Nbody.Set(append(cas, sw.Nbody.Slice()...))
- setNodeSeq(&sw.List, nil)
+ sw.List.Set(nil)
walkstmtlist(sw.Nbody.Slice())
}
}
func (s *typeSwitch) typeone(t *Node) *Node {
var name *Node
var init []*Node
- if nodeSeqLen(t.Rlist) == 0 {
+ if t.Rlist.Len() == 0 {
name = nblank
typecheck(&nblank, Erv|Easgn)
} else {
- name = nodeSeqFirst(t.Rlist)
+ name = t.Rlist.First()
init = []*Node{Nod(ODCL, name, nil)}
a := Nod(OAS, name, nil)
typecheck(&a, Etop)
}
a := Nod(OAS2, nil, nil)
- setNodeSeq(&a.List, []*Node{name, s.okname}) // name, ok =
+ a.List.Set([]*Node{name, s.okname}) // name, ok =
b := Nod(ODOTTYPE, s.facename, nil)
b.Type = t.Left.Type // interface.(type)
- setNodeSeq(&a.Rlist, []*Node{b})
+ a.Rlist.Set([]*Node{b})
typecheck(&a, Etop)
init = append(init, a)
a.Left = Nod(OLE, s.hashname, Nodintconst(int64(cc[half-1].hash)))
typecheck(&a.Left, Erv)
a.Nbody.Set([]*Node{s.walkCases(cc[:half])})
- setNodeSeq(&a.Rlist, []*Node{s.walkCases(cc[half:])})
+ a.Rlist.Set([]*Node{s.walkCases(cc[half:])})
return a
}
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.
// Changes to the NodeList entries (as in l.N = n) will *not* be
// reflected in the Nodes.
}
func typechecklist(l []*Node, top int) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- typecheck(it.P(), top)
+ for i := range l {
+ typecheck(&l[i], top)
}
}
}
func callrecvlist(l Nodes) bool {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- if callrecv(it.N()) {
+ for _, n := range l.Slice() {
+ if callrecv(n) {
return true
}
}
n.Type = nil
return
}
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
case OTINTER:
ok |= Etype
n.Op = OADDSTR
if l.Op == OADDSTR {
- setNodeSeq(&n.List, l.List)
+ n.List.Set(l.List.Slice())
} else {
- setNodeSeq(&n.List, []*Node{l})
+ n.List.Set([]*Node{l})
}
if r.Op == OADDSTR {
- appendNodeSeq(&n.List, r.List)
+ n.List.AppendNodes(&r.List)
} else {
- appendNodeSeqNode(&n.List, r)
+ n.List.Append(r)
}
n.Left = nil
n.Right = nil
return
}
- if nodeSeqLen(n.List) == 1 && !n.Isddd {
+ if n.List.Len() == 1 && !n.Isddd {
it := nodeSeqIterate(n.List)
typecheck(it.P(), Erv|Efnstruct)
} else {
ok |= Erv
var r *Node
var l *Node
- if nodeSeqLen(n.List) == 1 {
+ if n.List.Len() == 1 {
typechecklist(n.List.Slice(), Efnstruct)
- if nodeSeqFirst(n.List).Op != OCALLFUNC && nodeSeqFirst(n.List).Op != OCALLMETH {
+ if n.List.First().Op != OCALLFUNC && n.List.First().Op != OCALLMETH {
Yyerror("invalid operation: complex expects two arguments")
n.Type = nil
return
}
- t := nodeSeqFirst(n.List).Left.Type
+ t := n.List.First().Left.Type
if t.Outtuple != 2 {
- Yyerror("invalid operation: complex expects two arguments, %v returns %d results", nodeSeqFirst(n.List), t.Outtuple)
+ Yyerror("invalid operation: complex expects two arguments, %v returns %d results", n.List.First(), t.Outtuple)
n.Type = nil
return
}
- t = nodeSeqFirst(n.List).Type.Type
+ t = n.List.First().Type.Type
l = t.Nname
r = t.Down.Nname
} else {
case ODELETE:
args := n.List
- if nodeSeqLen(args) == 0 {
+ if args.Len() == 0 {
Yyerror("missing arguments to delete")
n.Type = nil
return
}
- if nodeSeqLen(args) == 1 {
+ if args.Len() == 1 {
Yyerror("missing second (key) argument to delete")
n.Type = nil
return
}
- if nodeSeqLen(args) != 2 {
+ if args.Len() != 2 {
Yyerror("too many arguments to delete")
n.Type = nil
return
ok |= Etop
typechecklist(args.Slice(), Erv)
- l := nodeSeqFirst(args)
- r := nodeSeqSecond(args)
+ l := args.First()
+ r := args.Second()
if l.Type != nil && l.Type.Etype != TMAP {
Yyerror("first argument to delete must be map; have %v", Tconv(l.Type, obj.FmtLong))
n.Type = nil
case OAPPEND:
ok |= Erv
args := n.List
- if nodeSeqLen(args) == 0 {
+ if args.Len() == 0 {
Yyerror("missing arguments to append")
n.Type = nil
return
}
- if nodeSeqLen(args) == 1 && !n.Isddd {
+ if args.Len() == 1 && !n.Isddd {
it := nodeSeqIterate(args)
typecheck(it.P(), Erv|Efnstruct)
} else {
typechecklist(args.Slice(), Erv)
}
- t := nodeSeqFirst(args).Type
+ t := args.First().Type
if t == nil {
n.Type = nil
return
n.Type = t
if !Isslice(t) {
- if Isconst(nodeSeqFirst(args), CTNIL) {
+ if Isconst(args.First(), CTNIL) {
Yyerror("first argument to append must be typed slice; have untyped nil")
n.Type = nil
return
}
if n.Isddd {
- if nodeSeqLen(args) == 1 {
+ if args.Len() == 1 {
Yyerror("cannot use ... on first argument to append")
n.Type = nil
return
}
- if nodeSeqLen(args) != 2 {
+ if args.Len() != 2 {
Yyerror("too many arguments to append")
n.Type = nil
return
}
- if Istype(t.Type, TUINT8) && Istype(nodeSeqSecond(args).Type, TSTRING) {
+ if Istype(t.Type, TUINT8) && Istype(args.Second().Type, TSTRING) {
it := nodeSeqIterate(args)
it.Next()
defaultlit(it.P(), Types[TSTRING])
it := nodeSeqIterate(args)
it.Next()
- *it.P() = assignconv(nodeSeqSecond(args), t.Orig, "append")
+ *it.P() = assignconv(args.Second(), t.Orig, "append")
break OpSwitch
}
case OCOPY:
ok |= Etop | Erv
args := n.List
- if nodeSeqLen(args) < 2 {
+ if args.Len() < 2 {
Yyerror("missing arguments to copy")
n.Type = nil
return
}
- if nodeSeqLen(args) > 2 {
+ if args.Len() > 2 {
Yyerror("too many arguments to copy")
n.Type = nil
return
}
- n.Left = nodeSeqFirst(args)
- n.Right = nodeSeqSecond(args)
- setNodeSeq(&n.List, nil)
+ n.Left = args.First()
+ n.Right = args.Second()
+ n.List.Set(nil)
n.Type = Types[TINT]
typecheck(&n.Left, Erv)
typecheck(&n.Right, Erv)
return
}
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
l := args.N()
args.Next()
typecheck(&l, Etype)
case ONEW:
ok |= Erv
args := n.List
- if nodeSeqLen(args) == 0 {
+ if args.Len() == 0 {
Yyerror("missing argument to new")
n.Type = nil
return
}
- l := nodeSeqFirst(args)
+ l := args.First()
typecheck(&l, Etype)
t := l.Type
if t == nil {
n.Type = nil
return
}
- if nodeSeqLen(args) > 1 {
+ if args.Len() > 1 {
Yyerror("too many arguments to new(%v)", t)
n.Type = nil
return
case OPRINT, OPRINTN:
ok |= Etop
typechecklist(n.List.Slice(), Erv|Eindir) // Eindir: address does not escape
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
+ for i1, n1 := range n.List.Slice() {
// Special case for print: int constant is int64, not int.
- if Isconst(it.N(), CTINT) {
- defaultlit(it.P(), Types[TINT64])
+ if Isconst(n1, CTINT) {
+ defaultlit(&n.List.Slice()[i1], Types[TINT64])
} else {
- defaultlit(it.P(), nil)
+ defaultlit(&n.List.Slice()[i1], nil)
}
}
case ORECOVER:
ok |= Erv | Etop
- if nodeSeqLen(n.List) != 0 {
+ if n.List.Len() != 0 {
Yyerror("too many arguments to recover")
n.Type = nil
return
case ORETURN:
ok |= Etop
- if nodeSeqLen(n.List) == 1 {
+ if n.List.Len() == 1 {
typechecklist(n.List.Slice(), Erv|Efnstruct)
} else {
typechecklist(n.List.Slice(), Erv)
return
}
- if Curfn.Type.Outnamed && nodeSeqLen(n.List) == 0 {
+ if Curfn.Type.Outnamed && n.List.Len() == 0 {
break OpSwitch
}
typecheckaste(ORETURN, nil, false, Curfn.Type.Results(), n.List, func() string { return "return argument" })
if n.Left != nil {
return true
}
- if nodeSeqLen(n.List) == 0 {
+ if n.List.Len() == 0 {
p := fmt.Sprintf(f, args...)
Yyerror("missing argument to %s: %v", p, n)
return false
}
- if nodeSeqLen(n.List) > 1 {
+ if n.List.Len() > 1 {
p := fmt.Sprintf(f, args...)
Yyerror("too many arguments to %s: %v", p, n)
- n.Left = nodeSeqFirst(n.List)
- setNodeSeq(&n.List, nil)
+ n.Left = n.List.First()
+ n.List.Set(nil)
return false
}
- n.Left = nodeSeqFirst(n.List)
- setNodeSeq(&n.List, nil)
+ n.Left = n.List.First()
+ n.List.Set(nil)
return true
}
if n.Left != nil {
return true
}
- if nodeSeqLen(n.List) == 0 {
+ if n.List.Len() == 0 {
Yyerror("missing argument to %v - %v", Oconv(n.Op, 0), n)
return false
}
- n.Left = nodeSeqFirst(n.List)
- if nodeSeqLen(n.List) == 1 {
+ n.Left = n.List.First()
+ if n.List.Len() == 1 {
Yyerror("missing argument to %v - %v", Oconv(n.Op, 0), n)
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
return false
}
- if nodeSeqLen(n.List) > 2 {
+ if n.List.Len() > 2 {
Yyerror("too many arguments to %v - %v", Oconv(n.Op, 0), n)
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
return false
}
- n.Right = nodeSeqSecond(n.List)
- setNodeSeq(&n.List, nil)
+ n.Right = n.List.Second()
+ n.List.Set(nil)
return true
}
}
func nokeys(l Nodes) bool {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- if it.N().Op == OKEY {
+ for _, n := range l.Slice() {
+ if n.Op == OKEY {
return false
}
}
}
n = nil
- if nodeSeqLen(nl) == 1 {
- n = nodeSeqFirst(nl)
+ if nl.Len() == 1 {
+ n = nl.First()
if n.Type != nil {
if n.Type.Etype == TSTRUCT && n.Type.Funarg {
if !hasddd(tstruct) {
}
n1 = downcount(tstruct)
- n2 = nodeSeqLen(nl)
+ n2 = nl.Len()
if !hasddd(tstruct) {
if n2 > n1 {
goto toomany
}()
if n.Right == nil {
- if nodeSeqLen(n.List) != 0 {
- setlineno(nodeSeqFirst(n.List))
+ if n.List.Len() != 0 {
+ setlineno(n.List.First())
}
Yyerror("missing type in composite literal")
n.Type = nil
case TARRAY:
// Only allocate hash if there are some key/value pairs.
var hash map[int64]*Node
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op == OKEY {
+ for _, n1 := range n.List.Slice() {
+ if n1.Op == OKEY {
hash = make(map[int64]*Node)
break
}
}
length := int64(0)
i := 0
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- l := it.N()
+ for i2, n2 := range n.List.Slice() {
+ l := n2
setlineno(l)
if l.Op != OKEY {
l = Nod(OKEY, Nodintconst(int64(i)), l)
l.Left.Type = Types[TINT]
l.Left.Typecheck = 1
- *it.P() = l
+ n.List.Slice()[i2] = l
}
typecheck(&l.Left, Erv)
case TMAP:
hash := make(map[uint32][]*Node)
var l *Node
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- l = it.N()
+ for i3, n3 := range n.List.Slice() {
+ l = n3
setlineno(l)
if l.Op != OKEY {
- typecheck(it.P(), Erv)
+ typecheck(&n.List.Slice()[i3], Erv)
Yyerror("missing key in map literal")
continue
}
case TSTRUCT:
bad := 0
- if nodeSeqLen(n.List) != 0 && nokeys(n.List) {
+ if n.List.Len() != 0 && nokeys(n.List) {
// simple list of variables
f := t.Type
var s *Sym
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- setlineno(it.N())
- typecheck(it.P(), Erv)
+ for i4, n4 := range n.List.Slice() {
+ setlineno(n4)
+ typecheck(&n.List.Slice()[i4], Erv)
if f == nil {
if bad == 0 {
Yyerror("too many values in struct initializer")
if s != nil && !exportname(s.Name) && s.Pkg != localpkg {
Yyerror("implicit assignment of unexported field '%s' in %v literal", s.Name, t)
}
-
// No pushtype allowed here. Must name fields for that.
- *it.P() = assignconv(it.N(), f.Type, "field value")
-
- *it.P() = Nod(OKEY, newname(f.Sym), it.N())
- it.N().Left.Type = f
- it.N().Left.Typecheck = 1
+ n.List.Slice()[i4] = assignconv(n.List.Slice()[i4], f.Type, "field value")
+ n.List.Slice()[i4] = Nod(OKEY, newname(f.Sym), n.List.Slice()[i4])
+ n.List.Slice()[i4].Left.Type = f
+ n.List.Slice()[i4].Left.Typecheck = 1
f = f.Down
}
var f *Type
var l *Node
var s1 *Sym
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- l = it.N()
+ for i5, n5 := range n.List.Slice() {
+ l = n5
setlineno(l)
if l.Op != OKEY {
if bad == 0 {
Yyerror("mixture of field:value and value initializers")
}
bad++
- typecheck(it.P(), Erv)
+ typecheck(&n.List.Slice()[i5], Erv)
continue
}
}
func checkassignlist(stmt *Node, l Nodes) {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- checkassign(stmt, it.N())
+ for _, n := range l.Slice() {
+ checkassign(stmt, n)
}
}
}
func typecheckas2(n *Node) {
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
+ for i1 := range n.List.Slice() {
// delicate little dance.
- *it.P() = resolve(it.N())
+ n.List.Slice()[i1] = resolve(n.List.Slice()[i1])
- if it.N().Name == nil || it.N().Name.Defn != n || it.N().Name.Param.Ntype != nil {
- typecheck(it.P(), Erv|Easgn)
+ if n.List.Slice()[i1].Name == nil || n.List.Slice()[i1].Name.Defn != n || n.List.Slice()[i1].Name.Param.Ntype != nil {
+ typecheck(&n.List.Slice()[i1], Erv|Easgn)
}
}
- cl := nodeSeqLen(n.List)
- cr := nodeSeqLen(n.Rlist)
+ cl := n.List.Len()
+ cr := n.Rlist.Len()
if cl > 1 && cr == 1 {
it := nodeSeqIterate(n.Rlist)
typecheck(it.P(), Erv|Efnstruct)
if cl == cr {
// easy
lrit := nodeSeqIterate(n.Rlist)
- for llit := nodeSeqIterate(n.List); !llit.Done(); llit.Next() {
- if llit.N().Type != nil && lrit.N().Type != nil {
- *lrit.P() = assignconv(lrit.N(), llit.N().Type, "assignment")
+ for _, n2 := range n.List.Slice() {
+ if n2.Type != nil && lrit.N().Type != nil {
+ *lrit.P() = assignconv(lrit.N(), n2.Type, "assignment")
}
- if llit.N().Name != nil && llit.N().Name.Defn == n && llit.N().Name.Param.Ntype == nil {
+ if n2.Name != nil && n2.Name.Defn == n && n2.Name.Param.Ntype == nil {
defaultlit(lrit.P(), nil)
- llit.N().Type = lrit.N().Type
+ n2.Type = lrit.N().Type
}
lrit.Next()
}
goto out
}
- l = nodeSeqFirst(n.List)
- r = nodeSeqFirst(n.Rlist)
+ l = n.List.First()
+ r = n.Rlist.First()
// x,y,z = f()
if cr == 1 {
}
n.Op = OAS2FUNC
t, s := IterFields(r.Type)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if t.Type != nil && it.N().Type != nil {
- checkassignto(t.Type, it.N())
+ for _, n3 := range n.List.Slice() {
+ if t.Type != nil && n3.Type != nil {
+ checkassignto(t.Type, n3)
}
- if it.N().Name != nil && it.N().Name.Defn == n && it.N().Name.Param.Ntype == nil {
- it.N().Type = t.Type
+ if n3.Name != nil && n3.Name.Defn == n && n3.Name.Param.Ntype == nil {
+ n3.Type = t.Type
}
t = s.Next()
}
if l.Name != nil && l.Name.Defn == n {
l.Type = r.Type
}
- l := nodeSeqSecond(n.List)
+ l := n.List.Second()
if l.Type != nil && l.Type.Etype != TBOOL {
checkassignto(Types[TBOOL], l)
}
// second half of dance
out:
n.Typecheck = 1
-
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Typecheck == 0 {
- typecheck(it.P(), Erv|Easgn)
+ for i4, n4 := range n.List.Slice() {
+ if n4.Typecheck == 0 {
+ typecheck(&n.List.Slice()[i4], Erv|Easgn)
}
}
}
}
nn := Nod(OCOMPLIT, nil, typenod(n.Type))
- setNodeSeq(&nn.List, l)
+ nn.List.Set(l)
typecheck(&nn, Erv)
*np = nn
}
return false
}
def := 0
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if !it.N().Nbody.isterminating() {
+ for _, n1 := range n.List.Slice() {
+ if !n1.Nbody.isterminating() {
return false
}
- if nodeSeqLen(it.N().List) == 0 { // default
+ if n1.List.Len() == 0 { // default
def = 1
}
}
return nil
}
- if nodeSeqLen(args) == 0 {
+ if args.Len() == 0 {
Yyerror("missing argument for %v", s)
return nil
}
- r := nodeSeqFirst(args)
+ r := args.First()
var v int64
if s.Name == "Sizeof" {
goto ret
yes:
- if nodeSeqLen(args) > 1 {
+ if args.Len() > 1 {
Yyerror("extra arguments for %v", s)
}
var lhs *Node
callfunc := n.Left
- for argsit := nodeSeqIterate(callfunc.List); !argsit.Done(); argsit.Next() {
- arg = argsit.N()
+ for _, arg = range callfunc.List.Slice() {
if arg.Op != OAS {
Yyerror("call arg not assignment")
}
Fatalf("missing typecheck: %v", Nconv(n, obj.FmtSign))
}
init := n.Ninit
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
walkexpr(&n, &init)
addinit(&n, init.Slice())
if (*np).Op == OCOPY && n.Op == OCONVNOP {
Fatalf("missing typecheck: %v", Nconv(n, obj.FmtSign))
}
init := n.Ninit
- setNodeSeq(&n.Ninit, nil)
+ n.Ninit.Set(nil)
walkexpr(&n.Left, &init)
n = mkcall1(chanfn("chanrecv1", 2, n.Left.Type), nil, &init, typename(n.Left.Type), n.Left, nodnil())
if n.Left != nil {
walkstmtlist(n.Left.Ninit.Slice())
init := n.Left.Ninit
- setNodeSeq(&n.Left.Ninit, nil)
+ n.Left.Ninit.Set(nil)
walkexpr(&n.Left, &init)
addinit(&n.Left, init.Slice())
}
case ORETURN:
walkexprlist(n.List.Slice(), &n.Ninit)
- if nodeSeqLen(n.List) == 0 {
+ if n.List.Len() == 0 {
break
}
- if (Curfn.Type.Outnamed && nodeSeqLen(n.List) > 1) || paramoutheap(Curfn) {
+ if (Curfn.Type.Outnamed && n.List.Len() > 1) || paramoutheap(Curfn) {
// assign to the function out parameters,
// so that reorder3 can fix up conflicts
var rl []*Node
}
}
- if got, want := nodeSeqLen(n.List), len(rl); got != want {
+ if got, want := n.List.Len(), len(rl); got != want {
// order should have rewritten multi-value function calls
// with explicit OAS2FUNC nodes.
Fatalf("expected %v return arguments, have %v", want, got)
if samelist(rl, n.List.Slice()) {
// special return in disguise
- setNodeSeq(&n.List, nil)
+ n.List.Set(nil)
break
}
walkexprlistsafe(n.List.Slice(), &n.Ninit)
ll := ascompatee(n.Op, rl, n.List.Slice(), &n.Ninit)
- setNodeSeq(&n.List, reorder3(ll))
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- *it.P() = applywritebarrier(it.N())
+ n.List.Set(reorder3(ll))
+ for i1 := range n.List.Slice() {
+ n.List.Slice()[i1] = applywritebarrier(n.List.Slice()[i1])
}
break
}
ll := ascompatte(n.Op, nil, false, Curfn.Type.ResultsP(), n.List.Slice(), 1, &n.Ninit)
- setNodeSeq(&n.List, ll)
+ n.List.Set(ll)
case ORETJMP:
break
Fatalf("walkexpr init == &n->ninit")
}
- if nodeSeqLen(n.Ninit) != 0 {
+ if n.Ninit.Len() != 0 {
walkstmtlist(n.Ninit.Slice())
init.AppendNodes(&n.Ninit)
}
OCOMPLEX,
OLROT:
if n.Op == OCOMPLEX && n.Left == nil && n.Right == nil {
- n.Left = nodeSeqFirst(n.List)
- n.Right = nodeSeqSecond(n.List)
+ n.Left = n.List.First()
+ n.Right = n.List.Second()
}
walkexpr(&n.Left, init)
case OCALLINTER:
t := n.Left.Type
- if nodeSeqLen(n.List) != 0 && nodeSeqFirst(n.List).Op == OAS {
+ if n.List.Len() != 0 && n.List.First().Op == OAS {
break
}
walkexpr(&n.Left, init)
walkexprlist(n.List.Slice(), init)
ll := ascompatte(n.Op, n, n.Isddd, t.ParamsP(), n.List.Slice(), 0, init)
- setNodeSeq(&n.List, reorder1(ll))
+ n.List.Set(reorder1(ll))
case OCALLFUNC:
if n.Left.Op == OCLOSURE {
// transformclosure already did all preparation work.
// Prepend captured variables to argument list.
- setNodeSeq(&n.List, append(n.Left.Func.Enter.Slice(), nodeSeqSlice(n.List)...))
+ n.List.Set(append(n.Left.Func.Enter.Slice(), n.List.Slice()...))
n.Left.Func.Enter.Set(nil)
}
t := n.Left.Type
- if nodeSeqLen(n.List) != 0 && nodeSeqFirst(n.List).Op == OAS {
+ if n.List.Len() != 0 && n.List.First().Op == OAS {
break
}
switch Thearch.Thechar {
case '5', '6', '7':
n.Op = OSQRT
- n.Left = nodeSeqFirst(n.List)
- setNodeSeq(&n.List, nil)
+ n.Left = n.List.First()
+ n.List.Set(nil)
break opswitch
}
}
ll := ascompatte(n.Op, n, n.Isddd, t.ParamsP(), n.List.Slice(), 0, init)
- setNodeSeq(&n.List, reorder1(ll))
+ n.List.Set(reorder1(ll))
case OCALLMETH:
t := n.Left.Type
- if nodeSeqLen(n.List) != 0 && nodeSeqFirst(n.List).Op == OAS {
+ if n.List.Len() != 0 && n.List.First().Op == OAS {
break
}
walkexpr(&n.Left, init)
ll = append(ll, lr...)
n.Left.Left = nil
ullmancalc(n.Left)
- setNodeSeq(&n.List, reorder1(ll))
+ n.List.Set(reorder1(ll))
case OAS:
init.AppendNodes(&n.Ninit)
case OAS2FUNC:
init.AppendNodes(&n.Ninit)
- r := nodeSeqFirst(n.Rlist)
+ r := n.Rlist.First()
walkexprlistsafe(n.List.Slice(), init)
walkexpr(&r, init)
case OAS2RECV:
init.AppendNodes(&n.Ninit)
- r := nodeSeqFirst(n.Rlist)
+ r := n.Rlist.First()
walkexprlistsafe(n.List.Slice(), init)
walkexpr(&r.Left, init)
var n1 *Node
- if isblank(nodeSeqFirst(n.List)) {
+ if isblank(n.List.First()) {
n1 = nodnil()
} else {
- n1 = Nod(OADDR, nodeSeqFirst(n.List), nil)
+ n1 = Nod(OADDR, n.List.First(), nil)
}
n1.Etype = 1 // addr does not escape
fn := chanfn("chanrecv2", 2, r.Left.Type)
- r = mkcall1(fn, nodeSeqSecond(n.List).Type, init, typename(r.Left.Type), r.Left, n1)
- n = Nod(OAS, nodeSeqSecond(n.List), r)
+ r = mkcall1(fn, n.List.Second().Type, init, typename(r.Left.Type), r.Left, n1)
+ n = Nod(OAS, n.List.Second(), r)
typecheck(&n, Etop)
// a,b = m[i];
case OAS2MAPR:
init.AppendNodes(&n.Ninit)
- r := nodeSeqFirst(n.Rlist)
+ r := n.Rlist.First()
walkexprlistsafe(n.List.Slice(), init)
walkexpr(&r.Left, init)
walkexpr(&r.Right, init)
// to:
// var,b = mapaccess2*(t, m, i)
// a = *var
- a := nodeSeqFirst(n.List)
+ a := n.List.First()
fn := mapfn(p, t)
r = mkcall1(fn, fn.Type.Results(), init, typename(t), r.Left, key)
// mapaccess2* returns a typed bool, but due to spec changes,
// the boolean result of i.(T) is now untyped so we make it the
// same type as the variable on the lhs.
- if !isblank(nodeSeqSecond(n.List)) {
- r.Type.Type.Down.Type = nodeSeqSecond(n.List).Type
+ if !isblank(n.List.Second()) {
+ r.Type.Type.Down.Type = n.List.Second().Type
}
setNodeSeq(&n.Rlist, list1(r))
n.Op = OAS2FUNC
case ODELETE:
init.AppendNodes(&n.Ninit)
- map_ := nodeSeqFirst(n.List)
- key := nodeSeqSecond(n.List)
+ map_ := n.List.First()
+ key := n.List.Second()
walkexpr(&map_, init)
walkexpr(&key, init)
n = mkcall1(mapfndel("mapdelete", t), nil, init, typename(t), map_, key)
case OAS2DOTTYPE:
- e := nodeSeqFirst(n.Rlist) // i.(T)
+ e := n.Rlist.First() // i.(T)
// TODO(rsc): The Isfat is for consistency with componentgen and orderexpr.
// It needs to be removed in all three places.
// That would allow inlining x.(struct{*int}) the same as x.(*int).
from := e.Left // i
oktype := Types[TBOOL]
- ok := nodeSeqSecond(n.List)
+ ok := n.List.Second()
if !isblank(ok) {
oktype = ok.Type
}
// Avoid runtime calls in a few cases of the form _, ok := i.(T).
// This is faster and shorter and allows the corresponding assertX2X2
// routines to skip nil checks on their last argument.
- if isblank(nodeSeqFirst(n.List)) {
+ if isblank(n.List.First()) {
var fast *Node
switch {
case fromKind == 'E' && toKind == 'T':
}
var resptr *Node // &res
- if isblank(nodeSeqFirst(n.List)) {
+ if isblank(n.List.First()) {
resptr = nodnil()
} else {
- resptr = Nod(OADDR, nodeSeqFirst(n.List), nil)
+ resptr = Nod(OADDR, n.List.First(), nil)
}
resptr.Etype = 1 // addr does not escape
}
// s + "badgerbadgerbadger" == "badgerbadgerbadger"
- if (Op(n.Etype) == OEQ || Op(n.Etype) == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && nodeSeqLen(n.Left.List) == 2 && Isconst(nodeSeqSecond(n.Left.List), CTSTR) && strlit(n.Right) == strlit(nodeSeqSecond(n.Left.List)) {
+ if (Op(n.Etype) == OEQ || Op(n.Etype) == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && n.Left.List.Len() == 2 && Isconst(n.Left.List.Second(), CTSTR) && strlit(n.Right) == strlit(n.Left.List.Second()) {
// TODO(marvin): Fix Node.EType type union.
- r := Nod(Op(n.Etype), Nod(OLEN, nodeSeqFirst(n.Left.List), nil), Nodintconst(0))
+ r := Nod(Op(n.Etype), Nod(OLEN, n.Left.List.First(), nil), Nodintconst(0))
typecheck(&r, Erv)
walkexpr(&r, init)
r.Type = n.Type
// expr-list = expr-list
// ensure order of evaluation for function calls
- for nlit := nodeSeqIterate(nl); !nlit.Done(); nlit.Next() {
- *nlit.P() = safeexpr(nlit.N(), init)
+ for i := range nl {
+ nl[i] = safeexpr(nl[i], init)
}
- for nrit := nodeSeqIterate(nr); !nrit.Done(); nrit.Next() {
- *nrit.P() = safeexpr(nrit.N(), init)
+ for i1 := range nr {
+ nr[i1] = safeexpr(nr[i1], init)
}
var nn []*Node
}
if !it.Done() || r != nil {
- Yyerror("ascompatet: assignment count mismatch: %d = %d", nodeSeqLen(nl), structcount(*nr))
+ Yyerror("ascompatet: assignment count mismatch: %d = %d", nl.Len(), structcount(*nr))
}
if ucount != 0 {
if ddd != nil && prealloc[ddd] != nil {
prealloc[n] = prealloc[ddd] // temporary to use
}
- setNodeSeq(&n.List, lr0)
+ n.List.Set(lr0)
n.Esc = esc
typecheck(&n, Erv)
if n.Type == nil {
fmt_ := ""
fmt_ += "\t"
first := 1
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- r = it.N()
+ for _, r = range l {
if first != 0 {
first = 0
} else {
}
a = Nod(OAS2, nil, nil)
- setNodeSeq(&a.List, alist)
- setNodeSeq(&a.Rlist, lr)
+ a.List.Set(alist)
+ a.Rlist.Set(lr)
typecheck(&a, Etop)
walkstmt(&a)
init.Append(a)
walkexprlistcheap(all.Slice(), init)
calls = append(calls, mkcall("printlock", nil, init))
-
- for it := nodeSeqIterate(all); !it.Done(); it.Next() {
+ for i1, n1 := range all.Slice() {
if notfirst {
calls = append(calls, mkcall("printsp", nil, init))
}
notfirst = op == OPRINTN
- n = it.N()
+ n = n1
if n.Op == OLITERAL {
switch n.Val().Ctype() {
case CTRUNE:
defaultlit(&n, Types[TINT64])
}
defaultlit(&n, nil)
- *it.P() = n
+ all.Slice()[i1] = n
if n.Type == nil || n.Type.Etype == TFORW {
continue
}
}
r = Nod(OCALL, on, nil)
- appendNodeSeqNode(&r.List, n)
+ r.List.Append(n)
calls = append(calls, r)
}
r = Nod(OEMPTY, nil, nil)
typecheck(&r, Etop)
walkexpr(&r, init)
- setNodeSeq(&r.Ninit, calls)
+ r.Ninit.Set(calls)
return r
}
if vmatch2(l, r.Right) {
return true
}
- for it := nodeSeqIterate(r.List); !it.Done(); it.Next() {
- if vmatch2(l, it.N()) {
+ for _, n := range r.List.Slice() {
+ if vmatch2(l, n) {
return true
}
}
if vmatch1(l.Right, r) {
return true
}
- for it := nodeSeqIterate(l.List); !it.Done(); it.Next() {
- if vmatch1(it.N(), r) {
+ for _, n := range l.List.Slice() {
+ if vmatch1(n, r) {
return true
}
}
n := fn.Type.Intuple
r := Nod(OCALL, fn, nil)
- setNodeSeq(&r.List, va[:n])
+ r.List.Set(va[:n])
if fn.Type.Outtuple > 0 {
typecheck(&r, Erv|Efnstruct)
} else {
func addstr(n *Node, init *Nodes) *Node {
// orderexpr rewrote OADDSTR to have a list of strings.
- c := nodeSeqLen(n.List)
+ c := n.List.Len()
if c < 2 {
Yyerror("addstr count %d too small", c)
buf := nodnil()
if n.Esc == EscNone {
sz := int64(0)
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- if it.N().Op == OLITERAL {
- sz += int64(len(it.N().Val().U.(string)))
+ for _, n1 := range n.List.Slice() {
+ if n1.Op == OLITERAL {
+ sz += int64(len(n1.Val().U.(string)))
}
}
// build list of string arguments
args := []*Node{buf}
-
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- args = append(args, conv(it.N(), Types[TSTRING]))
+ for _, n2 := range n.List.Slice() {
+ args = append(args, conv(n2, Types[TSTRING]))
}
var fn string
if prealloc[n] != nil {
prealloc[slice] = prealloc[n]
}
- setNodeSeq(&slice.List, args[1:]) // skip buf arg
+ slice.List.Set(args[1:]) // skip buf arg
args = []*Node{buf}
args = append(args, slice)
slice.Esc = EscNone
cat := syslook(fn)
r := Nod(OCALL, cat, nil)
- setNodeSeq(&r.List, args)
+ r.List.Set(args)
typecheck(&r, Erv)
walkexpr(&r, init)
r.Type = n.Type
// l2 is allowed to be a string.
func appendslice(n *Node, init *Nodes) *Node {
walkexprlistsafe(n.List.Slice(), init)
+ for i1 := range
// walkexprlistsafe will leave OINDEX (s[n]) alone if both s
// and n are name or literal, but those may index the slice we're
// modifying here. Fix explicitly.
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
- *it.P() = cheapexpr(it.N(), init)
+ n.List.Slice() {
+ n.List.Slice()[i1] = cheapexpr(n.List.Slice()[i1],
+ init)
}
- l1 := nodeSeqFirst(n.List)
- l2 := nodeSeqSecond(n.List)
+ l1 := n.List.First()
+ l2 := n.List.Second()
s := temp(l1.Type) // var s []T
var l []*Node
// }
// s
func walkappend(n *Node, init *Nodes, dst *Node) *Node {
- if !samesafeexpr(dst, nodeSeqFirst(n.List)) {
+ if !samesafeexpr(dst, n.List.First()) {
it := nodeSeqIterate(n.List)
*it.P() = safeexpr(it.N(), init)
walkexpr(it.P(), init)
*it.P() = cheapexpr(it.N(), init)
}
- nsrc := nodeSeqFirst(n.List)
+ nsrc := n.List.First()
// Resolve slice type of multi-valued return.
if Istype(nsrc.Type, TSTRUCT) {
nsrc.Type = nsrc.Type.Type.Type
}
- argc := nodeSeqLen(n.List) - 1
+ argc := n.List.Len() - 1
if argc < 1 {
return nsrc
}
n := newname(sym)
n.Class = PFUNC
ntype := Nod(OTFUNC, nil, nil)
- appendNodeSeqNode(&ntype.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
- appendNodeSeqNode(&ntype.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
- appendNodeSeqNode(&ntype.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TBOOL])))
+ ntype.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
+ ntype.List.Append(Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
+ ntype.Rlist.Append(Nod(ODCLFIELD, nil, typenod(Types[TBOOL])))
typecheck(&ntype, Etype)
n.Type = ntype.Type
*needsize = 0
// x, ok := l.(type(r))
expr := Nod(OAS2, nil, nil)
- appendNodeSeqNode(&expr.List, x)
- appendNodeSeqNode(&expr.List, ok)
- appendNodeSeqNode(&expr.Rlist, a)
+ expr.List.Append(x)
+ expr.List.Append(ok)
+ expr.Rlist.Append(a)
typecheck(&expr, Etop)
walkexpr(&expr, init)
var needsize int
call := Nod(OCALL, eqfor(t, &needsize), nil)
- appendNodeSeqNode(&call.List, l)
- appendNodeSeqNode(&call.List, r)
+ call.List.Append(l)
+ call.List.Append(r)
if needsize != 0 {
- appendNodeSeqNode(&call.List, Nodintconst(t.Width))
+ call.List.Append(Nodintconst(t.Width))
}
r = call
if n.Op != OEQ {
}
func candiscardlist(l Nodes) bool {
- for it := nodeSeqIterate(l); !it.Done(); it.Next() {
- if !candiscard(it.N()) {
+ for _, n := range l.Slice() {
+ if !candiscard(n) {
return false
}
}
func walkprintfunc(np **Node, init *Nodes) {
n := *np
- if nodeSeqLen(n.Ninit) != 0 {
+ if n.Ninit.Len() != 0 {
walkstmtlist(n.Ninit.Slice())
init.AppendNodes(&n.Ninit)
}
var printargs []*Node
var a *Node
var buf string
- for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
+ for _, n1 := range n.List.Slice() {
buf = fmt.Sprintf("a%d", num)
num++
- a = Nod(ODCLFIELD, newname(Lookup(buf)), typenod(it.N().Type))
- appendNodeSeqNode(&t.List, a)
+ a = Nod(ODCLFIELD, newname(Lookup(buf)), typenod(n1.Type))
+ t.List.Append(a)
printargs = append(printargs, a.Left)
}
funchdr(fn)
a = Nod(n.Op, nil, nil)
- setNodeSeq(&a.List, printargs)
+ a.List.Set(printargs)
typecheck(&a, Etop)
walkstmt(&a)
a = Nod(OCALL, nil, nil)
a.Left = fn.Func.Nname
- setNodeSeq(&a.List, n.List)
+ a.List.Set(n.List.Slice())
typecheck(&a, Etop)
walkexpr(&a, init)
*np = a