| 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 | 4 |
| 5 library fasta; | 5 library fasta; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:convert' show JSON; | 9 import 'dart:convert' show JSON; |
| 10 | 10 |
| 11 import 'dart:io' show BytesBuilder, Directory, File, exitCode; | 11 import 'dart:io' show BytesBuilder, Directory, File, exitCode; |
| 12 | 12 |
| 13 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; | 13 import 'package:kernel/binary/ast_to_binary.dart' |
| 14 show LibraryFilteringBinaryPrinter; |
| 14 | 15 |
| 15 import 'package:kernel/kernel.dart' show Program; | 16 import 'package:kernel/kernel.dart' show Program; |
| 16 | 17 |
| 17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; | 18 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; |
| 18 | 19 |
| 19 import 'compiler_command_line.dart' show CompilerCommandLine; | 20 import 'compiler_command_line.dart' show CompilerCommandLine; |
| 20 | 21 |
| 21 import 'compiler_context.dart' show CompilerContext; | 22 import 'compiler_context.dart' show CompilerContext; |
| 22 | 23 |
| 23 import 'errors.dart' show InputError, formatUnexpected, inputError, reportCrash; | 24 import 'errors.dart' show InputError, formatUnexpected, inputError, reportCrash; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 193 } |
| 193 | 194 |
| 194 if (program.mainMethod == null) { | 195 if (program.mainMethod == null) { |
| 195 return new CompilationResult.error("No 'main' method found."); | 196 return new CompilationResult.error("No 'main' method found."); |
| 196 } | 197 } |
| 197 | 198 |
| 198 // Perform target-specific transformations. | 199 // Perform target-specific transformations. |
| 199 target.performModularTransformations(program); | 200 target.performModularTransformations(program); |
| 200 target.performGlobalTransformations(program); | 201 target.performGlobalTransformations(program); |
| 201 | 202 |
| 202 // Write the program to a list of bytes and return it. | 203 // Write the program to a list of bytes and return it. Do not include |
| 204 // libraries that have a dart: import URI. |
| 205 // |
| 206 // TODO(kmillikin): This is intended to exclude platform libraries that are |
| 207 // included in the Kernel binary platform platform.dill. It does not |
| 208 // necessarily exclude exactly the platform libraries. Use a better |
| 209 // predicate that knows what is included in platform.dill. |
| 203 var sink = new ByteSink(); | 210 var sink = new ByteSink(); |
| 204 new BinaryPrinter(sink).writeProgramFile(program); | 211 bool predicate(Library library) => !library.importUri.isScheme('dart'); |
| 212 new LibraryFilteringBinaryPrinter(sink, predicate) |
| 213 .writeProgramFile(program); |
| 205 return new CompilationResult.ok(sink.builder.takeBytes()); | 214 return new CompilationResult.ok(sink.builder.takeBytes()); |
| 206 } catch (e, s) { | 215 } catch (e, s) { |
| 207 return reportCrash(e, s, fileName); | 216 return reportCrash(e, s, fileName); |
| 208 } | 217 } |
| 209 } | 218 } |
| 210 | 219 |
| 211 Future compilePlatform(Uri patchedSdk, Uri output, | 220 Future compilePlatform(Uri patchedSdk, Uri output, |
| 212 {Uri packages, bool verbose: false}) async { | 221 {Uri packages, bool verbose: false}) async { |
| 213 Ticker ticker = new Ticker(isVerbose: verbose); | 222 Ticker ticker = new Ticker(isVerbose: verbose); |
| 214 await CompilerCommandLine.withGlobalOptions("", [""], (CompilerContext c) { | 223 await CompilerCommandLine.withGlobalOptions("", [""], (CompilerContext c) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 final BytesBuilder builder = new BytesBuilder(); | 263 final BytesBuilder builder = new BytesBuilder(); |
| 255 | 264 |
| 256 void add(List<int> data) { | 265 void add(List<int> data) { |
| 257 builder.add(data); | 266 builder.add(data); |
| 258 } | 267 } |
| 259 | 268 |
| 260 void close() { | 269 void close() { |
| 261 // Nothing to do. | 270 // Nothing to do. |
| 262 } | 271 } |
| 263 } | 272 } |
| OLD | NEW |