Commit 80e5b525 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/compile: change order.go to use nodeSeq

Passes toolstash -cmp

Update #14473.

Change-Id: I15b35d40a5ec1f4355ee38bc6d131920933ac95c
Reviewed-on: https://go-review.googlesource.com/20237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 16e2e95d
This diff is collapsed.
......@@ -2366,23 +2366,15 @@ func listtreecopy(l *NodeList, lineno int32) *NodeList {
return out
}
func liststmt(l *NodeList) *Node {
func liststmt(l nodesOrNodeList) *Node {
n := Nod(OBLOCK, nil, nil)
n.List = l
if l != nil {
n.Lineno = l.N.Lineno
setNodeSeq(&n.List, l)
if nodeSeqLen(l) != 0 {
n.Lineno = nodeSeqFirst(l).Lineno
}
return n
}
func liststmtslice(l []*Node) *Node {
var ll *NodeList
for _, n := range l {
ll = list(ll, n)
}
return liststmt(ll)
}
// return nelem of list
func structcount(t *Type) int {
var s Iter
......
......@@ -617,27 +617,31 @@ func nodeSeqLen(ns nodesOrNodeList) int {
}
}
// nodeSeqFirst returns the first element of either a *NodeList or a Nodes.
// It panics if the sequence is empty.
// nodeSeqFirst returns the first element of a *NodeList, a Nodes,
// or a []*Node. It panics if the sequence is empty.
func nodeSeqFirst(ns nodesOrNodeList) *Node {
switch ns := ns.(type) {
case *NodeList:
return ns.N
case Nodes:
return ns.Slice()[0]
case []*Node:
return ns[0]
default:
panic("can't happen")
}
}
// nodeSeqSecond returns the second element of either a *NodeList or a Nodes.
// It panics if the sequence has fewer than two elements.
// nodeSeqSecond returns the second element of a *NodeList, a Nodes,
// or a []*Node. It panics if the sequence has fewer than two elements.
func nodeSeqSecond(ns nodesOrNodeList) *Node {
switch ns := ns.(type) {
case *NodeList:
return ns.Next.N
case Nodes:
return ns.Slice()[1]
case []*Node:
return ns[1]
default:
panic("can't happen")
}
......
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