Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: pkg/compiler/lib/src/serialization/serialization.dart

Issue 2250643002: Support encoding of NaN, infinity and negative infinity. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/serialization/serialization.dart
diff --git a/pkg/compiler/lib/src/serialization/serialization.dart b/pkg/compiler/lib/src/serialization/serialization.dart
index b1418f64907cfc912b62ea9c51bb1a5094980933..27baa606aac3ca56167929915407e4493b5e4b8c 100644
--- a/pkg/compiler/lib/src/serialization/serialization.dart
+++ b/pkg/compiler/lib/src/serialization/serialization.dart
@@ -540,13 +540,21 @@ abstract class AbstractDecoder<K> {
/// If no value is associated with [key], then if [isOptional] is `true`,
/// [defaultValue] is returned, otherwise an exception is thrown.
double getDouble(K key, {bool isOptional: false, double defaultValue}) {
- double value = _map[_getKeyValue(key)];
+ var value = _map[_getKeyValue(key)];
if (value == null) {
if (isOptional || defaultValue != null) {
return defaultValue;
}
throw new StateError("double value '$key' not found in $_map.");
}
+ // Support alternative encoding of NaN and +/- infinity for JSON.
+ if (value == 'NaN') {
+ return double.NAN;
+ } else if (value == '-Infinity') {
+ return double.NEGATIVE_INFINITY;
+ } else if (value == 'Infinity') {
+ return double.INFINITY;
+ }
return value;
}
« no previous file with comments | « pkg/compiler/lib/src/serialization/json_serializer.dart ('k') | tests/compiler/dart2js/serialization/test_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698