Chromium Code Reviews| 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 /// 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_impl; | 6 library front_end.kernel_generator_impl; |
| 7 | 7 |
| 8 import 'dart:async' show Future; | 8 import 'dart:async' show Future; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| 11 import 'package:kernel/kernel.dart' show Program, CanonicalName; | 11 import 'package:kernel/kernel.dart' show Program, CanonicalName; |
| 12 | 12 |
| 13 import 'base/processed_options.dart'; | 13 import 'base/processed_options.dart'; |
| 14 import 'fasta/compiler_command_line.dart' show CompilerCommandLine; | 14 import 'fasta/compiler_command_line.dart' show CompilerCommandLine; |
| 15 import 'fasta/compiler_context.dart' show CompilerContext; | 15 import 'fasta/compiler_context.dart' show CompilerContext; |
| 16 import 'fasta/deprecated_problems.dart' show deprecated_InputError, reportCrash; | 16 import 'fasta/deprecated_problems.dart' show deprecated_InputError, reportCrash; |
| 17 import 'fasta/dill/dill_target.dart' show DillTarget; | 17 import 'fasta/dill/dill_target.dart' show DillTarget; |
| 18 import 'fasta/fasta_codes.dart' show LocatedMessage; | |
| 18 import 'fasta/kernel/kernel_outline_shaker.dart'; | 19 import 'fasta/kernel/kernel_outline_shaker.dart'; |
| 19 import 'fasta/kernel/kernel_target.dart' show KernelTarget; | 20 import 'fasta/kernel/kernel_target.dart' show KernelTarget; |
| 20 import 'fasta/kernel/utils.dart'; | 21 import 'fasta/kernel/utils.dart'; |
| 21 import 'fasta/kernel/verifier.dart'; | 22 import 'fasta/kernel/verifier.dart'; |
| 22 import 'fasta/uri_translator.dart' show UriTranslator; | 23 import 'fasta/uri_translator.dart' show UriTranslator; |
| 23 | 24 |
| 24 /// Implementation for the `package:front_end/kernel_generator.dart` and | 25 /// Implementation for the `package:front_end/kernel_generator.dart` and |
| 25 /// `package:front_end/summary_generator.dart` APIs. | 26 /// `package:front_end/summary_generator.dart` APIs. |
| 26 Future<CompilerResult> generateKernel(ProcessedOptions options, | 27 Future<CompilerResult> generateKernel(ProcessedOptions options, |
| 27 {bool buildSummary: false, | 28 {bool buildSummary: false, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet(); | 141 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet(); |
| 141 trimProgram(program, (uri) => !excluded.contains(uri)); | 142 trimProgram(program, (uri) => !excluded.contains(uri)); |
| 142 } | 143 } |
| 143 if (options.debugDump) { | 144 if (options.debugDump) { |
| 144 printProgramText(program, libraryFilter: kernelTarget.isSourceLibrary); | 145 printProgramText(program, libraryFilter: kernelTarget.isSourceLibrary); |
| 145 } | 146 } |
| 146 options.ticker.logMs("Generated program"); | 147 options.ticker.logMs("Generated program"); |
| 147 } | 148 } |
| 148 | 149 |
| 149 if (kernelTarget.errors.isNotEmpty) { | 150 if (kernelTarget.errors.isNotEmpty) { |
| 150 kernelTarget.errors.forEach(options.deprecated_reportError); | 151 // TODO(ahe): The errors have already been reported via CompilerContext. |
| 152 for (LocatedMessage message in kernelTarget.errors) { | |
|
Siggi Cherem (dart-lang)
2017/07/13 21:05:56
irrelevant style question: why not `kernelTarget.e
ahe
2017/07/14 10:01:07
This is a mistake because of how this code evolved
| |
| 153 options.reportMessage(message); | |
| 154 } | |
| 151 return null; | 155 return null; |
| 152 } | 156 } |
| 153 | 157 |
| 154 return new CompilerResult( | 158 return new CompilerResult( |
| 155 summary: summary, | 159 summary: summary, |
| 156 program: program, | 160 program: program, |
| 157 deps: kernelTarget.loader.getDependencies()); | 161 deps: kernelTarget.loader.getDependencies()); |
| 158 } on deprecated_InputError catch (e) { | 162 } on deprecated_InputError catch (e) { |
| 159 options.deprecated_reportError(e.deprecated_format()); | 163 options.reportMessage(deprecated_InputError.toMessage(e)); |
| 160 return null; | 164 return null; |
| 161 } catch (e, t) { | 165 } catch (e, t) { |
| 162 return reportCrash(e, t); | 166 return reportCrash(e, t); |
| 163 } | 167 } |
| 164 } | 168 } |
| 165 | 169 |
| 166 /// Result object of [generateKernel]. | 170 /// Result object of [generateKernel]. |
| 167 class CompilerResult { | 171 class CompilerResult { |
| 168 /// The generated summary bytes, if it was requested. | 172 /// The generated summary bytes, if it was requested. |
| 169 final List<int> summary; | 173 final List<int> summary; |
| 170 | 174 |
| 171 /// The generated program, if it was requested. | 175 /// The generated program, if it was requested. |
| 172 final Program program; | 176 final Program program; |
| 173 | 177 |
| 174 /// Dependencies traversed by the compiler. Used only for generating | 178 /// Dependencies traversed by the compiler. Used only for generating |
| 175 /// dependency .GN files in the dart-sdk build system. | 179 /// dependency .GN files in the dart-sdk build system. |
| 176 /// Note this might be removed when we switch to compute depencencies without | 180 /// Note this might be removed when we switch to compute depencencies without |
| 177 /// using the compiler itself. | 181 /// using the compiler itself. |
| 178 final List<Uri> deps; | 182 final List<Uri> deps; |
| 179 | 183 |
| 180 CompilerResult({this.summary, this.program, this.deps}); | 184 CompilerResult({this.summary, this.program, this.deps}); |
| 181 } | 185 } |
| OLD | NEW |