| 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 /// Defines the front-end API for converting source code to Dart Kernel objects. | 5 /// Defines the front-end API for converting source code to Dart Kernel objects. |
| 6 library front_end.kernel_generator; | 6 library front_end.kernel_generator; |
| 7 | 7 |
| 8 import 'compiler_options.dart'; | 8 import 'compiler_options.dart'; |
| 9 import 'dart:async' show Future; | 9 import 'dart:async' show Future; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import 'package:front_end/physical_file_system.dart'; |
| 11 import 'src/fasta/dill/dill_target.dart' show DillTarget; | 12 import 'src/fasta/dill/dill_target.dart' show DillTarget; |
| 12 import 'src/fasta/errors.dart' show InputError; | 13 import 'src/fasta/errors.dart' show InputError; |
| 13 import 'src/fasta/kernel/kernel_target.dart' show KernelTarget; | 14 import 'src/fasta/kernel/kernel_target.dart' show KernelTarget; |
| 14 import 'package:kernel/kernel.dart' show Program; | 15 import 'package:kernel/kernel.dart' show Program; |
| 15 import 'src/fasta/ticker.dart' show Ticker; | 16 import 'src/fasta/ticker.dart' show Ticker; |
| 16 import 'src/fasta/translate_uri.dart' show TranslateUri; | 17 import 'src/fasta/translate_uri.dart' show TranslateUri; |
| 17 import 'src/simple_error.dart'; | 18 import 'src/simple_error.dart'; |
| 18 | 19 |
| 19 /// Generates a kernel representation of the program whose main library is in | 20 /// Generates a kernel representation of the program whose main library is in |
| 20 /// the given [source]. | 21 /// the given [source]. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 return null; | 43 return null; |
| 43 } | 44 } |
| 44 | 45 |
| 45 if (!await fs.entityForUri(source).exists()) { | 46 if (!await fs.entityForUri(source).exists()) { |
| 46 return report("Entry-point file not found: $source"); | 47 return report("Entry-point file not found: $source"); |
| 47 } | 48 } |
| 48 | 49 |
| 49 if (!await validateOptions(options)) return null; | 50 if (!await validateOptions(options)) return null; |
| 50 | 51 |
| 51 try { | 52 try { |
| 52 TranslateUri uriTranslator = | 53 TranslateUri uriTranslator = await TranslateUri.parse( |
| 53 await TranslateUri.parse(null, options.packagesFileUri); | 54 PhysicalFileSystem.instance, null, options.packagesFileUri); |
| 54 | 55 |
| 55 var dillTarget = | 56 var dillTarget = |
| 56 new DillTarget(new Ticker(isVerbose: false), uriTranslator); | 57 new DillTarget(new Ticker(isVerbose: false), uriTranslator); |
| 57 var summary = options.sdkSummary; | 58 var summary = options.sdkSummary; |
| 58 if (summary != null) dillTarget.read(summary); | 59 if (summary != null) dillTarget.read(summary); |
| 59 | 60 |
| 60 var kernelTarget = | 61 var kernelTarget = new KernelTarget( |
| 61 new KernelTarget(dillTarget, uriTranslator, options.strongMode); | 62 options.fileSystem, dillTarget, uriTranslator, options.strongMode); |
| 62 kernelTarget.read(source); | 63 kernelTarget.read(source); |
| 63 | 64 |
| 64 await dillTarget.writeOutline(null); | 65 await dillTarget.writeOutline(null); |
| 65 await kernelTarget.writeOutline(null); | 66 await kernelTarget.writeOutline(null); |
| 66 Program program = await kernelTarget.writeProgram(null); | 67 Program program = await kernelTarget.writeProgram(null); |
| 67 | 68 |
| 68 if (kernelTarget.errors.isNotEmpty) { | 69 if (kernelTarget.errors.isNotEmpty) { |
| 69 kernelTarget.errors.forEach((e) => report('$e')); | 70 kernelTarget.errors.forEach((e) => report('$e')); |
| 70 return null; | 71 return null; |
| 71 } | 72 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 /// TODO(paulberry): would it be better to define a data type in kernel to | 116 /// TODO(paulberry): would it be better to define a data type in kernel to |
| 116 /// represent a bundle of all the libraries in a given build unit? | 117 /// represent a bundle of all the libraries in a given build unit? |
| 117 /// | 118 /// |
| 118 /// TODO(paulberry): does additional information need to be output to allow the | 119 /// TODO(paulberry): does additional information need to be output to allow the |
| 119 /// caller to match up referenced elements to the summary files they were | 120 /// caller to match up referenced elements to the summary files they were |
| 120 /// obtained from? | 121 /// obtained from? |
| 121 Future<Program> kernelForBuildUnit( | 122 Future<Program> kernelForBuildUnit( |
| 122 List<Uri> sources, CompilerOptions options) async { | 123 List<Uri> sources, CompilerOptions options) async { |
| 123 throw new UnimplementedError("kernel for build-unit is not implemented"); | 124 throw new UnimplementedError("kernel for build-unit is not implemented"); |
| 124 } | 125 } |
| OLD | NEW |