| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Converters and codecs for converting between JSON and [Info] classes. | 5 /// Converters and codecs for converting between JSON and [Info] classes. |
| 6 part of dart2js_info.info; | 6 part of dart2js_info.info; |
| 7 | 7 |
| 8 // TODO(sigmund): add unit tests. | 8 // TODO(sigmund): add unit tests. |
| 9 class JsonToAllInfoConverter extends Converter<Map, AllInfo> { | 9 class JsonToAllInfoConverter extends Converter<Map, AllInfo> { |
| 10 Map<String, Info> registry; | 10 Map<String, Info> registry; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 'toJsonDuration': info.toJsonDuration, | 293 'toJsonDuration': info.toJsonDuration, |
| 294 'dumpInfoDuration': '${info.dumpInfoDuration}', | 294 'dumpInfoDuration': '${info.dumpInfoDuration}', |
| 295 'noSuchMethodEnabled': info.noSuchMethodEnabled, | 295 'noSuchMethodEnabled': info.noSuchMethodEnabled, |
| 296 'minified': info.minified, | 296 'minified': info.minified, |
| 297 }; | 297 }; |
| 298 } | 298 } |
| 299 | 299 |
| 300 Map _visitBasicInfo(BasicInfo info) { | 300 Map _visitBasicInfo(BasicInfo info) { |
| 301 var res = { | 301 var res = { |
| 302 'id': info.serializedId, | 302 'id': info.serializedId, |
| 303 'kind': _kindToString(info.kind), | 303 'kind': kindToString(info.kind), |
| 304 'name': info.name, | 304 'name': info.name, |
| 305 'size': info.size, | 305 'size': info.size, |
| 306 }; | 306 }; |
| 307 // TODO(sigmund): Omit this also when outputUnit.id == 0 (most code is in | 307 // TODO(sigmund): Omit this also when outputUnit.id == 0 (most code is in |
| 308 // the main output unit by default). | 308 // the main output unit by default). |
| 309 if (info.outputUnit != null) res['outputUnit'] = | 309 if (info.outputUnit != null) res['outputUnit'] = |
| 310 info.outputUnit.serializedId; | 310 info.outputUnit.serializedId; |
| 311 if (info.coverageId != null) res['coverageId'] = info.coverageId; | 311 if (info.coverageId != null) res['coverageId'] = info.coverageId; |
| 312 if (info.parent != null) res['parent'] = info.parent.serializedId; | 312 if (info.parent != null) res['parent'] = info.parent.serializedId; |
| 313 return res; | 313 return res; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 visitTypedef(TypedefInfo info) => _visitBasicInfo(info)..['type'] = info.type; | 418 visitTypedef(TypedefInfo info) => _visitBasicInfo(info)..['type'] = info.type; |
| 419 | 419 |
| 420 visitOutput(OutputUnitInfo info) => | 420 visitOutput(OutputUnitInfo info) => |
| 421 _visitBasicInfo(info)..['imports'] = info.imports; | 421 _visitBasicInfo(info)..['imports'] = info.imports; |
| 422 } | 422 } |
| 423 | 423 |
| 424 class AllInfoJsonCodec extends Codec<AllInfo, Map> { | 424 class AllInfoJsonCodec extends Codec<AllInfo, Map> { |
| 425 final Converter<AllInfo, Map> encoder = new AllInfoToJsonConverter(); | 425 final Converter<AllInfo, Map> encoder = new AllInfoToJsonConverter(); |
| 426 final Converter<Map, AllInfo> decoder = new JsonToAllInfoConverter(); | 426 final Converter<Map, AllInfo> decoder = new JsonToAllInfoConverter(); |
| 427 } | 427 } |
| OLD | NEW |