cmd/compile: fix printing of OCASE nodes

Switch lowering splits each case expression out
into its own OCASE node.

Change-Id: Ifcb72b99975ed36da8540f6e43343e9aa2058572
Reviewed-on: https://go-review.googlesource.com/26769
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2016-05-25 14:08:13 -07:00 committed by Brad Fitzpatrick
parent bd2838be77
commit 4739dcf7fb
2 changed files with 9 additions and 2 deletions

View file

@ -886,13 +886,20 @@ func stmtfmt(n *Node) string {
f += fmt.Sprintf(" { %v }", n.List)
case OCASE, OXCASE:
case OXCASE:
if n.List.Len() != 0 {
f += fmt.Sprintf("case %v: %v", hconv(n.List, FmtComma), n.Nbody)
} else {
f += fmt.Sprintf("default: %v", n.Nbody)
}
case OCASE:
if n.Left != nil {
f += fmt.Sprintf("case %v: %v", n.Left, n.Nbody)
} else {
f += fmt.Sprintf("default: %v", n.Nbody)
}
case OBREAK,
OCONTINUE,
OGOTO,

View file

@ -425,7 +425,7 @@ const (
// statements
OBLOCK // { List } (block of code)
OBREAK // break
OCASE // case List: Nbody (select case after processing; List==nil means default)
OCASE // case Left: Nbody (select case after processing; Left==nil means default)
OXCASE // case List: Nbody (select case before processing; List==nil means default)
OCONTINUE // continue
ODEFER // defer Left (Left must be call)