]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: make AlgKind a stringer
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 14 Apr 2020 22:16:09 +0000 (15:16 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 16 Apr 2020 03:19:50 +0000 (03:19 +0000)
Change-Id: I4a4b866d9233b8369e5ca913a9dd576b323b8f3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/228421
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/gc/alg.go
src/cmd/compile/internal/gc/algkind_string.go [new file with mode: 0644]

index c83badaa86e400ecc21c2a3596117567c8d6fa4d..404df12609f8d351985d4d4715d54f9cbe7aac25 100644 (file)
@@ -14,6 +14,8 @@ import (
 // hashing a Type.
 type AlgKind int
 
+//go:generate stringer -type AlgKind -trimprefix A
+
 const (
        // These values are known by runtime.
        ANOEQ AlgKind = iota
diff --git a/src/cmd/compile/internal/gc/algkind_string.go b/src/cmd/compile/internal/gc/algkind_string.go
new file mode 100644 (file)
index 0000000..52b5399
--- /dev/null
@@ -0,0 +1,48 @@
+// Code generated by "stringer -type AlgKind -trimprefix A"; DO NOT EDIT.
+
+package gc
+
+import "strconv"
+
+func _() {
+       // An "invalid array index" compiler error signifies that the constant values have changed.
+       // Re-run the stringer command to generate them again.
+       var x [1]struct{}
+       _ = x[ANOEQ-0]
+       _ = x[AMEM0-1]
+       _ = x[AMEM8-2]
+       _ = x[AMEM16-3]
+       _ = x[AMEM32-4]
+       _ = x[AMEM64-5]
+       _ = x[AMEM128-6]
+       _ = x[ASTRING-7]
+       _ = x[AINTER-8]
+       _ = x[ANILINTER-9]
+       _ = x[AFLOAT32-10]
+       _ = x[AFLOAT64-11]
+       _ = x[ACPLX64-12]
+       _ = x[ACPLX128-13]
+       _ = x[AMEM-100]
+       _ = x[ASPECIAL - -1]
+}
+
+const (
+       _AlgKind_name_0 = "SPECIALNOEQMEM0MEM8MEM16MEM32MEM64MEM128STRINGINTERNILINTERFLOAT32FLOAT64CPLX64CPLX128"
+       _AlgKind_name_1 = "MEM"
+)
+
+var (
+       _AlgKind_index_0 = [...]uint8{0, 7, 11, 15, 19, 24, 29, 34, 40, 46, 51, 59, 66, 73, 79, 86}
+)
+
+func (i AlgKind) String() string {
+       switch {
+       case -1 <= i && i <= 13:
+               i -= -1
+               return _AlgKind_name_0[_AlgKind_index_0[i]:_AlgKind_index_0[i+1]]
+       case i == 100:
+               return _AlgKind_name_1
+       default:
+               return "AlgKind(" + strconv.FormatInt(int64(i), 10) + ")"
+       }
+}