OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.ast_from_binary; | 4 library kernel.ast_from_binary; |
5 | 5 |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
8 | 8 |
9 import '../ast.dart'; | 9 import '../ast.dart'; |
10 import '../transformations/flags.dart'; | 10 import '../transformations/flags.dart'; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 } | 380 } |
381 | 381 |
382 debugPath.add(library.name ?? library.importUri?.toString() ?? 'library'); | 382 debugPath.add(library.name ?? library.importUri?.toString() ?? 'library'); |
383 | 383 |
384 if (shouldWriteData) { | 384 if (shouldWriteData) { |
385 _fillTreeNodeList(library.annotations, readExpression, library); | 385 _fillTreeNodeList(library.annotations, readExpression, library); |
386 } else { | 386 } else { |
387 _skipNodeList(readExpression); | 387 _skipNodeList(readExpression); |
388 } | 388 } |
389 _readLibraryDependencies(library); | 389 _readLibraryDependencies(library); |
| 390 _readLibraryParts(library); |
390 _mergeNamedNodeList(library.typedefs, readTypedef, library); | 391 _mergeNamedNodeList(library.typedefs, readTypedef, library); |
391 _mergeNamedNodeList(library.classes, readClass, library); | 392 _mergeNamedNodeList(library.classes, readClass, library); |
392 _mergeNamedNodeList(library.fields, readField, library); | 393 _mergeNamedNodeList(library.fields, readField, library); |
393 _mergeNamedNodeList(library.procedures, readProcedure, library); | 394 _mergeNamedNodeList(library.procedures, readProcedure, library); |
394 | 395 |
395 debugPath.removeLast(); | 396 debugPath.removeLast(); |
396 _currentLibrary = null; | 397 _currentLibrary = null; |
397 return library; | 398 return library; |
398 } | 399 } |
399 | 400 |
(...skipping 19 matching lines...) Expand all Loading... |
419 Combinator readCombinator() { | 420 Combinator readCombinator() { |
420 var isShow = readUInt() == 1; | 421 var isShow = readUInt() == 1; |
421 var names = readStringReferenceList(); | 422 var names = readStringReferenceList(); |
422 return new Combinator(isShow, names); | 423 return new Combinator(isShow, names); |
423 } | 424 } |
424 | 425 |
425 List<Combinator> readCombinatorList() { | 426 List<Combinator> readCombinatorList() { |
426 return new List<Combinator>.generate(readUInt(), (i) => readCombinator()); | 427 return new List<Combinator>.generate(readUInt(), (i) => readCombinator()); |
427 } | 428 } |
428 | 429 |
| 430 void _readLibraryParts(Library library) { |
| 431 int length = readUInt(); |
| 432 library.parts.length = length; |
| 433 for (int i = 0; i < length; ++i) { |
| 434 var annotations = readExpressionList(); |
| 435 var fileUri = readStringOrNullIfEmpty(); |
| 436 library.parts[i] = new LibraryPart(annotations, fileUri) |
| 437 ..parent = library; |
| 438 } |
| 439 } |
| 440 |
429 Typedef readTypedef() { | 441 Typedef readTypedef() { |
430 var canonicalName = readCanonicalNameReference(); | 442 var canonicalName = readCanonicalNameReference(); |
431 var reference = canonicalName.getReference(); | 443 var reference = canonicalName.getReference(); |
432 Typedef node = reference.node; | 444 Typedef node = reference.node; |
433 bool shouldWriteData = node == null || _isReadingLibraryImplementation; | 445 bool shouldWriteData = node == null || _isReadingLibraryImplementation; |
434 if (node == null) { | 446 if (node == null) { |
435 node = new Typedef(null, null, reference: reference); | 447 node = new Typedef(null, null, reference: reference); |
436 } | 448 } |
437 int fileOffset = readOffset(); | 449 int fileOffset = readOffset(); |
438 String name = readStringReference(); | 450 String name = readStringReference(); |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 ..fileOffset = offset | 1271 ..fileOffset = offset |
1260 ..fileEqualsOffset = fileEqualsOffset; | 1272 ..fileEqualsOffset = fileEqualsOffset; |
1261 } | 1273 } |
1262 | 1274 |
1263 int readOffset() { | 1275 int readOffset() { |
1264 // Offset is saved as unsigned, | 1276 // Offset is saved as unsigned, |
1265 // but actually ranges from -1 and up (thus the -1) | 1277 // but actually ranges from -1 and up (thus the -1) |
1266 return readUInt() - 1; | 1278 return readUInt() - 1; |
1267 } | 1279 } |
1268 } | 1280 } |
OLD | NEW |