| Index: pkg/compiler/lib/src/serialization/json_serializer.dart
|
| diff --git a/pkg/compiler/lib/src/serialization/json_serializer.dart b/pkg/compiler/lib/src/serialization/json_serializer.dart
|
| index 52e9f9604d6d82e33d714c57e9a4e877deb696e1..ba995bde28babd1f15a71b45549438c199707d20 100644
|
| --- a/pkg/compiler/lib/src/serialization/json_serializer.dart
|
| +++ b/pkg/compiler/lib/src/serialization/json_serializer.dart
|
| @@ -15,8 +15,13 @@ class JsonSerializationEncoder implements SerializationEncoder {
|
| const JsonSerializationEncoder();
|
|
|
| String encode(ObjectValue objectValue) {
|
| - return new JsonEncoder.withIndent(' ')
|
| - .convert(const JsonValueEncoder().convert(objectValue));
|
| + try {
|
| + return new JsonEncoder.withIndent(' ')
|
| + .convert(const JsonValueEncoder().convert(objectValue));
|
| + } on JsonUnsupportedObjectError catch (e) {
|
| + throw 'Error encoding `${e.unsupportedObject}` '
|
| + '(${e.unsupportedObject.runtimeType})';
|
| + }
|
| }
|
| }
|
|
|
| @@ -48,7 +53,19 @@ class JsonValueEncoder implements ValueVisitor {
|
| visitConstant(ConstantValue value, arg) => visit(value.id);
|
|
|
| @override
|
| - double visitDouble(DoubleValue value, arg) => value.value;
|
| + visitDouble(DoubleValue value, arg) {
|
| + double d = value.value;
|
| + if (d.isNaN) {
|
| + return 'NaN';
|
| + } else if (d.isInfinite) {
|
| + if (d.isNegative) {
|
| + return '-Infinity';
|
| + } else {
|
| + return 'Infinity';
|
| + }
|
| + }
|
| + return d;
|
| + }
|
|
|
| @override
|
| visitElement(ElementValue value, arg) => visit(value.id);
|
|
|