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 library type_graph_inferrer; | 5 library type_graph_inferrer; |
6 | 6 |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/names.dart' show | 10 import '../common/names.dart' show |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 for (TypeMask mask in masks) { | 546 for (TypeMask mask in masks) { |
547 // Don't do any work on computing unions if we know that after all that | 547 // Don't do any work on computing unions if we know that after all that |
548 // work the result will be `dynamic`. | 548 // work the result will be `dynamic`. |
549 // TODO(sigmund): change to `mask == dynamicType` so we can continue to | 549 // TODO(sigmund): change to `mask == dynamicType` so we can continue to |
550 // track the non-nullable bit. | 550 // track the non-nullable bit. |
551 if (mask.containsAll(classWorld)) return dynamicType; | 551 if (mask.containsAll(classWorld)) return dynamicType; |
552 list.add(mask); | 552 list.add(mask); |
553 } | 553 } |
554 | 554 |
555 TypeMask newType = null; | 555 TypeMask newType = null; |
556 for (TypeMask mask in masks) { | 556 for (TypeMask mask in list) { |
557 newType = newType == null ? mask : newType.union(mask, classWorld); | 557 newType = newType == null ? mask : newType.union(mask, classWorld); |
558 // Likewise - stop early if we already reach dynamic. | 558 // Likewise - stop early if we already reach dynamic. |
559 if (newType.containsAll(classWorld)) return dynamicType; | 559 if (newType.containsAll(classWorld)) return dynamicType; |
560 } | 560 } |
561 | 561 |
562 return newType ?? const TypeMask.nonNullEmpty(); | 562 return newType ?? const TypeMask.nonNullEmpty(); |
563 } | 563 } |
564 } | 564 } |
565 | 565 |
566 /** | 566 /** |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 bool isCalledOnce(Element element) { | 1423 bool isCalledOnce(Element element) { |
1424 if (compiler.disableTypeInference) return false; | 1424 if (compiler.disableTypeInference) return false; |
1425 MemberTypeInformation info = inferrer.types.getInferredTypeOf(element); | 1425 MemberTypeInformation info = inferrer.types.getInferredTypeOf(element); |
1426 return info.isCalledOnce(); | 1426 return info.isCalledOnce(); |
1427 } | 1427 } |
1428 | 1428 |
1429 void clear() { | 1429 void clear() { |
1430 inferrer.clear(); | 1430 inferrer.clear(); |
1431 } | 1431 } |
1432 } | 1432 } |
OLD | NEW |