Commit 4739dcf7 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder Committed by Brad Fitzpatrick

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: default avatarMatthew Dempsky <mdempsky@google.com>
parent bd2838be
......@@ -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,
......
......@@ -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)
......
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