| 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 30 matching lines...) Expand all Loading... |
| 41 var target = idMap[dep['id']]; | 41 var target = idMap[dep['id']]; |
| 42 assert(target != null); | 42 assert(target != null); |
| 43 src.uses.add(new DependencyInfo(target, dep['mask'])); | 43 src.uses.add(new DependencyInfo(target, dep['mask'])); |
| 44 } | 44 } |
| 45 }); | 45 }); |
| 46 | 46 |
| 47 json['dependencies']?.forEach((k, deps) { | 47 json['dependencies']?.forEach((k, deps) { |
| 48 result.dependencies[idMap[k]] = deps.map((d) => idMap[d]).toList(); | 48 result.dependencies[idMap[k]] = deps.map((d) => idMap[d]).toList(); |
| 49 }); | 49 }); |
| 50 | 50 |
| 51 result.outputUnits.addAll(json['outputUnits'].map(parseOutputUnit)); |
| 52 |
| 51 result.program = parseProgram(json['program']); | 53 result.program = parseProgram(json['program']); |
| 52 // todo: version, etc | 54 // todo: version, etc |
| 53 return result; | 55 return result; |
| 54 } | 56 } |
| 55 | 57 |
| 58 OutputUnitInfo parseOutputUnit(Map json) { |
| 59 OutputUnitInfo result = parseId(json['id']); |
| 60 result |
| 61 ..name = json['name'] |
| 62 ..size = json['size']; |
| 63 return result; |
| 64 } |
| 65 |
| 56 LibraryInfo parseLibrary(Map json) { | 66 LibraryInfo parseLibrary(Map json) { |
| 57 LibraryInfo result = parseId(json['id']); | 67 LibraryInfo result = parseId(json['id']); |
| 58 result | 68 result |
| 59 ..name = json['name'] | 69 ..name = json['name'] |
| 60 ..uri = Uri.parse(json['canonicalUri']) | 70 ..uri = Uri.parse(json['canonicalUri']) |
| 61 ..outputUnit = parseId(json['outputUnit']) | 71 ..outputUnit = parseId(json['outputUnit']) |
| 62 ..size = json['size']; | 72 ..size = json['size']; |
| 63 for (var child in json['children'].map(parseId)) { | 73 for (var child in json['children'].map(parseId)) { |
| 64 if (child is FunctionInfo) { | 74 if (child is FunctionInfo) { |
| 65 result.topLevelFunctions.add(child); | 75 result.topLevelFunctions.add(child); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 416 |
| 407 visitTypedef(TypedefInfo info) => _visitBasicInfo(info)..['type'] = info.type; | 417 visitTypedef(TypedefInfo info) => _visitBasicInfo(info)..['type'] = info.type; |
| 408 | 418 |
| 409 visitOutput(OutputUnitInfo info) => _visitBasicInfo(info); | 419 visitOutput(OutputUnitInfo info) => _visitBasicInfo(info); |
| 410 } | 420 } |
| 411 | 421 |
| 412 class AllInfoJsonCodec extends Codec<AllInfo, Map> { | 422 class AllInfoJsonCodec extends Codec<AllInfo, Map> { |
| 413 final Converter<AllInfo, Map> encoder = new AllInfoToJsonConverter(); | 423 final Converter<AllInfo, Map> encoder = new AllInfoToJsonConverter(); |
| 414 final Converter<Map, AllInfo> decoder = new JsonToAllInfoConverter(); | 424 final Converter<Map, AllInfo> decoder = new JsonToAllInfoConverter(); |
| 415 } | 425 } |
| OLD | NEW |