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

cmd/compile: remove nodesOrNodeList outside of syntax.go

Passes toolstash -cmp.

Update #14473.

Change-Id: I717ebd948dfc8faf8b9ef5aa02c67484af618d18
Reviewed-on: https://go-review.googlesource.com/20359Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent f3a29f1f
...@@ -288,7 +288,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -288,7 +288,7 @@ func genhash(sym *Sym, t *Type) {
Curfn = fn Curfn = fn
fn.Func.Dupok = true fn.Func.Dupok = true
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody, Etop) typechecklist(fn.Nbody.Slice(), Etop)
Curfn = nil Curfn = nil
// Disable safemode while compiling this code: the code we // Disable safemode while compiling this code: the code we
...@@ -486,7 +486,7 @@ func geneq(sym *Sym, t *Type) { ...@@ -486,7 +486,7 @@ func geneq(sym *Sym, t *Type) {
Curfn = fn Curfn = fn
fn.Func.Dupok = true fn.Func.Dupok = true
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody, Etop) typechecklist(fn.Nbody.Slice(), Etop)
Curfn = nil Curfn = nil
// Disable safemode while compiling this code: the code we // Disable safemode while compiling this code: the code we
......
...@@ -806,7 +806,7 @@ func (p *exporter) inlinedBody(n *Node) { ...@@ -806,7 +806,7 @@ func (p *exporter) inlinedBody(n *Node) {
p.int(index) p.int(index)
} }
func (p *exporter) nodeList(list nodesOrNodeList) { func (p *exporter) nodeList(list Nodes) {
it := nodeSeqIterate(list) it := nodeSeqIterate(list)
if p.trace { if p.trace {
p.tracef("[ ") p.tracef("[ ")
......
...@@ -249,8 +249,8 @@ func (p *importer) typ() *Type { ...@@ -249,8 +249,8 @@ func (p *importer) typ() *Type {
} }
sym := pkg.Lookup(name) sym := pkg.Lookup(name)
n := methodname1(newname(sym), recv.N.Right) n := methodname1(newname(sym), recv[0].Right)
n.Type = functype(recv.N, params, result) n.Type = functype(recv[0], params, result)
checkwidth(n.Type) checkwidth(n.Type)
// addmethod uses the global variable structpkg to verify consistency // addmethod uses the global variable structpkg to verify consistency
{ {
...@@ -342,14 +342,14 @@ func (p *importer) qualifiedName() *Sym { ...@@ -342,14 +342,14 @@ func (p *importer) qualifiedName() *Sym {
} }
// go.y:hidden_structdcl_list // go.y:hidden_structdcl_list
func (p *importer) fieldList() *NodeList { func (p *importer) fieldList() []*Node {
i := p.int() i := p.int()
if i == 0 { if i == 0 {
return nil return nil
} }
n := list1(p.field()) n := make([]*Node, 0, i)
for i--; i > 0; i-- { for ; i > 0; i-- {
n = list(n, p.field()) n = append(n, p.field())
} }
return n return n
} }
...@@ -389,14 +389,14 @@ func (p *importer) note() (v Val) { ...@@ -389,14 +389,14 @@ func (p *importer) note() (v Val) {
} }
// go.y:hidden_interfacedcl_list // go.y:hidden_interfacedcl_list
func (p *importer) methodList() *NodeList { func (p *importer) methodList() []*Node {
i := p.int() i := p.int()
if i == 0 { if i == 0 {
return nil return nil
} }
n := list1(p.method()) n := make([]*Node, 0, i)
for i--; i > 0; i-- { for ; i > 0; i-- {
n = list(n, p.method()) n = append(n, p.method())
} }
return n return n
} }
...@@ -428,7 +428,7 @@ func (p *importer) fieldName() *Sym { ...@@ -428,7 +428,7 @@ func (p *importer) fieldName() *Sym {
} }
// go.y:ohidden_funarg_list // go.y:ohidden_funarg_list
func (p *importer) paramList() *NodeList { func (p *importer) paramList() []*Node {
i := p.int() i := p.int()
if i == 0 { if i == 0 {
return nil return nil
...@@ -440,10 +440,9 @@ func (p *importer) paramList() *NodeList { ...@@ -440,10 +440,9 @@ func (p *importer) paramList() *NodeList {
named = false named = false
} }
// i > 0 // i > 0
n := list1(p.param(named)) n := make([]*Node, 0, i)
i--
for ; i > 0; i-- { for ; i > 0; i-- {
n = list(n, p.param(named)) n = append(n, p.param(named))
} }
return n return n
} }
......
...@@ -111,7 +111,7 @@ func typecheckclosure(func_ *Node, top int) { ...@@ -111,7 +111,7 @@ func typecheckclosure(func_ *Node, top int) {
Curfn = func_ Curfn = func_
olddd := decldepth olddd := decldepth
decldepth = 1 decldepth = 1
typechecklist(func_.Nbody, Etop) typechecklist(func_.Nbody.Slice(), Etop)
decldepth = olddd decldepth = olddd
Curfn = oldfn Curfn = oldfn
} }
......
...@@ -297,7 +297,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList { ...@@ -297,7 +297,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList {
lastconst = cl lastconst = cl
lasttype = t lasttype = t
} }
clcopy := listtreecopy(cl, lno) clcopy := listtreecopy(nodeSeqSlice(cl), lno)
var v *Node var v *Node
var c *Node var c *Node
...@@ -437,7 +437,7 @@ func colasname(n *Node) bool { ...@@ -437,7 +437,7 @@ func colasname(n *Node) bool {
return false return false
} }
func colasdefn(left nodesOrNodeList, defn *Node) { func colasdefn(left Nodes, defn *Node) {
for it := nodeSeqIterate(left); !it.Done(); it.Next() { for it := nodeSeqIterate(left); !it.Done(); it.Next() {
if it.N().Sym != nil { if it.N().Sym != nil {
it.N().Sym.Flags |= SymUniq it.N().Sym.Flags |= SymUniq
...@@ -828,13 +828,13 @@ func checkdupfields(t *Type, what string) { ...@@ -828,13 +828,13 @@ func checkdupfields(t *Type, what string) {
// convert a parsed id/type list into // convert a parsed id/type list into
// a type for struct/interface/arglist // a type for struct/interface/arglist
func tostruct(l nodesOrNodeList) *Type { func tostruct(l []*Node) *Type {
t := typ(TSTRUCT) t := typ(TSTRUCT)
tostruct0(t, l) tostruct0(t, l)
return t return t
} }
func tostruct0(t *Type, l nodesOrNodeList) { func tostruct0(t *Type, l []*Node) {
if t == nil || t.Etype != TSTRUCT { if t == nil || t.Etype != TSTRUCT {
Fatalf("struct expected") Fatalf("struct expected")
} }
...@@ -860,7 +860,7 @@ func tostruct0(t *Type, l nodesOrNodeList) { ...@@ -860,7 +860,7 @@ func tostruct0(t *Type, l nodesOrNodeList) {
} }
} }
func tofunargs(l nodesOrNodeList) *Type { func tofunargs(l []*Node) *Type {
var f *Type var f *Type
t := typ(TSTRUCT) t := typ(TSTRUCT)
...@@ -955,13 +955,13 @@ func interfacefield(n *Node) *Type { ...@@ -955,13 +955,13 @@ func interfacefield(n *Node) *Type {
return f return f
} }
func tointerface(l nodesOrNodeList) *Type { func tointerface(l []*Node) *Type {
t := typ(TINTER) t := typ(TINTER)
tointerface0(t, l) tointerface0(t, l)
return t return t
} }
func tointerface0(t *Type, l nodesOrNodeList) *Type { func tointerface0(t *Type, l []*Node) *Type {
if t == nil || t.Etype != TINTER { if t == nil || t.Etype != TINTER {
Fatalf("interface expected") Fatalf("interface expected")
} }
...@@ -1155,20 +1155,20 @@ func isifacemethod(f *Type) bool { ...@@ -1155,20 +1155,20 @@ func isifacemethod(f *Type) bool {
} }
// turn a parsed function declaration into a type // turn a parsed function declaration into a type
func functype(this *Node, in nodesOrNodeList, out nodesOrNodeList) *Type { func functype(this *Node, in, out []*Node) *Type {
t := typ(TFUNC) t := typ(TFUNC)
functype0(t, this, in, out) functype0(t, this, in, out)
return t return t
} }
func functype0(t *Type, this *Node, in nodesOrNodeList, out nodesOrNodeList) { func functype0(t *Type, this *Node, in, out []*Node) {
if t == nil || t.Etype != TFUNC { if t == nil || t.Etype != TFUNC {
Fatalf("function type expected") Fatalf("function type expected")
} }
var rcvr *NodeList var rcvr []*Node
if this != nil { if this != nil {
rcvr = list1(this) rcvr = []*Node{this}
} }
t.Type = tofunargs(rcvr) t.Type = tofunargs(rcvr)
t.Type.Down = tofunargs(out) t.Type.Down = tofunargs(out)
...@@ -1538,7 +1538,7 @@ func checknowritebarrierrec() { ...@@ -1538,7 +1538,7 @@ func checknowritebarrierrec() {
}) })
} }
func (c *nowritebarrierrecChecker) visitcodelist(l nodesOrNodeList) { func (c *nowritebarrierrecChecker) visitcodelist(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
c.visitcode(it.N()) c.visitcode(it.N())
} }
......
...@@ -110,7 +110,7 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 { ...@@ -110,7 +110,7 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 {
return min return min
} }
func (v *bottomUpVisitor) visitcodelist(l nodesOrNodeList, min uint32) uint32 { func (v *bottomUpVisitor) visitcodelist(l Nodes, min uint32) uint32 {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
min = v.visitcode(it.N(), min) min = v.visitcode(it.N(), min)
} }
...@@ -300,9 +300,9 @@ func (l Level) guaranteedDereference() int { ...@@ -300,9 +300,9 @@ func (l Level) guaranteedDereference() int {
type NodeEscState struct { type NodeEscState struct {
Curfn *Node Curfn *Node
Escflowsrc []*Node // flow(this, src) Escflowsrc []*Node // flow(this, src)
Escretval *NodeList // on OCALLxxx, list of dummy return values Escretval Nodes // on OCALLxxx, list of dummy return values
Escloopdepth int32 // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes Escloopdepth int32 // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes
Esclevel Level Esclevel Level
Walkgen uint32 Walkgen uint32
Maxextraloopdepth int32 Maxextraloopdepth int32
...@@ -522,7 +522,7 @@ var looping Label ...@@ -522,7 +522,7 @@ var looping Label
var nonlooping Label var nonlooping Label
func escloopdepthlist(e *EscState, l nodesOrNodeList) { func escloopdepthlist(e *EscState, l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
escloopdepth(e, it.N()) escloopdepth(e, it.N())
} }
...@@ -566,7 +566,7 @@ func escloopdepth(e *EscState, n *Node) { ...@@ -566,7 +566,7 @@ func escloopdepth(e *EscState, n *Node) {
escloopdepthlist(e, n.Rlist) escloopdepthlist(e, n.Rlist)
} }
func esclist(e *EscState, l nodesOrNodeList, up *Node) { func esclist(e *EscState, l Nodes, up *Node) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
esc(e, it.N(), up) esc(e, it.N(), up)
} }
...@@ -771,7 +771,7 @@ func esc(e *EscState, n *Node, up *Node) { ...@@ -771,7 +771,7 @@ func esc(e *EscState, n *Node, up *Node) {
} }
case ORETURN: case ORETURN:
ll := nodesOrNodeList(n.List) ll := n.List
if nodeSeqLen(n.List) == 1 && Curfn.Type.Outtuple > 1 { if nodeSeqLen(n.List) == 1 && Curfn.Type.Outtuple > 1 {
// OAS2FUNC in disguise // OAS2FUNC in disguise
// esccall already done on n->list->n // esccall already done on n->list->n
...@@ -1204,7 +1204,7 @@ func describeEscape(em uint16) string { ...@@ -1204,7 +1204,7 @@ func describeEscape(em uint16) string {
// escassignfromtag models the input-to-output assignment flow of one of a function // escassignfromtag models the input-to-output assignment flow of one of a function
// calls arguments, where the flow is encoded in "note". // calls arguments, where the flow is encoded in "note".
func escassignfromtag(e *EscState, note *string, dsts nodesOrNodeList, src *Node) uint16 { func escassignfromtag(e *EscState, note *string, dsts Nodes, src *Node) uint16 {
em := parsetag(note) em := parsetag(note)
if src.Op == OLITERAL { if src.Op == OLITERAL {
return em return em
...@@ -1320,7 +1320,7 @@ func escNoteOutputParamFlow(e uint16, vargen int32, level Level) uint16 { ...@@ -1320,7 +1320,7 @@ func escNoteOutputParamFlow(e uint16, vargen int32, level Level) uint16 {
func initEscretval(e *EscState, n *Node, fntype *Type) { func initEscretval(e *EscState, n *Node, fntype *Type) {
i := 0 i := 0
nE := e.nodeEscState(n) nE := e.nodeEscState(n)
setNodeSeq(&nE.Escretval, nil) // Suspect this is not nil for indirect calls. nE.Escretval.Set(nil) // Suspect this is not nil for indirect calls.
for t := getoutargx(fntype).Type; t != nil; t = t.Down { for t := getoutargx(fntype).Type; t != nil; t = t.Down {
src := Nod(ONAME, nil, nil) src := Nod(ONAME, nil, nil)
buf := fmt.Sprintf(".out%d", i) buf := fmt.Sprintf(".out%d", i)
...@@ -1332,7 +1332,7 @@ func initEscretval(e *EscState, n *Node, fntype *Type) { ...@@ -1332,7 +1332,7 @@ func initEscretval(e *EscState, n *Node, fntype *Type) {
e.nodeEscState(src).Escloopdepth = e.loopdepth e.nodeEscState(src).Escloopdepth = e.loopdepth
src.Used = true src.Used = true
src.Lineno = n.Lineno src.Lineno = n.Lineno
appendNodeSeqNode(&nE.Escretval, src) nE.Escretval.Append(src)
} }
} }
...@@ -1368,7 +1368,7 @@ func esccall(e *EscState, n *Node, up *Node) { ...@@ -1368,7 +1368,7 @@ func esccall(e *EscState, n *Node, up *Node) {
indirect = true indirect = true
} }
ll := nodesOrNodeList(n.List) ll := n.List
if nodeSeqLen(n.List) == 1 { if nodeSeqLen(n.List) == 1 {
a := nodeSeqFirst(n.List) a := nodeSeqFirst(n.List)
if a.Type.Etype == TSTRUCT && a.Type.Funarg { // f(g()). if a.Type.Etype == TSTRUCT && a.Type.Funarg { // f(g()).
......
...@@ -106,7 +106,7 @@ func dumppkg(p *Pkg) { ...@@ -106,7 +106,7 @@ func dumppkg(p *Pkg) {
} }
// Look for anything we need for the inline body // Look for anything we need for the inline body
func reexportdeplist(ll nodesOrNodeList) { func reexportdeplist(ll Nodes) {
for it := nodeSeqIterate(ll); !it.Done(); it.Next() { for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
reexportdep(it.N()) reexportdep(it.N())
} }
......
...@@ -1699,7 +1699,9 @@ func Nconv(n *Node, flag int) string { ...@@ -1699,7 +1699,9 @@ func Nconv(n *Node, flag int) string {
} }
func (l *NodeList) String() string { func (l *NodeList) String() string {
return Hconv(l, 0) var n Nodes
n.Set(nodeSeqSlice(l))
return Hconv(n, 0)
} }
func (n Nodes) String() string { func (n Nodes) String() string {
...@@ -1708,7 +1710,7 @@ func (n Nodes) String() string { ...@@ -1708,7 +1710,7 @@ func (n Nodes) String() string {
// Fmt '%H': NodeList. // Fmt '%H': NodeList.
// Flags: all those of %N plus ',': separate with comma's instead of semicolons. // Flags: all those of %N plus ',': separate with comma's instead of semicolons.
func Hconv(l nodesOrNodeList, flag int) string { func Hconv(l Nodes, flag int) string {
if nodeSeqLen(l) == 0 && fmtmode == FDbg { if nodeSeqLen(l) == 0 && fmtmode == FDbg {
return "<nil>" return "<nil>"
} }
...@@ -1736,7 +1738,7 @@ func Hconv(l nodesOrNodeList, flag int) string { ...@@ -1736,7 +1738,7 @@ func Hconv(l nodesOrNodeList, flag int) string {
return buf.String() return buf.String()
} }
func dumplist(s string, l nodesOrNodeList) { func dumplist(s string, l Nodes) {
fmt.Printf("%s%v\n", s, Hconv(l, obj.FmtSign)) fmt.Printf("%s%v\n", s, Hconv(l, obj.FmtSign))
} }
......
...@@ -215,7 +215,7 @@ func stmtlabel(n *Node) *Label { ...@@ -215,7 +215,7 @@ func stmtlabel(n *Node) *Label {
} }
// compile statements // compile statements
func Genlist(l nodesOrNodeList) { func Genlist(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
gen(it.N()) gen(it.N())
} }
...@@ -440,7 +440,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) { ...@@ -440,7 +440,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) {
r1.Type = byteptr r1.Type = byteptr
r2.Type = byteptr r2.Type = byteptr
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type))) setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List, 0, nil)) setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List.Slice(), 0, nil))
gen(call) gen(call)
Regfree(&r1) Regfree(&r1)
Regfree(&r2) Regfree(&r2)
...@@ -526,7 +526,7 @@ func Cgen_As2dottype(n, res, resok *Node) { ...@@ -526,7 +526,7 @@ func Cgen_As2dottype(n, res, resok *Node) {
dowidth(fn.Type) dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil) call := Nod(OCALLFUNC, fn, nil)
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type))) setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List, 0, nil)) setNodeSeq(&call.List, ascompatte(OCALLFUNC, call, false, getinarg(fn.Type), call.List.Slice(), 0, nil))
gen(call) gen(call)
Regfree(&r1) Regfree(&r1)
Regfree(&r2) Regfree(&r2)
......
...@@ -94,7 +94,7 @@ func fninit(n *NodeList) { ...@@ -94,7 +94,7 @@ func fninit(n *NodeList) {
return return
} }
nf := initfix(n) nf := initfix(nodeSeqSlice(n))
if !anyinit(nf) { if !anyinit(nf) {
return return
} }
......
...@@ -87,7 +87,7 @@ func typecheckinl(fn *Node) { ...@@ -87,7 +87,7 @@ func typecheckinl(fn *Node) {
savefn := Curfn savefn := Curfn
Curfn = fn Curfn = fn
typechecklist(fn.Func.Inl, Etop) typechecklist(fn.Func.Inl.Slice(), Etop)
Curfn = savefn Curfn = savefn
safemode = save_safemode safemode = save_safemode
...@@ -170,7 +170,7 @@ func caninl(fn *Node) { ...@@ -170,7 +170,7 @@ func caninl(fn *Node) {
} }
// Look for anything we want to punt on. // Look for anything we want to punt on.
func ishairylist(ll nodesOrNodeList, budget *int) bool { func ishairylist(ll Nodes, budget *int) bool {
for it := nodeSeqIterate(ll); !it.Done(); it.Next() { for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
if ishairy(it.N(), budget) { if ishairy(it.N(), budget) {
return true return true
...@@ -245,7 +245,7 @@ func ishairy(n *Node, budget *int) bool { ...@@ -245,7 +245,7 @@ func ishairy(n *Node, budget *int) bool {
// Inlcopy and inlcopylist recursively copy the body of a function. // Inlcopy and inlcopylist recursively copy the body of a function.
// Any name-like node of non-local class is marked for re-export by adding it to // Any name-like node of non-local class is marked for re-export by adding it to
// the exportlist. // the exportlist.
func inlcopylist(ll nodesOrNodeList) []*Node { func inlcopylist(ll []*Node) []*Node {
s := make([]*Node, 0, nodeSeqLen(ll)) s := make([]*Node, 0, nodeSeqLen(ll))
for it := nodeSeqIterate(ll); !it.Done(); it.Next() { for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
s = append(s, inlcopy(it.N())) s = append(s, inlcopy(it.N()))
...@@ -270,9 +270,9 @@ func inlcopy(n *Node) *Node { ...@@ -270,9 +270,9 @@ func inlcopy(n *Node) *Node {
} }
m.Left = inlcopy(n.Left) m.Left = inlcopy(n.Left)
m.Right = inlcopy(n.Right) m.Right = inlcopy(n.Right)
setNodeSeq(&m.List, inlcopylist(n.List)) setNodeSeq(&m.List, inlcopylist(n.List.Slice()))
setNodeSeq(&m.Rlist, inlcopylist(n.Rlist)) setNodeSeq(&m.Rlist, inlcopylist(n.Rlist.Slice()))
setNodeSeq(&m.Ninit, inlcopylist(n.Ninit)) setNodeSeq(&m.Ninit, inlcopylist(n.Ninit.Slice()))
m.Nbody.Set(inlcopylist(n.Nbody.Slice())) m.Nbody.Set(inlcopylist(n.Nbody.Slice()))
return m return m
...@@ -324,7 +324,7 @@ func inlconv2list(n *Node) []*Node { ...@@ -324,7 +324,7 @@ func inlconv2list(n *Node) []*Node {
return s return s
} }
func inlnodelist(l nodesOrNodeList) { func inlnodelist(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
inlnode(it.P()) inlnode(it.P())
} }
...@@ -899,7 +899,7 @@ func newlabel_inl() *Node { ...@@ -899,7 +899,7 @@ func newlabel_inl() *Node {
// pristine ->inl body of the function while substituting references // pristine ->inl body of the function while substituting references
// to input/output parameters with ones to the tmpnames, and // to input/output parameters with ones to the tmpnames, and
// substituting returns with assignments to the output. // substituting returns with assignments to the output.
func inlsubstlist(ll nodesOrNodeList) []*Node { func inlsubstlist(ll Nodes) []*Node {
s := make([]*Node, 0, nodeSeqLen(ll)) s := make([]*Node, 0, nodeSeqLen(ll))
for it := nodeSeqIterate(ll); !it.Done(); it.Next() { for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
s = append(s, inlsubst(it.N())) s = append(s, inlsubst(it.N()))
...@@ -949,7 +949,7 @@ func inlsubst(n *Node) *Node { ...@@ -949,7 +949,7 @@ func inlsubst(n *Node) *Node {
appendNodeSeqNode(&m.Ninit, as) appendNodeSeqNode(&m.Ninit, as)
} }
typechecklist(m.Ninit, Etop) typechecklist(m.Ninit.Slice(), Etop)
typecheck(&m, Etop) typecheck(&m, Etop)
// dump("Return after substitution", m); // dump("Return after substitution", m);
...@@ -984,7 +984,7 @@ func inlsubst(n *Node) *Node { ...@@ -984,7 +984,7 @@ func inlsubst(n *Node) *Node {
} }
// Plaster over linenumbers // Plaster over linenumbers
func setlnolist(ll nodesOrNodeList, lno int32) { func setlnolist(ll Nodes, lno int32) {
for it := nodeSeqIterate(ll); !it.Done(); it.Next() { for it := nodeSeqIterate(ll); !it.Done(); it.Next() {
setlno(it.N(), lno) setlno(it.N(), lno)
} }
......
...@@ -402,7 +402,7 @@ func Main() { ...@@ -402,7 +402,7 @@ func Main() {
Curfn = l.N Curfn = l.N
decldepth = 1 decldepth = 1
saveerrors() saveerrors()
typechecklist(l.N.Nbody, Etop) typechecklist(l.N.Nbody.Slice(), Etop)
checkreturn(l.N) checkreturn(l.N)
if nerrors != 0 { if nerrors != 0 {
l.N.Nbody.Set(nil) // type errors; do not compile l.N.Nbody.Set(nil) // type errors; do not compile
......
...@@ -249,7 +249,7 @@ func cleantemp(top ordermarker, order *Order) { ...@@ -249,7 +249,7 @@ func cleantemp(top ordermarker, order *Order) {
} }
// Orderstmtlist orders each of the statements in the list. // Orderstmtlist orders each of the statements in the list.
func orderstmtlist(l nodesOrNodeList, order *Order) { func orderstmtlist(l Nodes, order *Order) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
orderstmt(it.N(), order) orderstmt(it.N(), order)
} }
...@@ -257,7 +257,7 @@ func orderstmtlist(l nodesOrNodeList, order *Order) { ...@@ -257,7 +257,7 @@ func orderstmtlist(l nodesOrNodeList, order *Order) {
// Orderblock orders the block of statements l onto a new list, // Orderblock orders the block of statements l onto a new list,
// and returns the ordered list. // and returns the ordered list.
func orderblock(l nodesOrNodeList) []*Node { func orderblock(l Nodes) []*Node {
var order Order var order Order
mark := marktemp(&order) mark := marktemp(&order)
orderstmtlist(l, &order) orderstmtlist(l, &order)
...@@ -270,7 +270,7 @@ func orderblock(l nodesOrNodeList) []*Node { ...@@ -270,7 +270,7 @@ func orderblock(l nodesOrNodeList) []*Node {
func orderblockNodes(n *Nodes) { func orderblockNodes(n *Nodes) {
var order Order var order Order
mark := marktemp(&order) mark := marktemp(&order)
orderstmtlist(n.Slice(), &order) orderstmtlist(*n, &order)
cleantemp(mark, &order) cleantemp(mark, &order)
n.Set(order.out) n.Set(order.out)
} }
...@@ -309,7 +309,7 @@ func orderinit(n *Node, order *Order) { ...@@ -309,7 +309,7 @@ func orderinit(n *Node, order *Order) {
// Ismulticall reports whether the list l is f() for a multi-value function. // 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. // Such an f() could appear as the lone argument to a multi-arg function.
func ismulticall(l nodesOrNodeList) bool { func ismulticall(l Nodes) bool {
// one arg only // one arg only
if nodeSeqLen(l) != 1 { if nodeSeqLen(l) != 1 {
return false return false
...@@ -331,33 +331,34 @@ func ismulticall(l nodesOrNodeList) bool { ...@@ -331,33 +331,34 @@ func ismulticall(l nodesOrNodeList) bool {
// Copyret emits t1, t2, ... = n, where n is a function call, // Copyret emits t1, t2, ... = n, where n is a function call,
// and then returns the list t1, t2, .... // and then returns the list t1, t2, ....
func copyret(n *Node, order *Order) *NodeList { func copyret(n *Node, order *Order) Nodes {
if n.Type.Etype != TSTRUCT || !n.Type.Funarg { if n.Type.Etype != TSTRUCT || !n.Type.Funarg {
Fatalf("copyret %v %d", n.Type, n.Left.Type.Outtuple) Fatalf("copyret %v %d", n.Type, n.Left.Type.Outtuple)
} }
var l1 *NodeList var l1 []*Node
var l2 *NodeList var l2 []*Node
var tl Iter var tl Iter
var tmp *Node
for t := Structfirst(&tl, &n.Type); t != nil; t = structnext(&tl) { for t := Structfirst(&tl, &n.Type); t != nil; t = structnext(&tl) {
tmp = temp(t.Type) tmp := temp(t.Type)
l1 = list(l1, tmp) l1 = append(l1, tmp)
l2 = list(l2, tmp) l2 = append(l2, tmp)
} }
as := Nod(OAS2, nil, nil) as := Nod(OAS2, nil, nil)
setNodeSeq(&as.List, l1) as.List.Set(l1)
setNodeSeq(&as.Rlist, list1(n)) as.Rlist.Set([]*Node{n})
typecheck(&as, Etop) typecheck(&as, Etop)
orderstmt(as, order) orderstmt(as, order)
return l2 var r Nodes
r.Set(l2)
return r
} }
// Ordercallargs orders the list of call arguments l and returns the // Ordercallargs orders the list of call arguments l and returns the
// ordered list. // ordered list.
func ordercallargs(l nodesOrNodeList, order *Order) nodesOrNodeList { func ordercallargs(l Nodes, order *Order) Nodes {
if ismulticall(l) { if ismulticall(l) {
// return f() where f() is multiple values. // return f() where f() is multiple values.
return copyret(nodeSeqFirst(l), order) return copyret(nodeSeqFirst(l), order)
...@@ -969,7 +970,7 @@ func orderstmt(n *Node, order *Order) { ...@@ -969,7 +970,7 @@ func orderstmt(n *Node, order *Order) {
} }
// Orderexprlist orders the expression list l into order. // Orderexprlist orders the expression list l into order.
func orderexprlist(l nodesOrNodeList, order *Order) { func orderexprlist(l Nodes, order *Order) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
orderexpr(it.P(), order, nil) orderexpr(it.P(), order, nil)
} }
...@@ -977,7 +978,7 @@ func orderexprlist(l nodesOrNodeList, order *Order) { ...@@ -977,7 +978,7 @@ func orderexprlist(l nodesOrNodeList, order *Order) {
// Orderexprlist orders the expression list l but saves // Orderexprlist orders the expression list l but saves
// the side effects on the individual expression ninit lists. // the side effects on the individual expression ninit lists.
func orderexprlistinplace(l nodesOrNodeList, order *Order) { func orderexprlistinplace(l Nodes, order *Order) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
orderexprinplace(it.P(), order) orderexprinplace(it.P(), order)
} }
......
...@@ -682,12 +682,12 @@ func (p *parser) labeled_stmt(label *Node) *Node { ...@@ -682,12 +682,12 @@ func (p *parser) labeled_stmt(label *Node) *Node {
} }
label.Name.Defn = ls label.Name.Defn = ls
l := list1(label) l := []*Node{label}
if ls != nil { if ls != nil {
if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 { if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 {
appendNodeSeq(&l, ls.List) l = append(l, ls.List.Slice()...)
} else { } else {
appendNodeSeqNode(&l, ls) l = append(l, ls)
} }
} }
return liststmt(l) return liststmt(l)
...@@ -837,7 +837,7 @@ func (p *parser) compound_stmt(else_clause bool) *Node { ...@@ -837,7 +837,7 @@ func (p *parser) compound_stmt(else_clause bool) *Node {
if l == nil { if l == nil {
stmt = Nod(OEMPTY, nil, nil) stmt = Nod(OEMPTY, nil, nil)
} else { } else {
stmt = liststmt(l) stmt = liststmt(nodeSeqSlice(l))
} }
popdcl() popdcl()
...@@ -1983,7 +1983,7 @@ func (p *parser) hidden_fndcl() *Node { ...@@ -1983,7 +1983,7 @@ func (p *parser) hidden_fndcl() *Node {
s5 := p.ohidden_funres() s5 := p.ohidden_funres()
s := s1 s := s1
t := functype(nil, s3, s5) t := functype(nil, nodeSeqSlice(s3), nodeSeqSlice(s5))
importsym(s, ONAME) importsym(s, ONAME)
if s.Def != nil && s.Def.Op == ONAME { if s.Def != nil && s.Def.Op == ONAME {
...@@ -2013,7 +2013,7 @@ func (p *parser) hidden_fndcl() *Node { ...@@ -2013,7 +2013,7 @@ func (p *parser) hidden_fndcl() *Node {
s8 := p.ohidden_funres() s8 := p.ohidden_funres()
ss := methodname1(newname(s4), s2.N.Right) ss := methodname1(newname(s4), s2.N.Right)
ss.Type = functype(s2.N, s6, s8) ss.Type = functype(s2.N, nodeSeqSlice(s6), nodeSeqSlice(s8))
checkwidth(ss.Type) checkwidth(ss.Type)
addmethod(s4, ss.Type, false, false) addmethod(s4, ss.Type, false, false)
...@@ -2457,7 +2457,7 @@ func (p *parser) stmt() *Node { ...@@ -2457,7 +2457,7 @@ func (p *parser) stmt() *Node {
return p.compound_stmt(false) return p.compound_stmt(false)
case LVAR, LCONST, LTYPE: case LVAR, LCONST, LTYPE:
return liststmt(p.common_dcl()) return liststmt(nodeSeqSlice(p.common_dcl()))
case LNAME, '@', '?', LLITERAL, LFUNC, '(', // operands case LNAME, '@', '?', LLITERAL, LFUNC, '(', // operands
'[', LSTRUCT, LMAP, LCHAN, LINTERFACE, // composite types '[', LSTRUCT, LMAP, LCHAN, LINTERFACE, // composite types
...@@ -2973,7 +2973,7 @@ func (p *parser) hidden_type_misc() *Type { ...@@ -2973,7 +2973,7 @@ func (p *parser) hidden_type_misc() *Type {
s3 := p.ohidden_structdcl_list() s3 := p.ohidden_structdcl_list()
p.want('}') p.want('}')
return tostruct(s3) return tostruct(nodeSeqSlice(s3))
case LINTERFACE: case LINTERFACE:
// LINTERFACE '{' ohidden_interfacedcl_list '}' // LINTERFACE '{' ohidden_interfacedcl_list '}'
...@@ -2982,7 +2982,7 @@ func (p *parser) hidden_type_misc() *Type { ...@@ -2982,7 +2982,7 @@ func (p *parser) hidden_type_misc() *Type {
s3 := p.ohidden_interfacedcl_list() s3 := p.ohidden_interfacedcl_list()
p.want('}') p.want('}')
return tointerface(s3) return tointerface(nodeSeqSlice(s3))
case '*': case '*':
// '*' hidden_type // '*' hidden_type
...@@ -3053,7 +3053,7 @@ func (p *parser) hidden_type_func() *Type { ...@@ -3053,7 +3053,7 @@ func (p *parser) hidden_type_func() *Type {
p.want(')') p.want(')')
s5 := p.ohidden_funres() s5 := p.ohidden_funres()
return functype(nil, s3, s5) return functype(nil, nodeSeqSlice(s3), nodeSeqSlice(s5))
} }
func (p *parser) hidden_funarg() *Node { func (p *parser) hidden_funarg() *Node {
...@@ -3159,7 +3159,7 @@ func (p *parser) hidden_interfacedcl() *Node { ...@@ -3159,7 +3159,7 @@ func (p *parser) hidden_interfacedcl() *Node {
p.want(')') p.want(')')
s5 := p.ohidden_funres() s5 := p.ohidden_funres()
return Nod(ODCLFIELD, newname(s1), typenod(functype(fakethis(), s3, s5))) return Nod(ODCLFIELD, newname(s1), typenod(functype(fakethis(), nodeSeqSlice(s3), nodeSeqSlice(s5))))
} }
func (p *parser) ohidden_funres() *NodeList { func (p *parser) ohidden_funres() *NodeList {
......
...@@ -55,10 +55,10 @@ func instrument(fn *Node) { ...@@ -55,10 +55,10 @@ func instrument(fn *Node) {
} }
if flag_race == 0 || !ispkgin(norace_inst_pkgs) { if flag_race == 0 || !ispkgin(norace_inst_pkgs) {
instrumentlist(fn.Nbody.Slice(), nil) instrumentlist(fn.Nbody, nil)
// nothing interesting for race detector in fn->enter // nothing interesting for race detector in fn->enter
instrumentlist(fn.Func.Exit.Slice(), nil) instrumentlist(fn.Func.Exit, nil)
} }
if flag_race != 0 { if flag_race != 0 {
...@@ -86,7 +86,7 @@ func instrument(fn *Node) { ...@@ -86,7 +86,7 @@ func instrument(fn *Node) {
} }
} }
func instrumentlist(l nodesOrNodeList, init *Nodes) { func instrumentlist(l Nodes, init *Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
var instr Nodes var instr Nodes
instrumentnode(it.P(), &instr, 0, 0) instrumentnode(it.P(), &instr, 0, 0)
...@@ -427,7 +427,7 @@ ret: ...@@ -427,7 +427,7 @@ ret:
if n.Op != OBLOCK { // OBLOCK is handled above in a special way. if n.Op != OBLOCK { // OBLOCK is handled above in a special way.
instrumentlist(n.List, init) instrumentlist(n.List, init)
} }
instrumentlist(n.Nbody.Slice(), nil) instrumentlist(n.Nbody, nil)
instrumentlist(n.Rlist, nil) instrumentlist(n.Rlist, nil)
*np = n *np = n
} }
...@@ -594,7 +594,7 @@ func foreachnode(n *Node, f func(*Node, interface{}), c interface{}) { ...@@ -594,7 +594,7 @@ func foreachnode(n *Node, f func(*Node, interface{}), c interface{}) {
} }
} }
func foreachlist(l nodesOrNodeList, f func(*Node, interface{}), c interface{}) { func foreachlist(l Nodes, f func(*Node, interface{}), c interface{}) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
foreachnode(it.N(), f, c) foreachnode(it.N(), f, c)
} }
...@@ -618,7 +618,7 @@ func hascallspred(n *Node, c interface{}) { ...@@ -618,7 +618,7 @@ func hascallspred(n *Node, c interface{}) {
// appendinit is like addinit in subr.go // appendinit is like addinit in subr.go
// but appends rather than prepends. // but appends rather than prepends.
func appendinit(np **Node, init nodesOrNodeList) { func appendinit(np **Node, init Nodes) {
if nodeSeqLen(init) == 0 { if nodeSeqLen(init) == 0 {
return return
} }
......
...@@ -128,7 +128,7 @@ out: ...@@ -128,7 +128,7 @@ out:
} }
decldepth++ decldepth++
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody.Slice(), Etop)
decldepth-- decldepth--
} }
...@@ -160,7 +160,7 @@ func walkrange(n *Node) { ...@@ -160,7 +160,7 @@ func walkrange(n *Node) {
setNodeSeq(&n.List, nil) setNodeSeq(&n.List, nil)
var body []*Node var body []*Node
var init *NodeList var init []*Node
switch t.Etype { switch t.Etype {
default: default:
Fatalf("walkrange") Fatalf("walkrange")
...@@ -178,13 +178,13 @@ func walkrange(n *Node) { ...@@ -178,13 +178,13 @@ func walkrange(n *Node) {
hn := temp(Types[TINT]) hn := temp(Types[TINT])
var hp *Node var hp *Node
init = list(init, Nod(OAS, hv1, nil)) init = append(init, Nod(OAS, hv1, nil))
init = list(init, Nod(OAS, hn, Nod(OLEN, ha, nil))) init = append(init, Nod(OAS, hn, Nod(OLEN, ha, nil)))
if v2 != nil { if v2 != nil {
hp = temp(Ptrto(n.Type.Type)) hp = temp(Ptrto(n.Type.Type))
tmp := Nod(OINDEX, ha, Nodintconst(0)) tmp := Nod(OINDEX, ha, Nodintconst(0))
tmp.Bounded = true tmp.Bounded = true
init = list(init, Nod(OAS, hp, Nod(OADDR, tmp, nil))) init = append(init, Nod(OAS, hp, Nod(OADDR, tmp, nil)))
} }
n.Left = Nod(OLT, hv1, hn) n.Left = Nod(OLT, hv1, hn)
...@@ -233,7 +233,7 @@ func walkrange(n *Node) { ...@@ -233,7 +233,7 @@ func walkrange(n *Node) {
fn := syslook("mapiterinit") fn := syslook("mapiterinit")
substArgTypes(&fn, t.Down, t.Type, th) substArgTypes(&fn, t.Down, t.Type, th)
init = list(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil))) init = append(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil)))
n.Left = Nod(ONE, Nod(ODOT, hit, keyname), nodnil()) n.Left = Nod(ONE, Nod(ODOT, hit, keyname), nodnil())
fn = syslook("mapiternext") fn = syslook("mapiternext")
...@@ -264,7 +264,7 @@ func walkrange(n *Node) { ...@@ -264,7 +264,7 @@ func walkrange(n *Node) {
hv1 := temp(t.Type) hv1 := temp(t.Type)
hv1.Typecheck = 1 hv1.Typecheck = 1
if haspointers(t.Type) { if haspointers(t.Type) {
init = list(init, Nod(OAS, hv1, nil)) init = append(init, Nod(OAS, hv1, nil))
} }
hb := temp(Types[TBOOL]) hb := temp(Types[TBOOL])
...@@ -287,7 +287,7 @@ func walkrange(n *Node) { ...@@ -287,7 +287,7 @@ func walkrange(n *Node) {
ohv1 := temp(Types[TINT]) ohv1 := temp(Types[TINT])
hv1 := temp(Types[TINT]) hv1 := temp(Types[TINT])
init = list(init, Nod(OAS, hv1, nil)) init = append(init, Nod(OAS, hv1, nil))
var a *Node var a *Node
var hv2 *Node var hv2 *Node
...@@ -316,7 +316,7 @@ func walkrange(n *Node) { ...@@ -316,7 +316,7 @@ func walkrange(n *Node) {
n.Op = OFOR n.Op = OFOR
typechecklist(init, Etop) typechecklist(init, Etop)
appendNodeSeq(&n.Ninit, init) appendNodeSeq(&n.Ninit, init)
typechecklist(n.Left.Ninit, Etop) typechecklist(n.Left.Ninit.Slice(), Etop)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
typecheck(&n.Right, Etop) typecheck(&n.Right, Etop)
typecheckslice(body, Etop) typecheckslice(body, Etop)
...@@ -400,7 +400,7 @@ func memclrrange(n, v1, v2, a *Node) bool { ...@@ -400,7 +400,7 @@ func memclrrange(n, v1, v2, a *Node) bool {
n.Nbody.Append(v1) n.Nbody.Append(v1)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody.Slice(), Etop)
walkstmt(&n) walkstmt(&n)
return true return true
} }
...@@ -237,11 +237,11 @@ func hiter(t *Type) *Type { ...@@ -237,11 +237,11 @@ func hiter(t *Type) *Type {
// f is method type, with receiver. // f is method type, with receiver.
// return function type, receiver as first argument (or not). // return function type, receiver as first argument (or not).
func methodfunc(f *Type, receiver *Type) *Type { func methodfunc(f *Type, receiver *Type) *Type {
var in *NodeList var in []*Node
if receiver != nil { if receiver != nil {
d := Nod(ODCLFIELD, nil, nil) d := Nod(ODCLFIELD, nil, nil)
d.Type = receiver d.Type = receiver
in = list(in, d) in = append(in, d)
} }
var d *Node var d *Node
...@@ -249,14 +249,14 @@ func methodfunc(f *Type, receiver *Type) *Type { ...@@ -249,14 +249,14 @@ func methodfunc(f *Type, receiver *Type) *Type {
d = Nod(ODCLFIELD, nil, nil) d = Nod(ODCLFIELD, nil, nil)
d.Type = t.Type d.Type = t.Type
d.Isddd = t.Isddd d.Isddd = t.Isddd
in = list(in, d) in = append(in, d)
} }
var out *NodeList var out []*Node
for t := getoutargx(f).Type; t != nil; t = t.Down { for t := getoutargx(f).Type; t != nil; t = t.Down {
d = Nod(ODCLFIELD, nil, nil) d = Nod(ODCLFIELD, nil, nil)
d.Type = t.Type d.Type = t.Type
out = list(out, d) out = append(out, d)
} }
t := functype(nil, in, out) t := functype(nil, in, out)
...@@ -1249,7 +1249,7 @@ func dumptypestructs() { ...@@ -1249,7 +1249,7 @@ func dumptypestructs() {
// The latter is the type of an auto-generated wrapper. // The latter is the type of an auto-generated wrapper.
dtypesym(Ptrto(errortype)) dtypesym(Ptrto(errortype))
dtypesym(functype(nil, list1(Nod(ODCLFIELD, nil, typenod(errortype))), list1(Nod(ODCLFIELD, nil, typenod(Types[TSTRING]))))) dtypesym(functype(nil, []*Node{Nod(ODCLFIELD, nil, typenod(errortype))}, []*Node{Nod(ODCLFIELD, nil, typenod(Types[TSTRING]))}))
// add paths for runtime and main, which 6l imports implicitly. // add paths for runtime and main, which 6l imports implicitly.
dimportpath(Runtimepkg) dimportpath(Runtimepkg)
......
...@@ -12,7 +12,7 @@ func typecheckselect(sel *Node) { ...@@ -12,7 +12,7 @@ func typecheckselect(sel *Node) {
var def *Node var def *Node
lno := setlineno(sel) lno := setlineno(sel)
count := 0 count := 0
typechecklist(sel.Ninit, Etop) typechecklist(sel.Ninit.Slice(), Etop)
for it := nodeSeqIterate(sel.List); !it.Done(); it.Next() { for it := nodeSeqIterate(sel.List); !it.Done(); it.Next() {
count++ count++
ncase = it.N() ncase = it.N()
...@@ -80,7 +80,7 @@ func typecheckselect(sel *Node) { ...@@ -80,7 +80,7 @@ func typecheckselect(sel *Node) {
} }
} }
typechecklist(ncase.Nbody, Etop) typechecklist(ncase.Nbody.Slice(), Etop)
} }
sel.Xoffset = int64(count) sel.Xoffset = int64(count)
...@@ -212,7 +212,7 @@ func walkselect(sel *Node) { ...@@ -212,7 +212,7 @@ func walkselect(sel *Node) {
dflt = nodeSeqFirst(sel.List) dflt = nodeSeqFirst(sel.List)
} else { } else {
dflt = nodeSeqSecond(sel.List) dflt = nodeSeqSecond(sel.List)
cas = nodeSeqFirst(sel.List) cas = nodeSeqFirst(sel.List.Slice())
} }
n := cas.Left n := cas.Left
......
...@@ -212,13 +212,13 @@ func init2(n *Node, out *[]*Node) { ...@@ -212,13 +212,13 @@ func init2(n *Node, out *[]*Node) {
} }
} }
func init2list(l nodesOrNodeList, out *[]*Node) { func init2list(l Nodes, out *[]*Node) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
init2(it.N(), out) init2(it.N(), out)
} }
} }
func initreorder(l nodesOrNodeList, out *[]*Node) { func initreorder(l []*Node, out *[]*Node) {
var n *Node var n *Node
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
...@@ -228,7 +228,7 @@ func initreorder(l nodesOrNodeList, out *[]*Node) { ...@@ -228,7 +228,7 @@ func initreorder(l nodesOrNodeList, out *[]*Node) {
continue continue
} }
initreorder(n.Ninit, out) initreorder(n.Ninit.Slice(), out)
setNodeSeq(&n.Ninit, nil) setNodeSeq(&n.Ninit, nil)
init1(n, out) init1(n, out)
} }
...@@ -237,7 +237,7 @@ func initreorder(l nodesOrNodeList, out *[]*Node) { ...@@ -237,7 +237,7 @@ func initreorder(l nodesOrNodeList, out *[]*Node) {
// initfix computes initialization order for a list l of top-level // initfix computes initialization order for a list l of top-level
// declarations and outputs the corresponding list of statements // declarations and outputs the corresponding list of statements
// to include in the init() function body. // to include in the init() function body.
func initfix(l nodesOrNodeList) []*Node { func initfix(l []*Node) []*Node {
var lout []*Node var lout []*Node
initplans = make(map[*Node]*InitPlan) initplans = make(map[*Node]*InitPlan)
lno := lineno lno := lineno
......
...@@ -508,7 +508,7 @@ func (s *state) stmts(a Nodes) { ...@@ -508,7 +508,7 @@ func (s *state) stmts(a Nodes) {
} }
// ssaStmtList converts the statement n to SSA and adds it to s. // ssaStmtList converts the statement n to SSA and adds it to s.
func (s *state) stmtList(l nodesOrNodeList) { func (s *state) stmtList(l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
s.stmt(it.N()) s.stmt(it.N())
} }
......
...@@ -536,7 +536,7 @@ func treecopy(n *Node, lineno int32) *Node { ...@@ -536,7 +536,7 @@ func treecopy(n *Node, lineno int32) *Node {
m.Orig = m m.Orig = m
m.Left = treecopy(n.Left, lineno) m.Left = treecopy(n.Left, lineno)
m.Right = treecopy(n.Right, lineno) m.Right = treecopy(n.Right, lineno)
setNodeSeq(&m.List, listtreecopy(n.List, lineno)) setNodeSeq(&m.List, listtreecopy(n.List.Slice(), lineno))
if lineno != 0 { if lineno != 0 {
m.Lineno = lineno m.Lineno = lineno
} }
...@@ -2191,7 +2191,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2191,7 +2191,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
fn.Func.Dupok = true fn.Func.Dupok = true
} }
typecheck(&fn, Etop) typecheck(&fn, Etop)
typechecklist(fn.Nbody, Etop) typechecklist(fn.Nbody.Slice(), Etop)
inlcalls(fn) inlcalls(fn)
escAnalyze([]*Node{fn}, false) escAnalyze([]*Node{fn}, false)
...@@ -2353,7 +2353,7 @@ func Simsimtype(t *Type) EType { ...@@ -2353,7 +2353,7 @@ func Simsimtype(t *Type) EType {
return et return et
} }
func listtreecopy(l nodesOrNodeList, lineno int32) []*Node { func listtreecopy(l []*Node, lineno int32) []*Node {
var out []*Node var out []*Node
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
out = append(out, treecopy(it.N(), lineno)) out = append(out, treecopy(it.N(), lineno))
...@@ -2361,7 +2361,7 @@ func listtreecopy(l nodesOrNodeList, lineno int32) []*Node { ...@@ -2361,7 +2361,7 @@ func listtreecopy(l nodesOrNodeList, lineno int32) []*Node {
return out return out
} }
func liststmt(l nodesOrNodeList) *Node { func liststmt(l []*Node) *Node {
n := Nod(OBLOCK, nil, nil) n := Nod(OBLOCK, nil, nil)
setNodeSeq(&n.List, l) setNodeSeq(&n.List, l)
if nodeSeqLen(l) != 0 { if nodeSeqLen(l) != 0 {
...@@ -2695,7 +2695,7 @@ func mkpkg(path string) *Pkg { ...@@ -2695,7 +2695,7 @@ func mkpkg(path string) *Pkg {
return p return p
} }
func addinit(np **Node, init nodesOrNodeList) { func addinit(np **Node, init []*Node) {
if nodeSeqLen(init) == 0 { if nodeSeqLen(init) == 0 {
return return
} }
......
...@@ -59,7 +59,7 @@ type caseClause struct { ...@@ -59,7 +59,7 @@ type caseClause struct {
// typecheckswitch typechecks a switch statement. // typecheckswitch typechecks a switch statement.
func typecheckswitch(n *Node) { func typecheckswitch(n *Node) {
lno := lineno lno := lineno
typechecklist(n.Ninit, Etop) typechecklist(n.Ninit.Slice(), Etop)
var nilonly string var nilonly string
var top int var top int
...@@ -181,7 +181,7 @@ func typecheckswitch(n *Node) { ...@@ -181,7 +181,7 @@ func typecheckswitch(n *Node) {
} }
} }
typechecklist(ncase.Nbody, Etop) typechecklist(ncase.Nbody.Slice(), Etop)
} }
lineno = lno lineno = lno
...@@ -287,7 +287,7 @@ func (s *exprSwitch) walk(sw *Node) { ...@@ -287,7 +287,7 @@ func (s *exprSwitch) walk(sw *Node) {
func (s *exprSwitch) walkCases(cc []*caseClause) *Node { func (s *exprSwitch) walkCases(cc []*caseClause) *Node {
if len(cc) < binarySearchMin { if len(cc) < binarySearchMin {
// linear search // linear search
var cas *NodeList var cas []*Node
for _, c := range cc { for _, c := range cc {
n := c.node n := c.node
lno := setlineno(n) lno := setlineno(n)
...@@ -305,7 +305,7 @@ func (s *exprSwitch) walkCases(cc []*caseClause) *Node { ...@@ -305,7 +305,7 @@ func (s *exprSwitch) walkCases(cc []*caseClause) *Node {
} }
a.Nbody.Set([]*Node{n.Right}) // goto l a.Nbody.Set([]*Node{n.Right}) // goto l
cas = list(cas, a) cas = append(cas, a)
lineno = lno lineno = lno
} }
return liststmt(cas) return liststmt(cas)
...@@ -653,9 +653,9 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -653,9 +653,9 @@ func (s *typeSwitch) walk(sw *Node) {
ncase := 0 ncase := 0
for i := 0; i < run; i++ { for i := 0; i < run; i++ {
ncase++ ncase++
hash := list1(cc[i].node.Right) hash := []*Node{cc[i].node.Right}
for j := i + 1; j < run && cc[i].hash == cc[j].hash; j++ { for j := i + 1; j < run && cc[i].hash == cc[j].hash; j++ {
hash = list(hash, cc[j].node.Right) hash = append(hash, cc[j].node.Right)
} }
cc[i].node.Right = liststmt(hash) cc[i].node.Right = liststmt(hash)
} }
...@@ -678,16 +678,16 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -678,16 +678,16 @@ func (s *typeSwitch) walk(sw *Node) {
// case body if the variable is of type t. // case body if the variable is of type t.
func (s *typeSwitch) typeone(t *Node) *Node { func (s *typeSwitch) typeone(t *Node) *Node {
var name *Node var name *Node
var init *NodeList var init []*Node
if nodeSeqLen(t.Rlist) == 0 { if nodeSeqLen(t.Rlist) == 0 {
name = nblank name = nblank
typecheck(&nblank, Erv|Easgn) typecheck(&nblank, Erv|Easgn)
} else { } else {
name = nodeSeqFirst(t.Rlist) name = nodeSeqFirst(t.Rlist)
init = list1(Nod(ODCL, name, nil)) init = []*Node{Nod(ODCL, name, nil)}
a := Nod(OAS, name, nil) a := Nod(OAS, name, nil)
typecheck(&a, Etop) typecheck(&a, Etop)
init = list(init, a) init = append(init, a)
} }
a := Nod(OAS2, nil, nil) a := Nod(OAS2, nil, nil)
...@@ -696,19 +696,19 @@ func (s *typeSwitch) typeone(t *Node) *Node { ...@@ -696,19 +696,19 @@ func (s *typeSwitch) typeone(t *Node) *Node {
b.Type = t.Left.Type // interface.(type) b.Type = t.Left.Type // interface.(type)
setNodeSeq(&a.Rlist, []*Node{b}) setNodeSeq(&a.Rlist, []*Node{b})
typecheck(&a, Etop) typecheck(&a, Etop)
init = list(init, a) init = append(init, a)
c := Nod(OIF, nil, nil) c := Nod(OIF, nil, nil)
c.Left = s.okname c.Left = s.okname
c.Nbody.Set([]*Node{t.Right}) // if ok { goto l } c.Nbody.Set([]*Node{t.Right}) // if ok { goto l }
return liststmt(list(init, c)) return liststmt(append(init, c))
} }
// walkCases generates an AST implementing the cases in cc. // walkCases generates an AST implementing the cases in cc.
func (s *typeSwitch) walkCases(cc []*caseClause) *Node { func (s *typeSwitch) walkCases(cc []*caseClause) *Node {
if len(cc) < binarySearchMin { if len(cc) < binarySearchMin {
var cas *NodeList var cas []*Node
for _, c := range cc { for _, c := range cc {
n := c.node n := c.node
if c.typ != caseKindTypeConst { if c.typ != caseKindTypeConst {
...@@ -718,7 +718,7 @@ func (s *typeSwitch) walkCases(cc []*caseClause) *Node { ...@@ -718,7 +718,7 @@ func (s *typeSwitch) walkCases(cc []*caseClause) *Node {
a.Left = Nod(OEQ, s.hashname, Nodintconst(int64(c.hash))) a.Left = Nod(OEQ, s.hashname, Nodintconst(int64(c.hash)))
typecheck(&a.Left, Erv) typecheck(&a.Left, Erv)
a.Nbody.Set([]*Node{n.Right}) a.Nbody.Set([]*Node{n.Right})
cas = list(cas, a) cas = append(cas, a)
} }
return liststmt(cas) return liststmt(cas)
} }
......
...@@ -34,7 +34,7 @@ func resolve(n *Node) *Node { ...@@ -34,7 +34,7 @@ func resolve(n *Node) *Node {
return n return n
} }
func typechecklist(l nodesOrNodeList, top int) { func typechecklist(l []*Node, top int) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
typecheck(it.P(), top) typecheck(it.P(), top)
} }
...@@ -220,7 +220,7 @@ func callrecv(n *Node) bool { ...@@ -220,7 +220,7 @@ func callrecv(n *Node) bool {
return callrecv(n.Left) || callrecv(n.Right) || callrecvlist(n.Ninit) || callrecvlist(n.Nbody) || callrecvlist(n.List) || callrecvlist(n.Rlist) return callrecv(n.Left) || callrecv(n.Right) || callrecvlist(n.Ninit) || callrecvlist(n.Nbody) || callrecvlist(n.List) || callrecvlist(n.Rlist)
} }
func callrecvlist(l nodesOrNodeList) bool { func callrecvlist(l Nodes) bool {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
if callrecv(it.N()) { if callrecv(it.N()) {
return true return true
...@@ -426,7 +426,7 @@ OpSwitch: ...@@ -426,7 +426,7 @@ OpSwitch:
case OTSTRUCT: case OTSTRUCT:
ok |= Etype ok |= Etype
n.Op = OTYPE n.Op = OTYPE
n.Type = tostruct(n.List) n.Type = tostruct(n.List.Slice())
if n.Type == nil || n.Type.Broke { if n.Type == nil || n.Type.Broke {
n.Type = nil n.Type = nil
return return
...@@ -436,7 +436,7 @@ OpSwitch: ...@@ -436,7 +436,7 @@ OpSwitch:
case OTINTER: case OTINTER:
ok |= Etype ok |= Etype
n.Op = OTYPE n.Op = OTYPE
n.Type = tointerface(n.List) n.Type = tointerface(n.List.Slice())
if n.Type == nil { if n.Type == nil {
n.Type = nil n.Type = nil
return return
...@@ -445,7 +445,7 @@ OpSwitch: ...@@ -445,7 +445,7 @@ OpSwitch:
case OTFUNC: case OTFUNC:
ok |= Etype ok |= Etype
n.Op = OTYPE n.Op = OTYPE
n.Type = functype(n.Left, n.List, n.Rlist) n.Type = functype(n.Left, n.List.Slice(), n.Rlist.Slice())
if n.Type == nil { if n.Type == nil {
n.Type = nil n.Type = nil
return return
...@@ -1292,7 +1292,7 @@ OpSwitch: ...@@ -1292,7 +1292,7 @@ OpSwitch:
it := nodeSeqIterate(n.List) it := nodeSeqIterate(n.List)
typecheck(it.P(), Erv|Efnstruct) typecheck(it.P(), Erv|Efnstruct)
} else { } else {
typechecklist(n.List, Erv) typechecklist(n.List.Slice(), Erv)
} }
t := l.Type t := l.Type
if t == nil { if t == nil {
...@@ -1447,7 +1447,7 @@ OpSwitch: ...@@ -1447,7 +1447,7 @@ OpSwitch:
var r *Node var r *Node
var l *Node var l *Node
if nodeSeqLen(n.List) == 1 { if nodeSeqLen(n.List) == 1 {
typechecklist(n.List, Efnstruct) typechecklist(n.List.Slice(), Efnstruct)
if nodeSeqFirst(n.List).Op != OCALLFUNC && nodeSeqFirst(n.List).Op != OCALLMETH { if nodeSeqFirst(n.List).Op != OCALLFUNC && nodeSeqFirst(n.List).Op != OCALLMETH {
Yyerror("invalid operation: complex expects two arguments") Yyerror("invalid operation: complex expects two arguments")
n.Type = nil n.Type = nil
...@@ -1567,7 +1567,7 @@ OpSwitch: ...@@ -1567,7 +1567,7 @@ OpSwitch:
} }
ok |= Etop ok |= Etop
typechecklist(args, Erv) typechecklist(args.Slice(), Erv)
l := nodeSeqFirst(args) l := nodeSeqFirst(args)
r := nodeSeqSecond(args) r := nodeSeqSecond(args)
if l.Type != nil && l.Type.Etype != TMAP { if l.Type != nil && l.Type.Etype != TMAP {
...@@ -1594,7 +1594,7 @@ OpSwitch: ...@@ -1594,7 +1594,7 @@ OpSwitch:
it := nodeSeqIterate(args) it := nodeSeqIterate(args)
typecheck(it.P(), Erv|Efnstruct) typecheck(it.P(), Erv|Efnstruct)
} else { } else {
typechecklist(args, Erv) typechecklist(args.Slice(), Erv)
} }
t := nodeSeqFirst(args).Type t := nodeSeqFirst(args).Type
...@@ -1921,7 +1921,7 @@ OpSwitch: ...@@ -1921,7 +1921,7 @@ OpSwitch:
case OPRINT, OPRINTN: case OPRINT, OPRINTN:
ok |= Etop ok |= Etop
typechecklist(n.List, Erv|Eindir) // Eindir: address does not escape typechecklist(n.List.Slice(), Erv|Eindir) // Eindir: address does not escape
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() { for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
// Special case for print: int constant is int64, not int. // Special case for print: int constant is int64, not int.
if Isconst(it.N(), CTINT) { if Isconst(it.N(), CTINT) {
...@@ -2063,7 +2063,7 @@ OpSwitch: ...@@ -2063,7 +2063,7 @@ OpSwitch:
case OFOR: case OFOR:
ok |= Etop ok |= Etop
typechecklist(n.Ninit, Etop) typechecklist(n.Ninit.Slice(), Etop)
decldepth++ decldepth++
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
if n.Left != nil { if n.Left != nil {
...@@ -2073,13 +2073,13 @@ OpSwitch: ...@@ -2073,13 +2073,13 @@ OpSwitch:
} }
} }
typecheck(&n.Right, Etop) typecheck(&n.Right, Etop)
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody.Slice(), Etop)
decldepth-- decldepth--
break OpSwitch break OpSwitch
case OIF: case OIF:
ok |= Etop ok |= Etop
typechecklist(n.Ninit, Etop) typechecklist(n.Ninit.Slice(), Etop)
typecheck(&n.Left, Erv) typecheck(&n.Left, Erv)
if n.Left != nil { if n.Left != nil {
t := n.Left.Type t := n.Left.Type
...@@ -2087,16 +2087,16 @@ OpSwitch: ...@@ -2087,16 +2087,16 @@ OpSwitch:
Yyerror("non-bool %v used as if condition", Nconv(n.Left, obj.FmtLong)) Yyerror("non-bool %v used as if condition", Nconv(n.Left, obj.FmtLong))
} }
} }
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody.Slice(), Etop)
typechecklist(n.Rlist, Etop) typechecklist(n.Rlist.Slice(), Etop)
break OpSwitch break OpSwitch
case ORETURN: case ORETURN:
ok |= Etop ok |= Etop
if nodeSeqLen(n.List) == 1 { if nodeSeqLen(n.List) == 1 {
typechecklist(n.List, Erv|Efnstruct) typechecklist(n.List.Slice(), Erv|Efnstruct)
} else { } else {
typechecklist(n.List, Erv) typechecklist(n.List.Slice(), Erv)
} }
if Curfn == nil { if Curfn == nil {
Yyerror("return outside function") Yyerror("return outside function")
...@@ -2136,8 +2136,8 @@ OpSwitch: ...@@ -2136,8 +2136,8 @@ OpSwitch:
case OXCASE: case OXCASE:
ok |= Etop ok |= Etop
typechecklist(n.List, Erv) typechecklist(n.List.Slice(), Erv)
typechecklist(n.Nbody, Etop) typechecklist(n.Nbody.Slice(), Etop)
break OpSwitch break OpSwitch
case ODCLFUNC: case ODCLFUNC:
...@@ -2575,7 +2575,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Type { ...@@ -2575,7 +2575,7 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Type {
return nil return nil
} }
func nokeys(l nodesOrNodeList) bool { func nokeys(l Nodes) bool {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
if it.N().Op == OKEY { if it.N().Op == OKEY {
return false return false
...@@ -2606,7 +2606,7 @@ func downcount(t *Type) int { ...@@ -2606,7 +2606,7 @@ func downcount(t *Type) int {
} }
// typecheck assignment: type list = expression list // typecheck assignment: type list = expression list
func typecheckaste(op Op, call *Node, isddd bool, tstruct *Type, nl nodesOrNodeList, desc func() string) { func typecheckaste(op Op, call *Node, isddd bool, tstruct *Type, nl Nodes, desc func() string) {
var t *Type var t *Type
var n *Node var n *Node
var n1 int var n1 int
...@@ -3235,7 +3235,7 @@ func checkassign(stmt *Node, n *Node) { ...@@ -3235,7 +3235,7 @@ func checkassign(stmt *Node, n *Node) {
Yyerror("cannot assign to %v", n) Yyerror("cannot assign to %v", n)
} }
func checkassignlist(stmt *Node, l nodesOrNodeList) { func checkassignlist(stmt *Node, l Nodes) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
checkassign(stmt, it.N()) checkassign(stmt, it.N())
} }
...@@ -3330,7 +3330,7 @@ func typecheckas2(n *Node) { ...@@ -3330,7 +3330,7 @@ func typecheckas2(n *Node) {
it := nodeSeqIterate(n.Rlist) it := nodeSeqIterate(n.Rlist)
typecheck(it.P(), Erv|Efnstruct) typecheck(it.P(), Erv|Efnstruct)
} else { } else {
typechecklist(n.Rlist, Erv) typechecklist(n.Rlist.Slice(), Erv)
} }
checkassignlist(n, n.List) checkassignlist(n, n.List)
...@@ -3890,7 +3890,7 @@ func markbreak(n *Node, implicit *Node) { ...@@ -3890,7 +3890,7 @@ func markbreak(n *Node, implicit *Node) {
} }
} }
func markbreaklist(l nodesOrNodeList, implicit *Node) { func markbreaklist(l Nodes, implicit *Node) {
for it := nodeSeqIterate(l); !it.Done(); it.Next() { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
n := it.N() n := it.N()
if n.Op == OLABEL && it.Len() > 1 && n.Name.Defn == nodeSeqSlice(it.Seq())[1] { if n.Op == OLABEL && it.Len() > 1 && n.Name.Defn == nodeSeqSlice(it.Seq())[1] {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment