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'; | |
11 import 'package:front_end/src/incremental/byte_store.dart'; | 10 import 'package:front_end/src/incremental/byte_store.dart'; |
12 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; | 11 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; |
13 import 'package:kernel/ast.dart'; | 12 import 'package:kernel/ast.dart'; |
14 import 'package:kernel/binary/ast_from_binary.dart'; | 13 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 bytes = serializeProgram(program, | 509 var byteSink = new ByteSink(); |
510 filter: (library) => library.importUri == bUri); | 510 var printer = new LimitedBinaryPrinter( |
| 511 byteSink, (library) => library.importUri == bUri); |
| 512 printer.writeProgramFile(program); |
| 513 bytes = byteSink.builder.takeBytes(); |
511 | 514 |
512 // Remove b.dart from the program. | 515 // Remove b.dart from the program. |
513 // So, the program is now ready for re-adding the library. | 516 // So, the program is now ready for re-adding the library. |
514 program.mainMethod = null; | 517 program.mainMethod = null; |
515 program.libraries.remove(initialLibrary); | 518 program.libraries.remove(initialLibrary); |
516 program.root.removeChild(initialLibrary.importUri.toString()); | 519 program.root.removeChild(initialLibrary.importUri.toString()); |
517 } | 520 } |
518 | 521 |
519 // Load b.dart from bytes using the initial name root, so that | 522 // Load b.dart from bytes using the initial name root, so that |
520 // serialized canonical names can be linked to corresponding nodes. | 523 // serialized canonical names can be linked to corresponding nodes. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 throw fail('No library found with URI "$uri"'); | 874 throw fail('No library found with URI "$uri"'); |
872 } | 875 } |
873 | 876 |
874 String _getLibraryText(Library library) { | 877 String _getLibraryText(Library library) { |
875 StringBuffer buffer = new StringBuffer(); | 878 StringBuffer buffer = new StringBuffer(); |
876 new Printer(buffer, syntheticNames: new NameSystem()) | 879 new Printer(buffer, syntheticNames: new NameSystem()) |
877 .writeLibraryFile(library); | 880 .writeLibraryFile(library); |
878 return buffer.toString(); | 881 return buffer.toString(); |
879 } | 882 } |
880 } | 883 } |
OLD | NEW |