cmd/compile: replace opnames with stringer

Now possible, since stringer just got the -trimprefix flag added.

While at it, simplify a few Op stringifications since we can now use %v,
and no longer have to worry about o<len(opnames).

Passes toolstash -cmp on std cmd.

Fixes #15462.

Change-Id: Icdcde0b0a5eb165d18488918175024da274f782b
Reviewed-on: https://go-review.googlesource.com/76790
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
This commit is contained in:
Daniel Martí 2017-11-09 23:10:43 +00:00
parent 366681cc06
commit 3231d4e4ef
7 changed files with 25 additions and 172 deletions

View file

@ -206,10 +206,6 @@ var goopnames = []string{
OXOR: "^",
}
func (o Op) String() string {
return fmt.Sprint(o)
}
func (o Op) GoString() string {
return fmt.Sprintf("%#v", o)
}
@ -232,12 +228,8 @@ func (o Op) oconv(s fmt.State, flag FmtFlag, mode fmtMode) {
}
}
if int(o) < len(opnames) && opnames[o] != "" {
fmt.Fprint(s, opnames[o])
return
}
fmt.Fprintf(s, "O-%d", int(o))
// 'o.String()' instead of just 'o' to avoid infinite recursion
fmt.Fprint(s, o.String())
}
var classnames = []string{