Commit 99b6b77e authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/compile: convert inl.go to use nodeSeq

Passes toolstash -cmp.

Update #14473.

Change-Id: I60ef7cac553b346ca6b8cc7152cd184e59994b66
Reviewed-on: https://go-review.googlesource.com/20216
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent c0740fed
This diff is collapsed.
......@@ -292,7 +292,7 @@ func orderexprinplace(np **Node, outer *Order) {
n := *np
var order Order
orderexpr(&n, &order, nil)
addinitslice(&n, order.out)
addinit(&n, order.out)
// insert new temporaries from order
// at head of outer list.
......
......@@ -2708,8 +2708,8 @@ func mkpkg(path string) *Pkg {
return p
}
func addinit(np **Node, init *NodeList) {
if init == nil {
func addinit(np **Node, init nodesOrNodeList) {
if nodeSeqLen(init) == 0 {
return
}
......@@ -2725,18 +2725,10 @@ func addinit(np **Node, init *NodeList) {
*np = n
}
n.Ninit = concat(init, n.Ninit)
setNodeSeq(&n.Ninit, append(nodeSeqSlice(init), nodeSeqSlice(n.Ninit)...))
n.Ullman = UINF
}
func addinitslice(np **Node, init []*Node) {
var l *NodeList
for _, n := range init {
l = list(l, n)
}
addinit(np, l)
}
var reservedimports = []string{
"go",
"type",
......
......@@ -603,13 +603,15 @@ func nodeSeqIterate(ns nodesOrNodeList) nodeSeqIterator {
}
}
// nodeSeqLen returns the length of either a *NodeList or a Nodes.
// nodeSeqLen returns the length of a *NodeList, a Nodes, or a []*Node.
func nodeSeqLen(ns nodesOrNodeList) int {
switch ns := ns.(type) {
case *NodeList:
return count(ns)
case Nodes:
return len(ns.Slice())
case []*Node:
return len(ns)
default:
panic("can't happen")
}
......@@ -641,6 +643,27 @@ func nodeSeqSecond(ns nodesOrNodeList) *Node {
}
}
// nodeSeqSlice returns a []*Node containing the contents of a
// *NodeList, a Nodes, or a []*Node.
// This is an interim function during the transition from NodeList to Nodes.
// TODO(iant): Remove when transition is complete.
func nodeSeqSlice(ns nodesOrNodeList) []*Node {
switch ns := ns.(type) {
case *NodeList:
var s []*Node
for l := ns; l != nil; l = l.Next {
s = append(s, l.N)
}
return s
case Nodes:
return ns.Slice()
case []*Node:
return ns
default:
panic("can't happen")
}
}
// setNodeSeq implements *a = b.
// a must have type **NodeList, *Nodes, or *[]*Node.
// b must have type *NodeList, Nodes, []*Node, or nil.
......
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