diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2016-04-22 12:27:29 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2016-04-22 21:34:25 +0000 |
| commit | 97360096e5e9fdea06be8c97f32bd83741f68adb (patch) | |
| tree | 79051165f4530f7e048e9c17ef31e4c8ff2ada7f /src/cmd/compile/internal/gc/parser.go | |
| parent | 2d342fba78d9cbddb4c8c71bfc0d1044b2e5c58a (diff) | |
| download | go-git-97360096e5e9fdea06be8c97f32bd83741f68adb.tar.gz | |
cmd/compile: replace Ctype switches with type switches
Instead of switching on Ctype (which internally uses a type switch)
and then scattering lots of type assertions throughout the CTFOO case
clauses, just use type switches directly on the underlying constant
value.
Passes toolstash/buildall.
Change-Id: I9bc172cc67e5f391cddc15539907883b4010689e
Reviewed-on: https://go-review.googlesource.com/22384
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/gc/parser.go')
| -rw-r--r-- | src/cmd/compile/internal/gc/parser.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/gc/parser.go b/src/cmd/compile/internal/gc/parser.go index 6538877e68..ae4b497b7b 100644 --- a/src/cmd/compile/internal/gc/parser.go +++ b/src/cmd/compile/internal/gc/parser.go @@ -3246,17 +3246,14 @@ func (p *parser) hidden_literal() *Node { if p.tok == LLITERAL { ss := nodlit(p.val) p.next() - switch ss.Val().Ctype() { - case CTINT, CTRUNE: - ss.Val().U.(*Mpint).Neg() - break - case CTFLT: - ss.Val().U.(*Mpflt).Neg() - break - case CTCPLX: - ss.Val().U.(*Mpcplx).Real.Neg() - ss.Val().U.(*Mpcplx).Imag.Neg() - break + switch u := ss.Val().U.(type) { + case *Mpint: + u.Neg() + case *Mpflt: + u.Neg() + case *Mpcplx: + u.Real.Neg() + u.Imag.Neg() default: Yyerror("bad negated constant") } |
