OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of masks; | 5 part of masks; |
6 | 6 |
7 class UnionTypeMask implements TypeMask { | 7 class UnionTypeMask implements TypeMask { |
8 final Iterable<FlatTypeMask> disjointMasks; | 8 final Iterable<FlatTypeMask> disjointMasks; |
9 | 9 |
10 static const int MAX_UNION_LENGTH = 4; | 10 static const int MAX_UNION_LENGTH = 4; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 bool needsNoSuchMethodHandling(Selector selector, ClosedWorld closedWorld) { | 328 bool needsNoSuchMethodHandling(Selector selector, ClosedWorld closedWorld) { |
329 return disjointMasks | 329 return disjointMasks |
330 .any((e) => e.needsNoSuchMethodHandling(selector, closedWorld)); | 330 .any((e) => e.needsNoSuchMethodHandling(selector, closedWorld)); |
331 } | 331 } |
332 | 332 |
333 bool canHit(Element element, Selector selector, ClosedWorld closedWorld) { | 333 bool canHit(Element element, Selector selector, ClosedWorld closedWorld) { |
334 return disjointMasks.any((e) => e.canHit(element, selector, closedWorld)); | 334 return disjointMasks.any((e) => e.canHit(element, selector, closedWorld)); |
335 } | 335 } |
336 | 336 |
337 Element locateSingleElement(Selector selector, Compiler compiler) { | 337 Element locateSingleElement(Selector selector, ClosedWorld closedWorld) { |
338 Element candidate; | 338 Element candidate; |
339 for (FlatTypeMask mask in disjointMasks) { | 339 for (FlatTypeMask mask in disjointMasks) { |
340 Element current = mask.locateSingleElement(selector, compiler); | 340 Element current = mask.locateSingleElement(selector, closedWorld); |
341 if (current == null) { | 341 if (current == null) { |
342 return null; | 342 return null; |
343 } else if (candidate == null) { | 343 } else if (candidate == null) { |
344 candidate = current; | 344 candidate = current; |
345 } else if (candidate != current) { | 345 } else if (candidate != current) { |
346 return null; | 346 return null; |
347 } | 347 } |
348 } | 348 } |
349 return candidate; | 349 return candidate; |
350 } | 350 } |
(...skipping 24 matching lines...) Expand all Loading... |
375 int get hashCode { | 375 int get hashCode { |
376 int hashCode = isNullable ? 86 : 43; | 376 int hashCode = isNullable ? 86 : 43; |
377 // The order of the masks in [disjointMasks] must not affect the | 377 // The order of the masks in [disjointMasks] must not affect the |
378 // hashCode. | 378 // hashCode. |
379 for (var mask in disjointMasks) { | 379 for (var mask in disjointMasks) { |
380 hashCode = (hashCode ^ mask.nonNullable().hashCode) & 0x3fffffff; | 380 hashCode = (hashCode ^ mask.nonNullable().hashCode) & 0x3fffffff; |
381 } | 381 } |
382 return hashCode; | 382 return hashCode; |
383 } | 383 } |
384 } | 384 } |
OLD | NEW |