| 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 /// Data collected by the dump-info task. | 5 /// Data collected by the dump-info task. |
| 6 library compiler.src.lib.info; | 6 library compiler.src.lib.info; |
| 7 | 7 |
| 8 // Note: this file intentionally doesn't import anything from the compiler. That | 8 // Note: this file intentionally doesn't import anything from the compiler. That |
| 9 // should make it easier for tools to depend on this library. The idea is that | 9 // should make it easier for tools to depend on this library. The idea is that |
| 10 // by using this library, tools can consume the information in the same way it | 10 // by using this library, tools can consume the information in the same way it |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 src.uses.add(new DependencyInfo(target, dep['mask'])); | 234 src.uses.add(new DependencyInfo(target, dep['mask'])); |
| 235 } | 235 } |
| 236 }); | 236 }); |
| 237 | 237 |
| 238 result.program = parseProgram(json['program']); | 238 result.program = parseProgram(json['program']); |
| 239 // todo: version, etc | 239 // todo: version, etc |
| 240 return result; | 240 return result; |
| 241 } | 241 } |
| 242 | 242 |
| 243 LibraryInfo parseLibrary(Map json) { | 243 LibraryInfo parseLibrary(Map json) { |
| 244 var result = parseId(json['id']) | 244 LibraryInfo result = parseId(json['id']); |
| 245 ..name = json['name'] | 245 result..name = json['name'] |
| 246 ..uri = Uri.parse(json['canonicalUri']) | 246 ..uri = Uri.parse(json['canonicalUri']) |
| 247 ..outputUnit = parseId(json['outputUnit']) | 247 ..outputUnit = parseId(json['outputUnit']) |
| 248 ..size = json['size']; | 248 ..size = json['size']; |
| 249 assert(result is LibraryInfo); | |
| 250 for (var child in json['children'].map(parseId)) { | 249 for (var child in json['children'].map(parseId)) { |
| 251 if (child is FunctionInfo) { | 250 if (child is FunctionInfo) { |
| 252 result.topLevelFunctions.add(child); | 251 result.topLevelFunctions.add(child); |
| 253 } else if (child is FieldInfo) { | 252 } else if (child is FieldInfo) { |
| 254 result.topLevelVariables.add(child); | 253 result.topLevelVariables.add(child); |
| 255 } else if (child is ClassInfo) { | 254 } else if (child is ClassInfo) { |
| 256 result.classes.add(child); | 255 result.classes.add(child); |
| 257 } else { | 256 } else { |
| 258 assert(child is TypedefInfo); | 257 assert(child is TypedefInfo); |
| 259 result.typedefs.add(child); | 258 result.typedefs.add(child); |
| 260 } | 259 } |
| 261 } | 260 } |
| 262 return result; | 261 return result; |
| 263 } | 262 } |
| 264 | 263 |
| 265 ClassInfo parseClass(Map json) { | 264 ClassInfo parseClass(Map json) { |
| 266 var result = parseId(json['id']) | 265 ClassInfo result = parseId(json['id']); |
| 267 ..name = json['name'] | 266 result..name = json['name'] |
| 268 ..outputUnit = parseId(json['outputUnit']) | 267 ..outputUnit = parseId(json['outputUnit']) |
| 269 ..size = json['size'] | 268 ..size = json['size'] |
| 270 ..isAbstract = json['modifiers']['abstract'] == true; | 269 ..isAbstract = json['modifiers']['abstract'] == true; |
| 271 assert(result is ClassInfo); | 270 assert(result is ClassInfo); |
| 272 for (var child in json['children'].map(parseId)) { | 271 for (var child in json['children'].map(parseId)) { |
| 273 if (child is FunctionInfo) { | 272 if (child is FunctionInfo) { |
| 274 result.functions.add(child); | 273 result.functions.add(child); |
| 275 } else { | 274 } else { |
| 276 assert(child is FieldInfo); | 275 assert(child is FieldInfo); |
| 277 result.fields.add(child); | 276 result.fields.add(child); |
| 278 } | 277 } |
| 279 } | 278 } |
| 280 return result; | 279 return result; |
| 281 } | 280 } |
| 282 | 281 |
| 283 FieldInfo parseField(Map json) { | 282 FieldInfo parseField(Map json) { |
| 284 return parseId(json['id']) | 283 FieldInfo result = parseId(json['id']); |
| 285 ..name = json['name'] | 284 return result..name = json['name'] |
| 286 ..outputUnit = parseId(json['outputUnit']) | 285 ..outputUnit = parseId(json['outputUnit']) |
| 287 ..size = json['size'] | 286 ..size = json['size'] |
| 288 ..type = json['type'] | 287 ..type = json['type'] |
| 289 ..inferredType = json['inferredType'] | 288 ..inferredType = json['inferredType'] |
| 290 ..code = json['code'] | 289 ..code = json['code'] |
| 291 ..closures = json['children'].map(parseId).toList(); | 290 ..closures = json['children'].map(parseId).toList(); |
| 292 } | 291 } |
| 293 | 292 |
| 294 TypedefInfo parseTypedef(Map json) => parseId(json['id']) | 293 TypedefInfo parseTypedef(Map json) { |
| 295 ..name = json['name'] | 294 TypedefInfo result = parseId(json['id']); |
| 295 return result..name = json['name'] |
| 296 ..type = json['type'] | 296 ..type = json['type'] |
| 297 ..size = 0; | 297 ..size = 0; |
| 298 } |
| 298 | 299 |
| 299 ProgramInfo parseProgram(Map json) => | 300 ProgramInfo parseProgram(Map json) => |
| 300 new ProgramInfo()..size = json['size']; | 301 new ProgramInfo()..size = json['size']; |
| 301 | 302 |
| 302 FunctionInfo parseFunction(Map json) { | 303 FunctionInfo parseFunction(Map json) { |
| 303 return parseId(json['id']) | 304 FunctionInfo result = parseId(json['id']); |
| 304 ..name = json['name'] | 305 return result..name = json['name'] |
| 305 ..outputUnit = parseId(json['outputUnit']) | 306 ..outputUnit = parseId(json['outputUnit']) |
| 306 ..size = json['size'] | 307 ..size = json['size'] |
| 307 ..type = json['type'] | 308 ..type = json['type'] |
| 308 ..returnType = json['returnType'] | 309 ..returnType = json['returnType'] |
| 309 ..inferredReturnType = json['inferredReturnType'] | 310 ..inferredReturnType = json['inferredReturnType'] |
| 310 ..parameters = json['parameters'].map(parseParameter).toList() | 311 ..parameters = json['parameters'].map(parseParameter).toList() |
| 311 ..code = json['code'] | 312 ..code = json['code'] |
| 312 ..sideEffects = json['sideEffects'] | 313 ..sideEffects = json['sideEffects'] |
| 313 ..modifiers = parseModifiers(json['modifiers']) | 314 ..modifiers = parseModifiers(json['modifiers']) |
| 314 ..closures = json['children'].map(parseId).toList(); | 315 ..closures = json['children'].map(parseId).toList(); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 case InfoKind.library: return 'library'; | 633 case InfoKind.library: return 'library'; |
| 633 case InfoKind.clazz: return 'class'; | 634 case InfoKind.clazz: return 'class'; |
| 634 case InfoKind.function: return 'function'; | 635 case InfoKind.function: return 'function'; |
| 635 case InfoKind.field: return 'field'; | 636 case InfoKind.field: return 'field'; |
| 636 case InfoKind.outputUnit: return 'outputUnit'; | 637 case InfoKind.outputUnit: return 'outputUnit'; |
| 637 case InfoKind.typedef: return 'typedef'; | 638 case InfoKind.typedef: return 'typedef'; |
| 638 default: return null; | 639 default: return null; |
| 639 } | 640 } |
| 640 } | 641 } |
| 641 | 642 |
| 642 int _idFromSerializedId(String serialiedId) => | 643 int _idFromSerializedId(String serializedId) => |
| 643 int.parse(serializedId.substring(serializedId.indexOf('/') + 1)); | 644 int.parse(serializedId.substring(serializedId.indexOf('/') + 1)); |
| 644 | 645 |
| 645 String _kindFromSerializedId(String serializedId) => | 646 InfoKind _kindFromSerializedId(String serializedId) => |
| 646 _kindFromString(serializedId.substring(0, serializedId.indexOf('/'))); | 647 _kindFromString(serializedId.substring(0, serializedId.indexOf('/'))); |
| 647 | 648 |
| 648 InfoKind _kindFromString(String kind) { | 649 InfoKind _kindFromString(String kind) { |
| 649 switch(kind) { | 650 switch(kind) { |
| 650 case 'library': return InfoKind.library; | 651 case 'library': return InfoKind.library; |
| 651 case 'class': return InfoKind.clazz; | 652 case 'class': return InfoKind.clazz; |
| 652 case 'function': return InfoKind.function; | 653 case 'function': return InfoKind.function; |
| 653 case 'field': return InfoKind.field; | 654 case 'field': return InfoKind.field; |
| 654 case 'outputUnit': return InfoKind.outputUnit; | 655 case 'outputUnit': return InfoKind.outputUnit; |
| 655 case 'typedef': return InfoKind.typedef; | 656 case 'typedef': return InfoKind.typedef; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 696 } |
| 696 | 697 |
| 697 visitField(FieldInfo info) { | 698 visitField(FieldInfo info) { |
| 698 info.closures.forEach(visitFunction); | 699 info.closures.forEach(visitFunction); |
| 699 } | 700 } |
| 700 | 701 |
| 701 visitFunction(FunctionInfo info) { | 702 visitFunction(FunctionInfo info) { |
| 702 info.closures.forEach(visitFunction); | 703 info.closures.forEach(visitFunction); |
| 703 } | 704 } |
| 704 } | 705 } |
| OLD | NEW |