@@ -150,24 +150,58 @@ class Type {
150
150
constexpr bool isFloat () const { return id == f32 || id == f64; }
151
151
constexpr bool isVector () const { return id == v128; };
152
152
constexpr bool isNumber () const { return id >= i32 && id <= v128; }
153
- bool isTuple () const ;
154
153
bool isSingle () const { return isConcrete () && !isTuple (); }
155
- bool isRef () const ;
156
- bool isFunction () const ;
157
- // See literal.h.
158
- bool isData () const ;
154
+
155
+ // Tuples, refs, etc. are quickly handled using isBasic(), leaving the non-
156
+ // basic case for the underlying implementation.
157
+
158
+ bool isTuple () const {
159
+ if (isBasic ()) {
160
+ return false ;
161
+ } else {
162
+ return isNonBasicTuple ();
163
+ }
164
+ }
165
+
166
+ bool isRef () const {
167
+ if (isBasic ()) {
168
+ return false ;
169
+ } else {
170
+ return isNonBasicRef ();
171
+ }
172
+ }
173
+
174
+ bool isFunction () const {
175
+ if (isBasic ()) {
176
+ return false ;
177
+ } else {
178
+ return isNonBasicFunction ();
179
+ }
180
+ }
181
+
182
+ bool isData () const {
183
+ if (isBasic ()) {
184
+ return false ;
185
+ } else {
186
+ return isNonBasicData ();
187
+ }
188
+ }
189
+
159
190
// Checks whether a type is a reference and is nullable. This returns false
160
191
// for a value that is not a reference, that is, for which nullability is
161
192
// irrelevant.
162
193
bool isNullable () const ;
194
+
163
195
// Checks whether a type is a reference and is non-nullable. This returns
164
196
// false for a value that is not a reference, that is, for which nullability
165
197
// is irrelevant. (For that reason, this is only the negation of isNullable()
166
198
// on references, but both return false on non-references.)
167
199
bool isNonNullable () const ;
200
+
201
+ bool isSignature () const ;
202
+
168
203
// Whether this type is only inhabited by null values.
169
204
bool isNull () const ;
170
- bool isSignature () const ;
171
205
bool isStruct () const ;
172
206
bool isArray () const ;
173
207
bool isExn () const ;
@@ -177,6 +211,11 @@ class Type {
177
211
Nullability getNullability () const ;
178
212
179
213
private:
214
+ bool isNonBasicTuple () const ;
215
+ bool isNonBasicRef () const ;
216
+ bool isNonBasicFunction () const ;
217
+ bool isNonBasicData () const ;
218
+
180
219
template <bool (Type::*pred)() const > bool hasPredicate () {
181
220
for (const auto & type : *this ) {
182
221
if ((type.*pred)()) {
0 commit comments