Commit 65c4b55a authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/compile: convert subr, swt, typecheck to nodeSeq

Passes toolstash -cmp.

Update #14473.

Change-Id: I836197810405cde72cbb49fef7e163a517601f9c
Reviewed-on: https://go-review.googlesource.com/20242Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent 3da1a26f
...@@ -297,19 +297,19 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList { ...@@ -297,19 +297,19 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList {
lastconst = cl lastconst = cl
lasttype = t lasttype = t
} }
cl = listtreecopy(cl, lno) clcopy := listtreecopy(cl, lno)
var v *Node var v *Node
var c *Node var c *Node
var vv *NodeList var vv *NodeList
for ; vl != nil; vl = vl.Next { for ; vl != nil; vl = vl.Next {
if cl == nil { if len(clcopy) == 0 {
Yyerror("missing value in const declaration") Yyerror("missing value in const declaration")
break break
} }
c = cl.N c = clcopy[0]
cl = cl.Next clcopy = clcopy[1:]
v = vl.N v = vl.N
v.Op = OLITERAL v.Op = OLITERAL
...@@ -321,7 +321,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList { ...@@ -321,7 +321,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList {
vv = list(vv, Nod(ODCLCONST, v, nil)) vv = list(vv, Nod(ODCLCONST, v, nil))
} }
if cl != nil { if len(clcopy) != 0 {
Yyerror("extra expression in const declaration") Yyerror("extra expression in const declaration")
} }
iota_ += 1 iota_ += 1
......
...@@ -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)
m.List = listtreecopy(n.List, lineno) setNodeSeq(&m.List, listtreecopy(n.List, lineno))
if lineno != 0 { if lineno != 0 {
m.Lineno = lineno m.Lineno = lineno
} }
...@@ -1393,7 +1393,7 @@ func ullmancalc(n *Node) { ...@@ -1393,7 +1393,7 @@ func ullmancalc(n *Node) {
var ul int var ul int
var ur int var ur int
if n.Ninit != nil { if nodeSeqLen(n.Ninit) != 0 {
ul = UINF ul = UINF
goto out goto out
} }
...@@ -2014,13 +2014,13 @@ func expandmeth(t *Type) { ...@@ -2014,13 +2014,13 @@ func expandmeth(t *Type) {
} }
// Given funarg struct list, return list of ODCLFIELD Node fn args. // Given funarg struct list, return list of ODCLFIELD Node fn args.
func structargs(tl **Type, mustname int) *NodeList { func structargs(tl **Type, mustname int) []*Node {
var savet Iter var savet Iter
var a *Node var a *Node
var n *Node var n *Node
var buf string var buf string
var args *NodeList var args []*Node
gen := 0 gen := 0
for t := Structfirst(&savet, tl); t != nil; t = structnext(&savet) { for t := Structfirst(&savet, tl); t != nil; t = structnext(&savet) {
n = nil n = nil
...@@ -2038,7 +2038,7 @@ func structargs(tl **Type, mustname int) *NodeList { ...@@ -2038,7 +2038,7 @@ func structargs(tl **Type, mustname int) *NodeList {
if n != nil { if n != nil {
n.Isddd = t.Isddd n.Isddd = t.Isddd
} }
args = list(args, a) args = append(args, a)
} }
return args return args
...@@ -2091,7 +2091,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2091,7 +2091,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
out := structargs(Getoutarg(method.Type), 0) out := structargs(Getoutarg(method.Type), 0)
t := Nod(OTFUNC, nil, nil) t := Nod(OTFUNC, nil, nil)
l := list1(this) l := []*Node{this}
if iface != 0 && rcvr.Width < Types[Tptr].Width { if iface != 0 && rcvr.Width < Types[Tptr].Width {
// Building method for interface table and receiver // Building method for interface table and receiver
// is smaller than the single pointer-sized word // is smaller than the single pointer-sized word
...@@ -2103,11 +2103,11 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2103,11 +2103,11 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
tpad.Type = Types[TUINT8] tpad.Type = Types[TUINT8]
tpad.Bound = Types[Tptr].Width - rcvr.Width tpad.Bound = Types[Tptr].Width - rcvr.Width
pad := Nod(ODCLFIELD, newname(Lookup(".pad")), typenod(tpad)) pad := Nod(ODCLFIELD, newname(Lookup(".pad")), typenod(tpad))
l = list(l, pad) l = append(l, pad)
} }
t.List = concat(l, in) setNodeSeq(&t.List, append(l, in...))
t.Rlist = out setNodeSeq(&t.Rlist, out)
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
fn.Func.Nname = newname(newnam) fn.Func.Nname = newname(newnam)
...@@ -2117,12 +2117,12 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2117,12 +2117,12 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
funchdr(fn) funchdr(fn)
// arg list // arg list
var args *NodeList var args []*Node
isddd := false isddd := false
for l := in; l != nil; l = l.Next { for _, n := range in {
args = list(args, l.N.Left) args = append(args, n.Left)
isddd = l.N.Left.Isddd isddd = n.Left.Isddd
} }
methodrcvr := getthisx(method.Type).Type.Type methodrcvr := getthisx(method.Type).Type.Type
...@@ -2136,17 +2136,17 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2136,17 +2136,17 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
// these strings are already in the reflect tables, // these strings are already in the reflect tables,
// so no space cost to use them here. // so no space cost to use them here.
var l *NodeList var l []*Node
var v Val var v Val
v.U = rcvr.Type.Sym.Pkg.Name // package name v.U = rcvr.Type.Sym.Pkg.Name // package name
l = list(l, nodlit(v)) l = append(l, nodlit(v))
v.U = rcvr.Type.Sym.Name // type name v.U = rcvr.Type.Sym.Name // type name
l = list(l, nodlit(v)) l = append(l, nodlit(v))
v.U = method.Sym.Name v.U = method.Sym.Name
l = list(l, nodlit(v)) // method name l = append(l, nodlit(v)) // method name
call := Nod(OCALL, syslook("panicwrap"), nil) call := Nod(OCALL, syslook("panicwrap"), nil)
call.List = l setNodeSeq(&call.List, l)
n.Nbody.Set([]*Node{call}) n.Nbody.Set([]*Node{call})
fn.Nbody.Append(n) fn.Nbody.Append(n)
} }
...@@ -2169,11 +2169,11 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2169,11 +2169,11 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
} else { } else {
fn.Func.Wrapper = true // ignore frame for panic+recover matching fn.Func.Wrapper = true // ignore frame for panic+recover matching
call := Nod(OCALL, dot, nil) call := Nod(OCALL, dot, nil)
call.List = args setNodeSeq(&call.List, args)
call.Isddd = isddd call.Isddd = isddd
if method.Type.Outtuple > 0 { if method.Type.Outtuple > 0 {
n := Nod(ORETURN, nil, nil) n := Nod(ORETURN, nil, nil)
n.List = list1(call) setNodeSeq(&n.List, []*Node{call})
call = n call = n
} }
...@@ -2207,10 +2207,10 @@ func hashmem(t *Type) *Node { ...@@ -2207,10 +2207,10 @@ func hashmem(t *Type) *Node {
n := newname(sym) n := newname(sym)
n.Class = PFUNC n.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
tfn.List = list(tfn.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t)))) appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Ptrto(t))))
tfn.List = list(tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn.List = list(tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) appendNodeSeqNode(&tfn.List, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
tfn.Rlist = list(tfn.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR]))) appendNodeSeqNode(&tfn.Rlist, Nod(ODCLFIELD, nil, typenod(Types[TUINTPTR])))
typecheck(&tfn, Etype) typecheck(&tfn, Etype)
n.Type = tfn.Type n.Type = tfn.Type
return n return n
...@@ -2354,10 +2354,10 @@ func Simsimtype(t *Type) EType { ...@@ -2354,10 +2354,10 @@ func Simsimtype(t *Type) EType {
return et return et
} }
func listtreecopy(l *NodeList, lineno int32) *NodeList { func listtreecopy(l nodesOrNodeList, lineno int32) []*Node {
var out *NodeList var out []*Node
for ; l != nil; l = l.Next { for it := nodeSeqIterate(l); !it.Done(); it.Next() {
out = list(out, treecopy(l.N, lineno)) out = append(out, treecopy(it.N(), lineno))
} }
return out return out
} }
......
This diff is collapsed.
...@@ -391,12 +391,12 @@ func list1(n *Node) *NodeList { ...@@ -391,12 +391,12 @@ func list1(n *Node) *NodeList {
if n == nil { if n == nil {
return nil return nil
} }
if n.Op == OBLOCK && n.Ninit == nil { if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
// Flatten list and steal storage. // Flatten list and steal storage.
// Poison pointer to catch errant uses. // Poison pointer to catch errant uses.
l := n.List l := n.List
n.List = nil setNodeSeq(&n.List, nil)
return l return l
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment