mirror of
https://github.com/golang/go
synced 2024-11-23 20:20:01 -07:00
cmd/compile: use stringer on types.EType
Another one that is possible thanks to the new -trimprefix stringer flag. The only subtle difference is that, in the previous version, some values such as TUNSAFEPTR were stringified as "TUNSAFEPTR" instead of "UNSAFEPTR". The new String method is always consistent in removing the "T" prefix. Passes toolstash -cmp on std cmd. Change-Id: I68407f391795403dfcbbfa68c813018c0235bbb5 Reviewed-on: https://go-review.googlesource.com/77250 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
79dbc1cc7b
commit
6e9960ea63
16
src/cmd/compile/internal/types/etype_string.go
Normal file
16
src/cmd/compile/internal/types/etype_string.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Code generated by "stringer -type EType -trimprefix T"; DO NOT EDIT.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
const _EType_name = "xxxINT8UINT8INT16UINT16INT32UINT32INT64UINT64INTUINTUINTPTRCOMPLEX64COMPLEX128FLOAT32FLOAT64BOOLPTR32PTR64FUNCSLICEARRAYSTRUCTCHANMAPINTERFORWANYSTRINGUNSAFEPTRIDEALNILBLANKFUNCARGSCHANARGSDDDFIELDSSATUPLENTYPE"
|
||||||
|
|
||||||
|
var _EType_index = [...]uint8{0, 3, 7, 12, 17, 23, 28, 34, 39, 45, 48, 52, 59, 68, 78, 85, 92, 96, 101, 106, 110, 115, 120, 126, 130, 133, 138, 142, 145, 151, 160, 165, 168, 173, 181, 189, 197, 200, 205, 210}
|
||||||
|
|
||||||
|
func (i EType) String() string {
|
||||||
|
if i >= EType(len(_EType_index)-1) {
|
||||||
|
return fmt.Sprintf("EType(%d)", i)
|
||||||
|
}
|
||||||
|
return _EType_name[_EType_index[i]:_EType_index[i+1]]
|
||||||
|
}
|
@ -15,11 +15,13 @@ import (
|
|||||||
// TODO(gri) try to eliminate soon
|
// TODO(gri) try to eliminate soon
|
||||||
type Node struct{ _ int }
|
type Node struct{ _ int }
|
||||||
|
|
||||||
|
//go:generate stringer -type EType -trimprefix T
|
||||||
|
|
||||||
// EType describes a kind of type.
|
// EType describes a kind of type.
|
||||||
type EType uint8
|
type EType uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Txxx = iota
|
Txxx EType = iota
|
||||||
|
|
||||||
TINT8
|
TINT8
|
||||||
TUINT8
|
TUINT8
|
||||||
|
@ -76,51 +76,3 @@ func (f *bitset8) set(mask uint8, b bool) {
|
|||||||
*(*uint8)(f) &^= mask
|
*(*uint8)(f) &^= mask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var etnames = []string{
|
|
||||||
Txxx: "Txxx",
|
|
||||||
TINT: "INT",
|
|
||||||
TUINT: "UINT",
|
|
||||||
TINT8: "INT8",
|
|
||||||
TUINT8: "UINT8",
|
|
||||||
TINT16: "INT16",
|
|
||||||
TUINT16: "UINT16",
|
|
||||||
TINT32: "INT32",
|
|
||||||
TUINT32: "UINT32",
|
|
||||||
TINT64: "INT64",
|
|
||||||
TUINT64: "UINT64",
|
|
||||||
TUINTPTR: "UINTPTR",
|
|
||||||
TFLOAT32: "FLOAT32",
|
|
||||||
TFLOAT64: "FLOAT64",
|
|
||||||
TCOMPLEX64: "COMPLEX64",
|
|
||||||
TCOMPLEX128: "COMPLEX128",
|
|
||||||
TBOOL: "BOOL",
|
|
||||||
TPTR32: "PTR32",
|
|
||||||
TPTR64: "PTR64",
|
|
||||||
TFUNC: "FUNC",
|
|
||||||
TARRAY: "ARRAY",
|
|
||||||
TSLICE: "SLICE",
|
|
||||||
TSTRUCT: "STRUCT",
|
|
||||||
TCHAN: "CHAN",
|
|
||||||
TMAP: "MAP",
|
|
||||||
TINTER: "INTER",
|
|
||||||
TFORW: "FORW",
|
|
||||||
TSTRING: "STRING",
|
|
||||||
TUNSAFEPTR: "TUNSAFEPTR",
|
|
||||||
TANY: "ANY",
|
|
||||||
TIDEAL: "TIDEAL",
|
|
||||||
TNIL: "TNIL",
|
|
||||||
TBLANK: "TBLANK",
|
|
||||||
TFUNCARGS: "TFUNCARGS",
|
|
||||||
TCHANARGS: "TCHANARGS",
|
|
||||||
TDDDFIELD: "TDDDFIELD",
|
|
||||||
TSSA: "TSSA",
|
|
||||||
TTUPLE: "TTUPLE",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (et EType) String() string {
|
|
||||||
if int(et) < len(etnames) && etnames[et] != "" {
|
|
||||||
return etnames[et]
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("E-%d", et)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user