/
pass_enumer.go
90 lines (75 loc) · 2.19 KB
/
pass_enumer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Code generated by "enumer -type=Pass"; DO NOT EDIT.
package xform
import (
"fmt"
"strings"
)
const _PassName = "ElaborationSimplificationLoweringLegalizeCleanUp"
var _PassIndex = [...]uint8{0, 11, 25, 33, 41, 48}
const _PassLowerName = "elaborationsimplificationloweringlegalizecleanup"
func (i Pass) String() string {
if i < 0 || i >= Pass(len(_PassIndex)-1) {
return fmt.Sprintf("Pass(%d)", i)
}
return _PassName[_PassIndex[i]:_PassIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _PassNoOp() {
var x [1]struct{}
_ = x[Elaboration-(0)]
_ = x[Simplification-(1)]
_ = x[Lowering-(2)]
_ = x[Legalize-(3)]
_ = x[CleanUp-(4)]
}
var _PassValues = []Pass{Elaboration, Simplification, Lowering, Legalize, CleanUp}
var _PassNameToValueMap = map[string]Pass{
_PassName[0:11]: Elaboration,
_PassLowerName[0:11]: Elaboration,
_PassName[11:25]: Simplification,
_PassLowerName[11:25]: Simplification,
_PassName[25:33]: Lowering,
_PassLowerName[25:33]: Lowering,
_PassName[33:41]: Legalize,
_PassLowerName[33:41]: Legalize,
_PassName[41:48]: CleanUp,
_PassLowerName[41:48]: CleanUp,
}
var _PassNames = []string{
_PassName[0:11],
_PassName[11:25],
_PassName[25:33],
_PassName[33:41],
_PassName[41:48],
}
// PassString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func PassString(s string) (Pass, error) {
if val, ok := _PassNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _PassNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Pass values", s)
}
// PassValues returns all values of the enum
func PassValues() []Pass {
return _PassValues
}
// PassStrings returns a slice of all String values of the enum
func PassStrings() []string {
strs := make([]string, len(_PassNames))
copy(strs, _PassNames)
return strs
}
// IsAPass returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Pass) IsAPass() bool {
for _, v := range _PassValues {
if i == v {
return true
}
}
return false
}