Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart (revision 30705) |
| +++ sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart (working copy) |
| @@ -532,14 +532,22 @@ |
| bool isUInt31(info) { |
| return info.type.satisfies(uint31Implementation, compiler); |
| } |
| + bool isPositiveInt(info) { |
| + return info.type.satisfies( |
| + compiler.backend.positiveIntImplementation, compiler); |
| + } |
| String name = selector.name; |
| // We are optimizing for the cases that are not expressed in the |
| // Dart code, for example: |
| // int + int -> int |
| // uint31 | uint31 -> uint31 |
| - if (name == '*' || name == '+' || name == '%' || name == 'remainder') { |
| - if (arguments.hasOnePositionalArgumentThatMatches(isInt)) { |
| + if (name == '*' || name == '+' || name == '%' || name == 'remainder' |
| + || name == '~/') { |
| + if (isPositiveInt(receiver) |
| + && arguments.hasOnePositionalArgumentThatMatches(isPositiveInt)) { |
| + return inferrer.types.positiveIntType; |
| + } else if (arguments.hasOnePositionalArgumentThatMatches(isInt)) { |
| return inferrer.types.intType; |
| } else if (arguments.hasOnePositionalArgumentThatMatches(isEmpty)) { |
| return inferrer.types.nonNullEmptyType; |
| @@ -560,8 +568,9 @@ |
| || arguments.hasOnePositionalArgumentThatMatches(isUInt31)) { |
| return inferrer.types.uint31Type; |
| } |
| + } else if (name == 'unary-') { |
| + return inferrer.types.intType; |
|
kasperl
2013/11/28 09:09:47
Can't you do -0.1? Add a comment on why this is al
ngeoffray
2013/11/28 11:21:47
There's a test at the beginning of this function w
|
| } else if (name == '-') { |
| - if (arguments.hasNoArguments()) return inferrer.types.intType; |
| if (arguments.hasOnePositionalArgumentThatMatches(isInt)) { |
| return inferrer.types.intType; |
| } else if (arguments.hasOnePositionalArgumentThatMatches(isEmpty)) { |
| @@ -569,7 +578,7 @@ |
| } |
| return null; |
| } else if (name == 'abs') { |
| - return arguments.hasNoArguments() ? inferrer.types.intType : null; |
| + return arguments.hasNoArguments() ? inferrer.types.positiveIntType : null; |
| } |
| return null; |
| } |