| 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 'compilation_error.dart'; | 8 import 'compilation_error.dart'; |
| 9 import 'compiler_options.dart'; | 9 import 'compiler_options.dart'; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 /// code for the SDK. | 31 /// code for the SDK. |
| 32 /// | 32 /// |
| 33 /// If summaries are provided in [options], they may be used to speed up | 33 /// If summaries are provided in [options], they may be used to speed up |
| 34 /// analysis. If in addition `compileSdk` is false, this will speed up | 34 /// analysis. If in addition `compileSdk` is false, this will speed up |
| 35 /// compilation, as no source of the sdk will be generated. Note however, that | 35 /// compilation, as no source of the sdk will be generated. Note however, that |
| 36 /// summaries for application code can also speed up analysis, but they will not | 36 /// summaries for application code can also speed up analysis, but they will not |
| 37 /// take the place of Dart source code (since the Dart source code is still | 37 /// take the place of Dart source code (since the Dart source code is still |
| 38 /// needed to access the contents of method bodies). | 38 /// needed to access the contents of method bodies). |
| 39 Future<Program> kernelForProgram(Uri source, CompilerOptions options) async { | 39 Future<Program> kernelForProgram(Uri source, CompilerOptions options) async { |
| 40 var loader = await _createLoader(options, entry: source); | 40 var loader = await _createLoader(options, entry: source); |
| 41 // TODO(sigmund): delete this. At this time we have no need to explicitly list | 41 |
| 42 // VM libraries, since they are normally found by chasing dependencies. | 42 if (options.compileSdk) { |
| 43 // `dart:_builtin` is an exception because it is used by the kernel | 43 options.additionalLibraries.forEach(loader.loadLibrary); |
| 44 // transformers to inform the VM about where the main entrypoint is. This is | |
| 45 // expected to change, and we should be able to remove these lines at that | |
| 46 // point. We check for the presense of `dart:developer` in the targetPatches | |
| 47 // to ensure we only load this library while running on the VM. | |
| 48 if (options.compileSdk && | |
| 49 options.targetPatches.containsKey(Uri.parse('dart:developer'))) { | |
| 50 loader.loadLibrary(Uri.parse('dart:_builtin')); | |
| 51 } | 44 } |
| 45 |
| 52 // TODO(sigmund): merge what we have in loadEverything and the logic below in | 46 // TODO(sigmund): merge what we have in loadEverything and the logic below in |
| 53 // kernelForBuildUnit so there is a single place where we crawl for | 47 // kernelForBuildUnit so there is a single place where we crawl for |
| 54 // dependencies. | 48 // dependencies. |
| 55 Program program = loader.loadProgram(source, compileSdk: options.compileSdk); | 49 Program program = loader.loadProgram(source, compileSdk: options.compileSdk); |
| 56 _reportErrors(loader.errors, options.onError); | 50 _reportErrors(loader.errors, options.onError); |
| 57 return program; | 51 return program; |
| 58 } | 52 } |
| 59 | 53 |
| 60 /// Generates a kernel representation for a build unit. | 54 /// Generates a kernel representation for a build unit. |
| 61 /// | 55 /// |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 183 } |
| 190 | 184 |
| 191 // TODO(sigmund): delete this class. Dartk should not format errors itself, we | 185 // TODO(sigmund): delete this class. Dartk should not format errors itself, we |
| 192 // should just pass them along. | 186 // should just pass them along. |
| 193 class _DartkError implements CompilationError { | 187 class _DartkError implements CompilationError { |
| 194 String get correction => null; | 188 String get correction => null; |
| 195 SourceSpan get span => null; | 189 SourceSpan get span => null; |
| 196 final String message; | 190 final String message; |
| 197 _DartkError(this.message); | 191 _DartkError(this.message); |
| 198 } | 192 } |
| OLD | NEW |