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 type_graph_inferrer; | 5 part of type_graph_inferrer; |
6 | 6 |
7 /** | 7 /** |
8 * Common class for all nodes in the graph. The current nodes are: | 8 * Common class for all nodes in the graph. The current nodes are: |
9 * | 9 * |
10 * - Concrete types | 10 * - Concrete types |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 bool isPositiveInt(info) { | 797 bool isPositiveInt(info) { |
798 return info.type.satisfies( | 798 return info.type.satisfies( |
799 classWorld.backend.positiveIntImplementation, classWorld); | 799 classWorld.backend.positiveIntImplementation, classWorld); |
800 } | 800 } |
801 | 801 |
802 String name = selector.name; | 802 String name = selector.name; |
803 // We are optimizing for the cases that are not expressed in the | 803 // We are optimizing for the cases that are not expressed in the |
804 // Dart code, for example: | 804 // Dart code, for example: |
805 // int + int -> int | 805 // int + int -> int |
806 // uint31 | uint31 -> uint31 | 806 // uint31 | uint31 -> uint31 |
807 if (name == '*' || name == '+' || name == '%' || name == 'remainder' || | 807 if (name == '*' || name == '+' ||name == '%' || name == 'remainder' || |
808 name == '~/') { | 808 name == '~/') { |
809 if (isPositiveInt(receiver) && | 809 if (isPositiveInt(receiver) && |
810 arguments.hasOnePositionalArgumentThatMatches(isPositiveInt)) { | 810 arguments.hasOnePositionalArgumentThatMatches(isPositiveInt)) { |
811 return inferrer.types.positiveIntType; | 811 // uint31 + uint31 -> uint32 |
| 812 if (name == '+' && isUInt31(receiver) && |
| 813 arguments.hasOnePositionalArgumentThatMatches(isUInt31)) { |
| 814 return inferrer.types.uint32Type; |
| 815 } else { |
| 816 return inferrer.types.positiveIntType; |
| 817 } |
812 } else if (arguments.hasOnePositionalArgumentThatMatches(isInt)) { | 818 } else if (arguments.hasOnePositionalArgumentThatMatches(isInt)) { |
813 return inferrer.types.intType; | 819 return inferrer.types.intType; |
814 } else if (arguments.hasOnePositionalArgumentThatMatches(isEmpty)) { | 820 } else if (arguments.hasOnePositionalArgumentThatMatches(isEmpty)) { |
815 return inferrer.types.nonNullEmptyType; | 821 return inferrer.types.nonNullEmptyType; |
816 } else { | 822 } else { |
817 return null; | 823 return null; |
818 } | 824 } |
819 } else if (name == '|' || name == '^') { | 825 } else if (name == '|' || name == '^') { |
820 if (isUInt31(receiver) && | 826 if (isUInt31(receiver) && |
821 arguments.hasOnePositionalArgumentThatMatches(isUInt31)) { | 827 arguments.hasOnePositionalArgumentThatMatches(isUInt31)) { |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 T visitConcreteTypeInformation(ConcreteTypeInformation info); | 1553 T visitConcreteTypeInformation(ConcreteTypeInformation info); |
1548 T visitStringLiteralTypeInformation(StringLiteralTypeInformation info); | 1554 T visitStringLiteralTypeInformation(StringLiteralTypeInformation info); |
1549 T visitClosureCallSiteTypeInformation(ClosureCallSiteTypeInformation info); | 1555 T visitClosureCallSiteTypeInformation(ClosureCallSiteTypeInformation info); |
1550 T visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info); | 1556 T visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info); |
1551 T visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info); | 1557 T visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info); |
1552 T visitMemberTypeInformation(MemberTypeInformation info); | 1558 T visitMemberTypeInformation(MemberTypeInformation info); |
1553 T visitParameterTypeInformation(ParameterTypeInformation info); | 1559 T visitParameterTypeInformation(ParameterTypeInformation info); |
1554 T visitClosureTypeInformation(ClosureTypeInformation info); | 1560 T visitClosureTypeInformation(ClosureTypeInformation info); |
1555 T visitAwaitTypeInformation(AwaitTypeInformation info); | 1561 T visitAwaitTypeInformation(AwaitTypeInformation info); |
1556 } | 1562 } |
OLD | NEW |