From 79dbc1cc7b029e9f2e45cc9d7796151bd90b224a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 10 Nov 2017 18:35:30 +0000 Subject: [PATCH] cmd/compile: replace classnames with Class.String MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the slice of names is almost exactly the same as what stringer is already generating for us. Passes toolstash -cmp on std cmd. Change-Id: I3f1e95efc690c0108236689e721627f00f79a461 Reviewed-on: https://go-review.googlesource.com/77190 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Dave Cheney --- src/cmd/compile/internal/gc/fmt.go | 16 +--------------- src/cmd/compile/internal/gc/ssa.go | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/cmd/compile/internal/gc/fmt.go b/src/cmd/compile/internal/gc/fmt.go index f456510f57b..4b2fdb0dca7 100644 --- a/src/cmd/compile/internal/gc/fmt.go +++ b/src/cmd/compile/internal/gc/fmt.go @@ -232,16 +232,6 @@ func (o Op) oconv(s fmt.State, flag FmtFlag, mode fmtMode) { fmt.Fprint(s, o.String()) } -var classnames = []string{ - "Pxxx", - "PEXTERN", - "PAUTO", - "PAUTOHEAP", - "PPARAM", - "PPARAMOUT", - "PFUNC", -} - type ( fmtMode int @@ -439,11 +429,7 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) { } if n.Class() != 0 { - if int(n.Class()) < len(classnames) { - fmt.Fprintf(s, " class(%s)", classnames[n.Class()]) - } else { - fmt.Fprintf(s, " class(%d?)", n.Class()) - } + fmt.Fprintf(s, " class(%v)", n.Class()) } if n.Colas() { diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 07e3c05831e..a99a20a116f 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -179,7 +179,7 @@ func buildssa(fn *Node, worker int) *ssa.Func { case PFUNC: // local function - already handled by frontend default: - s.Fatalf("local variable with class %s unimplemented", classnames[n.Class()]) + s.Fatalf("local variable with class %v unimplemented", n.Class()) } } @@ -3394,7 +3394,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value { // that cse works on their addresses return s.newValue1A(ssa.OpAddr, t, n, s.sp) default: - s.Fatalf("variable address class %v not implemented", classnames[n.Class()]) + s.Fatalf("variable address class %v not implemented", n.Class()) return nil } case OINDREGSP: