| 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_to_binary; | 4 library kernel.ast_to_binary; |
| 5 | 5 |
| 6 import '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import '../import_table.dart'; | 7 import '../import_table.dart'; |
| 8 import 'tag.dart'; | 8 import 'tag.dart'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 visitTypeParameter(TypeParameter node) { | 1028 visitTypeParameter(TypeParameter node) { |
| 1029 writeStringReference(node.name ?? ''); | 1029 writeStringReference(node.name ?? ''); |
| 1030 writeNode(node.bound); | 1030 writeNode(node.bound); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 defaultNode(Node node) { | 1033 defaultNode(Node node) { |
| 1034 throw 'Unsupported node: $node'; | 1034 throw 'Unsupported node: $node'; |
| 1035 } | 1035 } |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 typedef bool LibraryFilter(Library _); |
| 1039 |
| 1038 /// A [LibraryFilteringBinaryPrinter] can write a subset of libraries. | 1040 /// A [LibraryFilteringBinaryPrinter] can write a subset of libraries. |
| 1039 /// | 1041 /// |
| 1040 /// This printer writes a Kernel binary but includes only libraries that match a | 1042 /// This printer writes a Kernel binary but includes only libraries that match a |
| 1041 /// predicate. | 1043 /// predicate. |
| 1042 class LibraryFilteringBinaryPrinter extends BinaryPrinter { | 1044 class LibraryFilteringBinaryPrinter extends BinaryPrinter { |
| 1043 final Function predicate; | 1045 final LibraryFilter predicate; |
| 1044 | 1046 |
| 1045 LibraryFilteringBinaryPrinter( | 1047 LibraryFilteringBinaryPrinter( |
| 1046 Sink<List<int>> sink, bool predicate(Library library)) | 1048 Sink<List<int>> sink, bool predicate(Library library)) |
| 1047 : predicate = predicate, | 1049 : predicate = predicate, |
| 1048 super(sink); | 1050 super(sink); |
| 1049 | 1051 |
| 1050 void writeProgramFile(Program program) { | 1052 void writeProgramFile(Program program) { |
| 1051 program.computeCanonicalNames(); | 1053 program.computeCanonicalNames(); |
| 1052 writeMagicWord(Tag.ProgramFile); | 1054 writeMagicWord(Tag.ProgramFile); |
| 1053 _stringIndexer.scanProgram(program); | 1055 _stringIndexer.scanProgram(program); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 void flush() { | 1351 void flush() { |
| 1350 _sink.add(_buffer.sublist(0, length)); | 1352 _sink.add(_buffer.sublist(0, length)); |
| 1351 _buffer = new Uint8List(SIZE); | 1353 _buffer = new Uint8List(SIZE); |
| 1352 length = 0; | 1354 length = 0; |
| 1353 } | 1355 } |
| 1354 | 1356 |
| 1355 void flushAndDestroy() { | 1357 void flushAndDestroy() { |
| 1356 _sink.add(_buffer.sublist(0, length)); | 1358 _sink.add(_buffer.sublist(0, length)); |
| 1357 } | 1359 } |
| 1358 } | 1360 } |
| OLD | NEW |