mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
[dev.regabi] cmd/compile: rename CommStmt and CaseStmt [generated]
Rename these two AST nodes to match their cmd/compile/internal/syntax and go/ast counterparts. Passes toolstash -cmp. [git-generate] cd src/cmd/compile/internal/ir rf ' mv CaseStmt CaseClause mv CommStmt CommClause ' sed -E -i -e 's/(Case|Comm)Stmt/\1Clause/g' mknode.go Change-Id: I19fba0323a5de1e71346622857011b2f7879bcef Reviewed-on: https://go-review.googlesource.com/c/go/+/280446 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
parent
5f3bd59a0d
commit
f8afb8216a
|
@ -478,7 +478,7 @@ func stmtFmt(n Node, s fmt.State) {
|
||||||
fmt.Fprintf(s, " { %v }", n.Cases)
|
fmt.Fprintf(s, " { %v }", n.Cases)
|
||||||
|
|
||||||
case OCASE:
|
case OCASE:
|
||||||
n := n.(*CaseStmt)
|
n := n.(*CaseClause)
|
||||||
if len(n.List) != 0 {
|
if len(n.List) != 0 {
|
||||||
fmt.Fprintf(s, "case %.v", n.List)
|
fmt.Fprintf(s, "case %.v", n.List)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,8 +37,8 @@ func main() {
|
||||||
nodeType := lookup("Node")
|
nodeType := lookup("Node")
|
||||||
ntypeType := lookup("Ntype")
|
ntypeType := lookup("Ntype")
|
||||||
nodesType := lookup("Nodes")
|
nodesType := lookup("Nodes")
|
||||||
slicePtrCaseStmtType := types.NewSlice(types.NewPointer(lookup("CaseStmt")))
|
slicePtrCaseClauseType := types.NewSlice(types.NewPointer(lookup("CaseClause")))
|
||||||
slicePtrCommStmtType := types.NewSlice(types.NewPointer(lookup("CommStmt")))
|
slicePtrCommClauseType := types.NewSlice(types.NewPointer(lookup("CommClause")))
|
||||||
ptrFieldType := types.NewPointer(lookup("Field"))
|
ptrFieldType := types.NewPointer(lookup("Field"))
|
||||||
slicePtrFieldType := types.NewSlice(ptrFieldType)
|
slicePtrFieldType := types.NewSlice(ptrFieldType)
|
||||||
ptrIdentType := types.NewPointer(lookup("Ident"))
|
ptrIdentType := types.NewPointer(lookup("Ident"))
|
||||||
|
@ -78,9 +78,9 @@ func main() {
|
||||||
switch {
|
switch {
|
||||||
case is(nodesType):
|
case is(nodesType):
|
||||||
fmt.Fprintf(&buf, "c.%s = c.%s.Copy()\n", name, name)
|
fmt.Fprintf(&buf, "c.%s = c.%s.Copy()\n", name, name)
|
||||||
case is(slicePtrCaseStmtType):
|
case is(slicePtrCaseClauseType):
|
||||||
fmt.Fprintf(&buf, "c.%s = copyCases(c.%s)\n", name, name)
|
fmt.Fprintf(&buf, "c.%s = copyCases(c.%s)\n", name, name)
|
||||||
case is(slicePtrCommStmtType):
|
case is(slicePtrCommClauseType):
|
||||||
fmt.Fprintf(&buf, "c.%s = copyComms(c.%s)\n", name, name)
|
fmt.Fprintf(&buf, "c.%s = copyComms(c.%s)\n", name, name)
|
||||||
case is(ptrFieldType):
|
case is(ptrFieldType):
|
||||||
fmt.Fprintf(&buf, "if c.%s != nil { c.%s = c.%s.copy() }\n", name, name, name)
|
fmt.Fprintf(&buf, "if c.%s != nil { c.%s = c.%s.copy() }\n", name, name, name)
|
||||||
|
@ -100,9 +100,9 @@ func main() {
|
||||||
fmt.Fprintf(&buf, "err = maybeDo(n.%s, err, do)\n", name)
|
fmt.Fprintf(&buf, "err = maybeDo(n.%s, err, do)\n", name)
|
||||||
case is(nodesType):
|
case is(nodesType):
|
||||||
fmt.Fprintf(&buf, "err = maybeDoList(n.%s, err, do)\n", name)
|
fmt.Fprintf(&buf, "err = maybeDoList(n.%s, err, do)\n", name)
|
||||||
case is(slicePtrCaseStmtType):
|
case is(slicePtrCaseClauseType):
|
||||||
fmt.Fprintf(&buf, "err = maybeDoCases(n.%s, err, do)\n", name)
|
fmt.Fprintf(&buf, "err = maybeDoCases(n.%s, err, do)\n", name)
|
||||||
case is(slicePtrCommStmtType):
|
case is(slicePtrCommClauseType):
|
||||||
fmt.Fprintf(&buf, "err = maybeDoComms(n.%s, err, do)\n", name)
|
fmt.Fprintf(&buf, "err = maybeDoComms(n.%s, err, do)\n", name)
|
||||||
case is(ptrFieldType):
|
case is(ptrFieldType):
|
||||||
fmt.Fprintf(&buf, "err = maybeDoField(n.%s, err, do)\n", name)
|
fmt.Fprintf(&buf, "err = maybeDoField(n.%s, err, do)\n", name)
|
||||||
|
@ -123,9 +123,9 @@ func main() {
|
||||||
fmt.Fprintf(&buf, "n.%s = toNtype(maybeEdit(n.%s, edit))\n", name, name)
|
fmt.Fprintf(&buf, "n.%s = toNtype(maybeEdit(n.%s, edit))\n", name, name)
|
||||||
case is(nodesType):
|
case is(nodesType):
|
||||||
fmt.Fprintf(&buf, "editList(n.%s, edit)\n", name)
|
fmt.Fprintf(&buf, "editList(n.%s, edit)\n", name)
|
||||||
case is(slicePtrCaseStmtType):
|
case is(slicePtrCaseClauseType):
|
||||||
fmt.Fprintf(&buf, "editCases(n.%s, edit)\n", name)
|
fmt.Fprintf(&buf, "editCases(n.%s, edit)\n", name)
|
||||||
case is(slicePtrCommStmtType):
|
case is(slicePtrCommClauseType):
|
||||||
fmt.Fprintf(&buf, "editComms(n.%s, edit)\n", name)
|
fmt.Fprintf(&buf, "editComms(n.%s, edit)\n", name)
|
||||||
case is(ptrFieldType):
|
case is(ptrFieldType):
|
||||||
fmt.Fprintf(&buf, "editField(n.%s, edit)\n", name)
|
fmt.Fprintf(&buf, "editField(n.%s, edit)\n", name)
|
||||||
|
|
|
@ -226,15 +226,15 @@ func (n *CallPartExpr) editChildren(edit func(Node) Node) {
|
||||||
n.X = maybeEdit(n.X, edit)
|
n.X = maybeEdit(n.X, edit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *CaseStmt) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
|
func (n *CaseClause) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
|
||||||
func (n *CaseStmt) copy() Node {
|
func (n *CaseClause) copy() Node {
|
||||||
c := *n
|
c := *n
|
||||||
c.init = c.init.Copy()
|
c.init = c.init.Copy()
|
||||||
c.List = c.List.Copy()
|
c.List = c.List.Copy()
|
||||||
c.Body = c.Body.Copy()
|
c.Body = c.Body.Copy()
|
||||||
return &c
|
return &c
|
||||||
}
|
}
|
||||||
func (n *CaseStmt) doChildren(do func(Node) error) error {
|
func (n *CaseClause) doChildren(do func(Node) error) error {
|
||||||
var err error
|
var err error
|
||||||
err = maybeDoList(n.init, err, do)
|
err = maybeDoList(n.init, err, do)
|
||||||
err = maybeDo(n.Var, err, do)
|
err = maybeDo(n.Var, err, do)
|
||||||
|
@ -242,7 +242,7 @@ func (n *CaseStmt) doChildren(do func(Node) error) error {
|
||||||
err = maybeDoList(n.Body, err, do)
|
err = maybeDoList(n.Body, err, do)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
func (n *CaseStmt) editChildren(edit func(Node) Node) {
|
func (n *CaseClause) editChildren(edit func(Node) Node) {
|
||||||
editList(n.init, edit)
|
editList(n.init, edit)
|
||||||
n.Var = maybeEdit(n.Var, edit)
|
n.Var = maybeEdit(n.Var, edit)
|
||||||
editList(n.List, edit)
|
editList(n.List, edit)
|
||||||
|
@ -293,21 +293,21 @@ func (n *ClosureReadExpr) editChildren(edit func(Node) Node) {
|
||||||
editList(n.init, edit)
|
editList(n.init, edit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *CommStmt) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
|
func (n *CommClause) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) }
|
||||||
func (n *CommStmt) copy() Node {
|
func (n *CommClause) copy() Node {
|
||||||
c := *n
|
c := *n
|
||||||
c.init = c.init.Copy()
|
c.init = c.init.Copy()
|
||||||
c.Body = c.Body.Copy()
|
c.Body = c.Body.Copy()
|
||||||
return &c
|
return &c
|
||||||
}
|
}
|
||||||
func (n *CommStmt) doChildren(do func(Node) error) error {
|
func (n *CommClause) doChildren(do func(Node) error) error {
|
||||||
var err error
|
var err error
|
||||||
err = maybeDoList(n.init, err, do)
|
err = maybeDoList(n.init, err, do)
|
||||||
err = maybeDo(n.Comm, err, do)
|
err = maybeDo(n.Comm, err, do)
|
||||||
err = maybeDoList(n.Body, err, do)
|
err = maybeDoList(n.Body, err, do)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
func (n *CommStmt) editChildren(edit func(Node) Node) {
|
func (n *CommClause) editChildren(edit func(Node) Node) {
|
||||||
editList(n.init, edit)
|
editList(n.init, edit)
|
||||||
n.Comm = maybeEdit(n.Comm, edit)
|
n.Comm = maybeEdit(n.Comm, edit)
|
||||||
editList(n.Body, edit)
|
editList(n.Body, edit)
|
||||||
|
|
|
@ -173,31 +173,31 @@ func NewBranchStmt(pos src.XPos, op Op, label *types.Sym) *BranchStmt {
|
||||||
|
|
||||||
func (n *BranchStmt) Sym() *types.Sym { return n.Label }
|
func (n *BranchStmt) Sym() *types.Sym { return n.Label }
|
||||||
|
|
||||||
// A CaseStmt is a case statement in a switch or select: case List: Body.
|
// A CaseClause is a case statement in a switch or select: case List: Body.
|
||||||
type CaseStmt struct {
|
type CaseClause struct {
|
||||||
miniStmt
|
miniStmt
|
||||||
Var Node // declared variable for this case in type switch
|
Var Node // declared variable for this case in type switch
|
||||||
List Nodes // list of expressions for switch, early select
|
List Nodes // list of expressions for switch, early select
|
||||||
Body Nodes
|
Body Nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCaseStmt(pos src.XPos, list, body []Node) *CaseStmt {
|
func NewCaseStmt(pos src.XPos, list, body []Node) *CaseClause {
|
||||||
n := &CaseStmt{List: list, Body: body}
|
n := &CaseClause{List: list, Body: body}
|
||||||
n.pos = pos
|
n.pos = pos
|
||||||
n.op = OCASE
|
n.op = OCASE
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mdempsky): Generate these with mknode.go.
|
// TODO(mdempsky): Generate these with mknode.go.
|
||||||
func copyCases(list []*CaseStmt) []*CaseStmt {
|
func copyCases(list []*CaseClause) []*CaseClause {
|
||||||
if list == nil {
|
if list == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
c := make([]*CaseStmt, len(list))
|
c := make([]*CaseClause, len(list))
|
||||||
copy(c, list)
|
copy(c, list)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
func maybeDoCases(list []*CaseStmt, err error, do func(Node) error) error {
|
func maybeDoCases(list []*CaseClause, err error, do func(Node) error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -210,37 +210,37 @@ func maybeDoCases(list []*CaseStmt, err error, do func(Node) error) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func editCases(list []*CaseStmt, edit func(Node) Node) {
|
func editCases(list []*CaseClause, edit func(Node) Node) {
|
||||||
for i, x := range list {
|
for i, x := range list {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
list[i] = edit(x).(*CaseStmt)
|
list[i] = edit(x).(*CaseClause)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommStmt struct {
|
type CommClause struct {
|
||||||
miniStmt
|
miniStmt
|
||||||
Comm Node // communication case
|
Comm Node // communication case
|
||||||
Body Nodes
|
Body Nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommStmt(pos src.XPos, comm Node, body []Node) *CommStmt {
|
func NewCommStmt(pos src.XPos, comm Node, body []Node) *CommClause {
|
||||||
n := &CommStmt{Comm: comm, Body: body}
|
n := &CommClause{Comm: comm, Body: body}
|
||||||
n.pos = pos
|
n.pos = pos
|
||||||
n.op = OCASE
|
n.op = OCASE
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mdempsky): Generate these with mknode.go.
|
// TODO(mdempsky): Generate these with mknode.go.
|
||||||
func copyComms(list []*CommStmt) []*CommStmt {
|
func copyComms(list []*CommClause) []*CommClause {
|
||||||
if list == nil {
|
if list == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
c := make([]*CommStmt, len(list))
|
c := make([]*CommClause, len(list))
|
||||||
copy(c, list)
|
copy(c, list)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
func maybeDoComms(list []*CommStmt, err error, do func(Node) error) error {
|
func maybeDoComms(list []*CommClause, err error, do func(Node) error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -253,10 +253,10 @@ func maybeDoComms(list []*CommStmt, err error, do func(Node) error) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func editComms(list []*CommStmt, edit func(Node) Node) {
|
func editComms(list []*CommClause, edit func(Node) Node) {
|
||||||
for i, x := range list {
|
for i, x := range list {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
list[i] = edit(x).(*CommStmt)
|
list[i] = edit(x).(*CommClause)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,14 +406,14 @@ func (n *ReturnStmt) SetOrig(x Node) { n.orig = x }
|
||||||
type SelectStmt struct {
|
type SelectStmt struct {
|
||||||
miniStmt
|
miniStmt
|
||||||
Label *types.Sym
|
Label *types.Sym
|
||||||
Cases []*CommStmt
|
Cases []*CommClause
|
||||||
HasBreak bool
|
HasBreak bool
|
||||||
|
|
||||||
// TODO(rsc): Instead of recording here, replace with a block?
|
// TODO(rsc): Instead of recording here, replace with a block?
|
||||||
Compiled Nodes // compiled form, after walkswitch
|
Compiled Nodes // compiled form, after walkswitch
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSelectStmt(pos src.XPos, cases []*CommStmt) *SelectStmt {
|
func NewSelectStmt(pos src.XPos, cases []*CommClause) *SelectStmt {
|
||||||
n := &SelectStmt{Cases: cases}
|
n := &SelectStmt{Cases: cases}
|
||||||
n.pos = pos
|
n.pos = pos
|
||||||
n.op = OSELECT
|
n.op = OSELECT
|
||||||
|
@ -438,7 +438,7 @@ func NewSendStmt(pos src.XPos, ch, value Node) *SendStmt {
|
||||||
type SwitchStmt struct {
|
type SwitchStmt struct {
|
||||||
miniStmt
|
miniStmt
|
||||||
Tag Node
|
Tag Node
|
||||||
Cases []*CaseStmt
|
Cases []*CaseClause
|
||||||
Label *types.Sym
|
Label *types.Sym
|
||||||
HasBreak bool
|
HasBreak bool
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ type SwitchStmt struct {
|
||||||
Compiled Nodes // compiled form, after walkswitch
|
Compiled Nodes // compiled form, after walkswitch
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSwitchStmt(pos src.XPos, tag Node, cases []*CaseStmt) *SwitchStmt {
|
func NewSwitchStmt(pos src.XPos, tag Node, cases []*CaseClause) *SwitchStmt {
|
||||||
n := &SwitchStmt{Tag: tag, Cases: cases}
|
n := &SwitchStmt{Tag: tag, Cases: cases}
|
||||||
n.pos = pos
|
n.pos = pos
|
||||||
n.op = OSWITCH
|
n.op = OSWITCH
|
||||||
|
|
|
@ -1212,8 +1212,8 @@ func (p *noder) switchStmt(stmt *syntax.SwitchStmt) ir.Node {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitchGuard, rbrace syntax.Pos) []*ir.CaseStmt {
|
func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitchGuard, rbrace syntax.Pos) []*ir.CaseClause {
|
||||||
nodes := make([]*ir.CaseStmt, 0, len(clauses))
|
nodes := make([]*ir.CaseClause, 0, len(clauses))
|
||||||
for i, clause := range clauses {
|
for i, clause := range clauses {
|
||||||
p.setlineno(clause)
|
p.setlineno(clause)
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
@ -1263,8 +1263,8 @@ func (p *noder) selectStmt(stmt *syntax.SelectStmt) ir.Node {
|
||||||
return ir.NewSelectStmt(p.pos(stmt), p.commClauses(stmt.Body, stmt.Rbrace))
|
return ir.NewSelectStmt(p.pos(stmt), p.commClauses(stmt.Body, stmt.Rbrace))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *noder) commClauses(clauses []*syntax.CommClause, rbrace syntax.Pos) []*ir.CommStmt {
|
func (p *noder) commClauses(clauses []*syntax.CommClause, rbrace syntax.Pos) []*ir.CommClause {
|
||||||
nodes := make([]*ir.CommStmt, len(clauses))
|
nodes := make([]*ir.CommClause, len(clauses))
|
||||||
for i, clause := range clauses {
|
for i, clause := range clauses {
|
||||||
p.setlineno(clause)
|
p.setlineno(clause)
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ func isNamedTypeSwitch(x ir.Node) bool {
|
||||||
return ok && guard.Tag != nil
|
return ok && guard.Tag != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *exportWriter) caseList(cases []*ir.CaseStmt, namedTypeSwitch bool) {
|
func (w *exportWriter) caseList(cases []*ir.CaseClause, namedTypeSwitch bool) {
|
||||||
w.uint64(uint64(len(cases)))
|
w.uint64(uint64(len(cases)))
|
||||||
for _, cas := range cases {
|
for _, cas := range cases {
|
||||||
w.pos(cas.Pos())
|
w.pos(cas.Pos())
|
||||||
|
@ -1193,7 +1193,7 @@ func (w *exportWriter) caseList(cases []*ir.CaseStmt, namedTypeSwitch bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *exportWriter) commList(cases []*ir.CommStmt) {
|
func (w *exportWriter) commList(cases []*ir.CommClause) {
|
||||||
w.uint64(uint64(len(cases)))
|
w.uint64(uint64(len(cases)))
|
||||||
for _, cas := range cases {
|
for _, cas := range cases {
|
||||||
w.pos(cas.Pos())
|
w.pos(cas.Pos())
|
||||||
|
|
|
@ -767,10 +767,10 @@ func (r *importReader) stmtList() []ir.Node {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *importReader) caseList(switchExpr ir.Node) []*ir.CaseStmt {
|
func (r *importReader) caseList(switchExpr ir.Node) []*ir.CaseClause {
|
||||||
namedTypeSwitch := isNamedTypeSwitch(switchExpr)
|
namedTypeSwitch := isNamedTypeSwitch(switchExpr)
|
||||||
|
|
||||||
cases := make([]*ir.CaseStmt, r.uint64())
|
cases := make([]*ir.CaseClause, r.uint64())
|
||||||
for i := range cases {
|
for i := range cases {
|
||||||
cas := ir.NewCaseStmt(r.pos(), nil, nil)
|
cas := ir.NewCaseStmt(r.pos(), nil, nil)
|
||||||
cas.List.Set(r.stmtList())
|
cas.List.Set(r.stmtList())
|
||||||
|
@ -789,8 +789,8 @@ func (r *importReader) caseList(switchExpr ir.Node) []*ir.CaseStmt {
|
||||||
return cases
|
return cases
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *importReader) commList() []*ir.CommStmt {
|
func (r *importReader) commList() []*ir.CommClause {
|
||||||
cases := make([]*ir.CommStmt, r.uint64())
|
cases := make([]*ir.CommClause, r.uint64())
|
||||||
for i := range cases {
|
for i := range cases {
|
||||||
cases[i] = ir.NewCommStmt(r.pos(), r.node(), r.stmtList())
|
cases[i] = ir.NewCommStmt(r.pos(), r.node(), r.stmtList())
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,7 @@ func tcReturn(n *ir.ReturnStmt) ir.Node {
|
||||||
|
|
||||||
// select
|
// select
|
||||||
func tcSelect(sel *ir.SelectStmt) {
|
func tcSelect(sel *ir.SelectStmt) {
|
||||||
var def *ir.CommStmt
|
var def *ir.CommClause
|
||||||
lno := ir.SetPos(sel)
|
lno := ir.SetPos(sel)
|
||||||
Stmts(sel.Init())
|
Stmts(sel.Init())
|
||||||
for _, ncase := range sel.Cases {
|
for _, ncase := range sel.Cases {
|
||||||
|
|
|
@ -29,7 +29,7 @@ func walkSelect(sel *ir.SelectStmt) {
|
||||||
base.Pos = lno
|
base.Pos = lno
|
||||||
}
|
}
|
||||||
|
|
||||||
func walkSelectCases(cases []*ir.CommStmt) []ir.Node {
|
func walkSelectCases(cases []*ir.CommClause) []ir.Node {
|
||||||
ncas := len(cases)
|
ncas := len(cases)
|
||||||
sellineno := base.Pos
|
sellineno := base.Pos
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func walkSelectCases(cases []*ir.CommStmt) []ir.Node {
|
||||||
|
|
||||||
// convert case value arguments to addresses.
|
// convert case value arguments to addresses.
|
||||||
// this rewrite is used by both the general code and the next optimization.
|
// this rewrite is used by both the general code and the next optimization.
|
||||||
var dflt *ir.CommStmt
|
var dflt *ir.CommClause
|
||||||
for _, cas := range cases {
|
for _, cas := range cases {
|
||||||
ir.SetPos(cas)
|
ir.SetPos(cas)
|
||||||
n := cas.Comm
|
n := cas.Comm
|
||||||
|
@ -146,7 +146,7 @@ func walkSelectCases(cases []*ir.CommStmt) []ir.Node {
|
||||||
if dflt != nil {
|
if dflt != nil {
|
||||||
ncas--
|
ncas--
|
||||||
}
|
}
|
||||||
casorder := make([]*ir.CommStmt, ncas)
|
casorder := make([]*ir.CommClause, ncas)
|
||||||
nsends, nrecvs := 0, 0
|
nsends, nrecvs := 0, 0
|
||||||
|
|
||||||
var init []ir.Node
|
var init []ir.Node
|
||||||
|
@ -242,7 +242,7 @@ func walkSelectCases(cases []*ir.CommStmt) []ir.Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispatch cases
|
// dispatch cases
|
||||||
dispatch := func(cond ir.Node, cas *ir.CommStmt) {
|
dispatch := func(cond ir.Node, cas *ir.CommClause) {
|
||||||
cond = typecheck.Expr(cond)
|
cond = typecheck.Expr(cond)
|
||||||
cond = typecheck.DefaultLit(cond, nil)
|
cond = typecheck.DefaultLit(cond, nil)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue