if n.Op == OSWITCH && n.Left != nil && n.Left.Op == OTYPESW {
for ll := n.List; ll != nil; ll = ll.Next { // cases
- // ll->n->nname is the variable per case
- if ll.N.Nname != nil {
- e.nodeEscState(ll.N.Nname).Escloopdepth = e.loopdepth
+ // ll.N.Rlist is the variable per case
+ if ll.N.Rlist != nil {
+ e.nodeEscState(ll.N.Rlist.N).Escloopdepth = e.loopdepth
}
}
}
if n.Left != nil && n.Left.Op == OTYPESW {
for ll := n.List; ll != nil; ll = ll.Next {
// cases
- // ntest->right is the argument of the .(type),
- // ll->n->nname is the variable per case
- escassign(e, ll.N.Nname, n.Left.Right)
+ // n.Left.Right is the argument of the .(type),
+ // ll.N.Rlist is the variable per case
+ if ll.N.Rlist != nil {
+ escassign(e, ll.N.Rlist.N, n.Left.Right)
+ }
}
}
// type switch - declare variable
nn = newname(n.Sym);
declare(nn, dclcontext);
- $$.Nname = nn;
+ $$.Rlist = list1(nn);
// keep track of the instances for reporting unused
nn.Name.Defn = typesw.Right;
// type switch - declare variable
nn = newname(n.Sym);
declare(nn, dclcontext);
- $$.Nname = nn;
+ $$.Rlist = list1(nn);
// keep track of the instances for reporting unused
nn.Name.Defn = typesw.Right;
if top == Etype && n.Type != nil {
ll = ncase.List
- nvar := ncase.Nname
- if nvar != nil {
+ if ncase.Rlist != nil {
+ nvar := ncase.Rlist.N
if ll != nil && ll.Next == nil && ll.N.Type != nil && !Istype(ll.N.Type, TNIL) {
// single entry type switch
nvar.Name.Param.Ntype = typenod(ll.N.Type)
}
typecheck(&nvar, Erv|Easgn)
- ncase.Nname = nvar
+ ncase.Rlist.N = nvar
}
}
}
stat = list(stat, Nod(OLABEL, jmp.Left, nil))
- if typeswvar != nil && needvar && n.Nname != nil {
- l := list1(Nod(ODCL, n.Nname, nil))
- l = list(l, Nod(OAS, n.Nname, typeswvar))
+ if typeswvar != nil && needvar && n.Rlist != nil {
+ l := list1(Nod(ODCL, n.Rlist.N, nil))
+ l = list(l, Nod(OAS, n.Rlist.N, typeswvar))
typechecklist(l, Etop)
stat = concat(stat, l)
}
// typeone generates an AST that jumps to the
// case body if the variable is of type t.
func (s *typeSwitch) typeone(t *Node) *Node {
- name := t.Nname
+ var name *Node
var init *NodeList
- if name == nil {
- typecheck(&nblank, Erv|Easgn)
+ if t.Rlist == nil {
name = nblank
+ typecheck(&nblank, Erv|Easgn)
} else {
+ name = t.Rlist.N
init = list1(Nod(ODCL, name, nil))
}
// type switch - declare variable
nn = newname(n.Sym)
declare(nn, dclcontext)
- yyVAL.node.Nname = nn
+ yyVAL.node.Rlist = list1(nn)
// keep track of the instances for reporting unused
nn.Name.Defn = typesw.Right
// type switch - declare variable
nn = newname(n.Sym)
declare(nn, dclcontext)
- yyVAL.node.Nname = nn
+ yyVAL.node.Rlist = list1(nn)
// keep track of the instances for reporting unused
nn.Name.Defn = typesw.Right