-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypeclasses.go
137 lines (119 loc) · 2.85 KB
/
typeclasses.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package dtype
type TypeClass int
const (
All TypeClass = iota
Specialized
Addable
Number
Ord
Eq
Unsigned
Signed
SignedNonComplex
Floats
Complexes
FloatComplex
NonComplexNumber
Generatable
maxtypeclass
)
var typeclasses = [...]*typeclass{
allTypes,
specializedTypes,
addableTypes,
numberTypes,
ordTypes,
eqTypes,
unsignedTypes,
signedTypes,
signedNonComplexTypes,
floatTypes,
complexTypes,
floatcmplxTypes,
nonComplexNumberTypes,
generatableTypes,
}
// allTypes for indexing
var allTypes = &typeclass{
name: "τ",
set: []Dtype{
Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, Complex64, Complex128, String, Uintptr, UnsafePointer,
},
}
// specialized types indicate that there are specialized code generated for these types
var specializedTypes = &typeclass{
name: "Specialized",
set: []Dtype{
Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, Complex64, Complex128, String,
},
}
var addableTypes = &typeclass{
name: "Addable",
set: []Dtype{
Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, Complex64, Complex128, String,
},
}
var numberTypes = &typeclass{
name: "Number",
set: []Dtype{
Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, Complex64, Complex128,
},
}
var ordTypes = &typeclass{
name: "Ord",
set: []Dtype{
Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, String,
},
}
var eqTypes = &typeclass{
name: "Eq",
set: []Dtype{
Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, Complex64, Complex128, String, Uintptr, UnsafePointer,
},
}
var unsignedTypes = &typeclass{
name: "Unsigned",
set: []Dtype{Uint, Uint8, Uint16, Uint32, Uint64},
}
var signedTypes = &typeclass{
name: "Signed",
set: []Dtype{
Int, Int8, Int16, Int32, Int64, Float32, Float64, Complex64, Complex128,
},
}
// this typeclass is ever only used by Sub tests
var signedNonComplexTypes = &typeclass{
name: "Signed NonComplex",
set: []Dtype{
Int, Int8, Int16, Int32, Int64, Float32, Float64,
},
}
var floatTypes = &typeclass{
name: "Float",
set: []Dtype{
Float32, Float64,
},
}
var complexTypes = &typeclass{
name: "Complex Numbers",
set: []Dtype{Complex64, Complex128},
}
var floatcmplxTypes = &typeclass{
name: "Real",
set: []Dtype{
Float32, Float64, Complex64, Complex128,
},
}
var nonComplexNumberTypes = &typeclass{
name: "Non complex numbers",
set: []Dtype{
Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64,
},
}
// this typeclass is ever only used by Pow tests
var generatableTypes = &typeclass{
name: "Generatable types",
set: []Dtype{
Bool, Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, String,
},
}