OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:front_end/compiler_options.dart'; | 7 import 'package:front_end/compiler_options.dart'; |
8 import 'package:front_end/incremental_kernel_generator.dart'; | 8 import 'package:front_end/incremental_kernel_generator.dart'; |
9 import 'package:front_end/memory_file_system.dart'; | 9 import 'package:front_end/memory_file_system.dart'; |
| 10 import 'package:front_end/src/fasta/kernel/utils.dart'; |
10 import 'package:front_end/src/incremental/byte_store.dart'; | 11 import 'package:front_end/src/incremental/byte_store.dart'; |
11 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; | 12 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; |
12 import 'package:kernel/ast.dart'; | 13 import 'package:kernel/ast.dart'; |
13 import 'package:kernel/binary/ast_from_binary.dart'; | 14 import 'package:kernel/binary/ast_from_binary.dart'; |
14 import 'package:kernel/binary/limited_ast_to_binary.dart'; | |
15 import 'package:kernel/text/ast_to_text.dart'; | 15 import 'package:kernel/text/ast_to_text.dart'; |
16 import 'package:kernel/verifier.dart'; | 16 import 'package:kernel/verifier.dart'; |
17 import 'package:test/test.dart'; | 17 import 'package:test/test.dart'; |
18 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 18 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
19 | 19 |
20 import 'src/incremental/mock_sdk.dart'; | 20 import 'src/incremental/mock_sdk.dart'; |
21 | 21 |
22 main() { | 22 main() { |
23 defineReflectiveSuite(() { | 23 defineReflectiveSuite(() { |
24 defineReflectiveTests(IncrementalKernelGeneratorTest); | 24 defineReflectiveTests(IncrementalKernelGeneratorTest); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 '''); | 499 '''); |
500 | 500 |
501 Program program = await getInitialState(bUri); | 501 Program program = await getInitialState(bUri); |
502 | 502 |
503 String initialKernelText; | 503 String initialKernelText; |
504 List<int> bytes; | 504 List<int> bytes; |
505 { | 505 { |
506 Library initialLibrary = _getLibrary(program, bUri); | 506 Library initialLibrary = _getLibrary(program, bUri); |
507 initialKernelText = _getLibraryText(initialLibrary); | 507 initialKernelText = _getLibraryText(initialLibrary); |
508 | 508 |
509 var byteSink = new ByteSink(); | 509 bytes = serializeProgram(program, |
510 var printer = new LimitedBinaryPrinter( | 510 filter: (library) => library.importUri == bUri); |
511 byteSink, (library) => library.importUri == bUri); | |
512 printer.writeProgramFile(program); | |
513 bytes = byteSink.builder.takeBytes(); | |
514 | 511 |
515 // Remove b.dart from the program. | 512 // Remove b.dart from the program. |
516 // So, the program is now ready for re-adding the library. | 513 // So, the program is now ready for re-adding the library. |
517 program.mainMethod = null; | 514 program.mainMethod = null; |
518 program.libraries.remove(initialLibrary); | 515 program.libraries.remove(initialLibrary); |
519 program.root.removeChild(initialLibrary.importUri.toString()); | 516 program.root.removeChild(initialLibrary.importUri.toString()); |
520 } | 517 } |
521 | 518 |
522 // Load b.dart from bytes using the initial name root, so that | 519 // Load b.dart from bytes using the initial name root, so that |
523 // serialized canonical names can be linked to corresponding nodes. | 520 // serialized canonical names can be linked to corresponding nodes. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 throw fail('No library found with URI "$uri"'); | 871 throw fail('No library found with URI "$uri"'); |
875 } | 872 } |
876 | 873 |
877 String _getLibraryText(Library library) { | 874 String _getLibraryText(Library library) { |
878 StringBuffer buffer = new StringBuffer(); | 875 StringBuffer buffer = new StringBuffer(); |
879 new Printer(buffer, syntheticNames: new NameSystem()) | 876 new Printer(buffer, syntheticNames: new NameSystem()) |
880 .writeLibraryFile(library); | 877 .writeLibraryFile(library); |
881 return buffer.toString(); | 878 return buffer.toString(); |
882 } | 879 } |
883 } | 880 } |
OLD | NEW |