| 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 inferrer_visitor; | 5 library inferrer_visitor; |
| 6 | 6 |
| 7 import '../dart2jslib.dart' hide Selector, TypedSelector; | 7 import '../dart2jslib.dart' hide Selector, TypedSelector; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| 11 import '../universe/universe.dart'; | 11 import '../universe/universe.dart'; |
| 12 import '../util/util.dart'; | 12 import '../util/util.dart'; |
| 13 import '../types/types.dart' show TypeMask; | 13 import '../types/types.dart' show TypeMask; |
| 14 import '../types/constants.dart' show computeTypeMask; |
| 14 import 'dart:collection' show IterableMixin; | 15 import 'dart:collection' show IterableMixin; |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * The interface [InferrerVisitor] will use when working on types. | 18 * The interface [InferrerVisitor] will use when working on types. |
| 18 */ | 19 */ |
| 19 abstract class TypeSystem<T> { | 20 abstract class TypeSystem<T> { |
| 20 T get dynamicType; | 21 T get dynamicType; |
| 21 T get nullType; | 22 T get nullType; |
| 22 T get intType; | 23 T get intType; |
| 23 T get uint31Type; | 24 T get uint31Type; |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 744 |
| 744 T visitLiteralBool(LiteralBool node) { | 745 T visitLiteralBool(LiteralBool node) { |
| 745 return types.boolType; | 746 return types.boolType; |
| 746 } | 747 } |
| 747 | 748 |
| 748 T visitLiteralDouble(LiteralDouble node) { | 749 T visitLiteralDouble(LiteralDouble node) { |
| 749 ConstantSystem constantSystem = compiler.backend.constantSystem; | 750 ConstantSystem constantSystem = compiler.backend.constantSystem; |
| 750 // The JavaScript backend may turn this literal into an integer at | 751 // The JavaScript backend may turn this literal into an integer at |
| 751 // runtime. | 752 // runtime. |
| 752 return types.getConcreteTypeFor( | 753 return types.getConcreteTypeFor( |
| 753 constantSystem.createDouble(node.value).computeMask(compiler)); | 754 computeTypeMask(compiler, constantSystem.createDouble(node.value))); |
| 754 } | 755 } |
| 755 | 756 |
| 756 T visitLiteralInt(LiteralInt node) { | 757 T visitLiteralInt(LiteralInt node) { |
| 757 ConstantSystem constantSystem = compiler.backend.constantSystem; | 758 ConstantSystem constantSystem = compiler.backend.constantSystem; |
| 758 // The JavaScript backend may turn this literal into a double at | 759 // The JavaScript backend may turn this literal into a double at |
| 759 // runtime. | 760 // runtime. |
| 760 return types.getConcreteTypeFor( | 761 return types.getConcreteTypeFor( |
| 761 constantSystem.createInt(node.value).computeMask(compiler)); | 762 computeTypeMask(compiler, constantSystem.createInt(node.value))); |
| 762 } | 763 } |
| 763 | 764 |
| 764 T visitLiteralList(LiteralList node) { | 765 T visitLiteralList(LiteralList node) { |
| 765 node.visitChildren(this); | 766 node.visitChildren(this); |
| 766 return node.isConst ? types.constListType : types.growableListType; | 767 return node.isConst ? types.constListType : types.growableListType; |
| 767 } | 768 } |
| 768 | 769 |
| 769 T visitLiteralMap(LiteralMap node) { | 770 T visitLiteralMap(LiteralMap node) { |
| 770 node.visitChildren(this); | 771 node.visitChildren(this); |
| 771 return node.isConst ? types.constMapType : types.mapType; | 772 return node.isConst ? types.constMapType : types.mapType; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 return type; | 1269 return type; |
| 1269 } | 1270 } |
| 1270 | 1271 |
| 1271 T visitCascade(Cascade node) { | 1272 T visitCascade(Cascade node) { |
| 1272 // Ignore the result of the cascade send and return the type of the cascade | 1273 // Ignore the result of the cascade send and return the type of the cascade |
| 1273 // receiver. | 1274 // receiver. |
| 1274 visit(node.expression); | 1275 visit(node.expression); |
| 1275 return cascadeReceiverStack.removeLast(); | 1276 return cascadeReceiverStack.removeLast(); |
| 1276 } | 1277 } |
| 1277 } | 1278 } |
| OLD | NEW |