| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.constant_system; | 5 library dart2js.constant_system; |
| 6 | 6 |
| 7 import '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
| 8 import '../elements/resolution_types.dart'; | 8 import '../elements/resolution_types.dart'; |
| 9 import '../resolution/operators.dart'; | 9 import '../resolution/operators.dart'; |
| 10 import '../tree/dartstring.dart' show DartString; | 10 import '../tree/dartstring.dart' show DartString; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 BinaryOperation get codeUnitAt; | 56 BinaryOperation get codeUnitAt; |
| 57 UnaryOperation get round; | 57 UnaryOperation get round; |
| 58 | 58 |
| 59 const ConstantSystem(); | 59 const ConstantSystem(); |
| 60 | 60 |
| 61 ConstantValue createInt(int i); | 61 ConstantValue createInt(int i); |
| 62 ConstantValue createDouble(double d); | 62 ConstantValue createDouble(double d); |
| 63 ConstantValue createString(DartString string); | 63 ConstantValue createString(DartString string); |
| 64 ConstantValue createBool(bool value); | 64 ConstantValue createBool(bool value); |
| 65 ConstantValue createNull(); | 65 ConstantValue createNull(); |
| 66 ConstantValue createList(InterfaceType type, List<ConstantValue> values); | 66 ConstantValue createList( |
| 67 ResolutionInterfaceType type, List<ConstantValue> values); |
| 67 // TODO(johnniwinther): Remove the need for [compiler]. | 68 // TODO(johnniwinther): Remove the need for [compiler]. |
| 68 ConstantValue createMap(Compiler compiler, InterfaceType type, | 69 ConstantValue createMap(Compiler compiler, ResolutionInterfaceType type, |
| 69 List<ConstantValue> keys, List<ConstantValue> values); | 70 List<ConstantValue> keys, List<ConstantValue> values); |
| 70 // TODO(johnniwinther): Remove the need for [compiler]. | 71 // TODO(johnniwinther): Remove the need for [compiler]. |
| 71 ConstantValue createType(Compiler compiler, DartType type); | 72 ConstantValue createType(Compiler compiler, ResolutionDartType type); |
| 72 // TODO(johnniwinther): Remove the need for [compiler]. | 73 // TODO(johnniwinther): Remove the need for [compiler]. |
| 73 ConstantValue createSymbol(Compiler compiler, String text); | 74 ConstantValue createSymbol(Compiler compiler, String text); |
| 74 | 75 |
| 75 // We need to special case the subtype check for JavaScript constant | 76 // We need to special case the subtype check for JavaScript constant |
| 76 // system because an int is a double at runtime. | 77 // system because an int is a double at runtime. |
| 77 bool isSubtype(DartTypes types, DartType s, DartType t); | 78 bool isSubtype(DartTypes types, ResolutionDartType s, ResolutionDartType t); |
| 78 | 79 |
| 79 /** Returns true if the [constant] is an integer at runtime. */ | 80 /** Returns true if the [constant] is an integer at runtime. */ |
| 80 bool isInt(ConstantValue constant); | 81 bool isInt(ConstantValue constant); |
| 81 /** Returns true if the [constant] is a double at runtime. */ | 82 /** Returns true if the [constant] is a double at runtime. */ |
| 82 bool isDouble(ConstantValue constant); | 83 bool isDouble(ConstantValue constant); |
| 83 /** Returns true if the [constant] is a string at runtime. */ | 84 /** Returns true if the [constant] is a string at runtime. */ |
| 84 bool isString(ConstantValue constant); | 85 bool isString(ConstantValue constant); |
| 85 /** Returns true if the [constant] is a boolean at runtime. */ | 86 /** Returns true if the [constant] is a boolean at runtime. */ |
| 86 bool isBool(ConstantValue constant); | 87 bool isBool(ConstantValue constant); |
| 87 /** Returns true if the [constant] is null at runtime. */ | 88 /** Returns true if the [constant] is null at runtime. */ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return greaterEqual; | 139 return greaterEqual; |
| 139 case BinaryOperatorKind.EQ: | 140 case BinaryOperatorKind.EQ: |
| 140 return equal; | 141 return equal; |
| 141 case BinaryOperatorKind.IF_NULL: | 142 case BinaryOperatorKind.IF_NULL: |
| 142 return ifNull; | 143 return ifNull; |
| 143 default: | 144 default: |
| 144 return null; | 145 return null; |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 } | 148 } |
| OLD | NEW |