| 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.constants.values; | 5 library dart2js.constants.values; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../core_types.dart'; | 8 import '../core_types.dart'; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../elements/elements.dart' | 10 import '../elements/elements.dart' |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 368 |
| 369 final int hashCode; | 369 final int hashCode; |
| 370 | 370 |
| 371 // TODO(floitsch): cache StringConstants. | 371 // TODO(floitsch): cache StringConstants. |
| 372 // TODO(floitsch): compute hashcode without calling toString() on the | 372 // TODO(floitsch): compute hashcode without calling toString() on the |
| 373 // DartString. | 373 // DartString. |
| 374 StringConstantValue(DartString value) | 374 StringConstantValue(DartString value) |
| 375 : this.primitiveValue = value, | 375 : this.primitiveValue = value, |
| 376 this.hashCode = value.slowToString().hashCode; | 376 this.hashCode = value.slowToString().hashCode; |
| 377 | 377 |
| 378 StringConstantValue.fromString(String value) |
| 379 : this(new DartString.literal(value)); |
| 380 |
| 378 bool get isString => true; | 381 bool get isString => true; |
| 379 | 382 |
| 380 DartType getType(CoreTypes types) => types.stringType; | 383 DartType getType(CoreTypes types) => types.stringType; |
| 381 | 384 |
| 382 bool operator ==(var other) { | 385 bool operator ==(var other) { |
| 383 if (other is !StringConstantValue) return false; | 386 if (other is !StringConstantValue) return false; |
| 384 StringConstantValue otherString = other; | 387 StringConstantValue otherString = other; |
| 385 return hashCode == otherString.hashCode && | 388 return hashCode == otherString.hashCode && |
| 386 primitiveValue == otherString.primitiveValue; | 389 primitiveValue == otherString.primitiveValue; |
| 387 } | 390 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 List<ConstantValue> getDependencies() => const <ConstantValue>[]; | 744 List<ConstantValue> getDependencies() => const <ConstantValue>[]; |
| 742 | 745 |
| 743 @override | 746 @override |
| 744 DartType getType(CoreTypes types) => const DynamicType(); | 747 DartType getType(CoreTypes types) => const DynamicType(); |
| 745 | 748 |
| 746 @override | 749 @override |
| 747 String toStructuredString() => 'NonConstant'; | 750 String toStructuredString() => 'NonConstant'; |
| 748 | 751 |
| 749 @override | 752 @override |
| 750 String unparse() => '>>non-constant<<'; | 753 String unparse() => '>>non-constant<<'; |
| 751 } | 754 } |
| OLD | NEW |