label.Name.Defn = ls
l := list1(label)
if ls != nil {
- l = list(l, ls)
+ if ls.Op == OBLOCK && nodeSeqLen(ls.Ninit) == 0 {
+ l = concat(l, ls.List)
+ } else {
+ l = list(l, ls)
+ }
}
return liststmt(l)
}
if p.tok == LIF {
setNodeSeq(&stmt.Rlist, []*Node{p.if_stmt()})
} else {
- setNodeSeq(&stmt.Rlist, []*Node{p.compound_stmt(true)})
+ cs := p.compound_stmt(true)
+ if cs.Op == OBLOCK && cs.Ninit == nil {
+ setNodeSeq(&stmt.Rlist, cs.List)
+ } else {
+ setNodeSeq(&stmt.Rlist, []*Node{cs})
+ }
}
}
if s == missing_stmt {
break
}
- l = list(l, s)
+ if s != nil && s.Op == OBLOCK && nodeSeqLen(s.Ninit) == 0 {
+ l = concat(l, s.List)
+ } else {
+ l = list(l, s)
+ }
// customized version of osemi:
// ';' is optional before a closing ')' or '}'
if p.tok == ')' || p.tok == '}' {
if n == nil {
return nil
}
- if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
- // Flatten list and steal storage.
- // Poison pointer to catch errant uses.
- l := n.List
-
- setNodeSeq(&n.List, nil)
- return l
- }
-
l := new(NodeList)
l.N = n
l.End = l
// This is an interim function during the transition from NodeList to Nodes.
// TODO(iant): Remove when transition is complete.
func setNodeSeqNode(a nodesOrNodeListPtr, n *Node) {
- // This is what the old list1 function did;
- // the rest of the compiler has come to expect it.
- if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
- l := n.List
- setNodeSeq(&n.List, nil)
- setNodeSeq(a, l)
- return
- }
-
switch a := a.(type) {
case **NodeList:
*a = list1(n)
// This is an interim function during the transition from NodeList to Nodes.
// TODO(iant): Remove when transition is complete.
func appendNodeSeqNode(a nodesOrNodeListPtr, n *Node) {
- // This is what the old list1 function did;
- // the rest of the compiler has come to expect it.
- if n.Op == OBLOCK && nodeSeqLen(n.Ninit) == 0 {
- l := n.List
- setNodeSeq(&n.List, nil)
- appendNodeSeq(a, l)
- return
- }
-
switch a := a.(type) {
case **NodeList:
*a = list(*a, n)