| 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 front_end.compiler_options; | 5 library front_end.compiler_options; |
| 6 | 6 |
| 7 import 'package:front_end/src/base/performace_logger.dart'; | 7 import 'package:front_end/src/base/performace_logger.dart'; |
| 8 import 'package:front_end/src/incremental/byte_store.dart'; | 8 import 'package:front_end/src/incremental/byte_store.dart'; |
| 9 import 'package:kernel/target/targets.dart' show Target; | 9 import 'package:kernel/target/targets.dart' show Target; |
| 10 | 10 |
| 11 import 'compilation_error.dart'; | 11 import 'compilation_message.dart'; |
| 12 import 'file_system.dart'; | 12 import 'file_system.dart'; |
| 13 import 'physical_file_system.dart'; | 13 import 'physical_file_system.dart'; |
| 14 | 14 |
| 15 /// Default error handler used by [CompilerOptions.onError]. | |
| 16 void defaultErrorHandler(CompilationError error) => throw error; | |
| 17 | |
| 18 /// Callback used to report errors encountered during compilation. | 15 /// Callback used to report errors encountered during compilation. |
| 19 typedef void ErrorHandler(CompilationError error); | 16 typedef void ErrorHandler(CompilationMessage error); |
| 20 | 17 |
| 21 /// Front-end options relevant to compiler back ends. | 18 /// Front-end options relevant to compiler back ends. |
| 22 /// | 19 /// |
| 23 /// Not intended to be implemented or extended by clients. | 20 /// Not intended to be implemented or extended by clients. |
| 24 class CompilerOptions { | 21 class CompilerOptions { |
| 25 /// The URI of the root of the Dart SDK (typically a "file:" URI). | 22 /// The URI of the root of the Dart SDK (typically a "file:" URI). |
| 26 /// | 23 /// |
| 27 /// If `null`, the SDK will be searched for using | 24 /// If `null`, the SDK will be searched for using |
| 28 /// [Platform.resolvedExecutable] as a starting point. | 25 /// [Platform.resolvedExecutable] as a starting point. |
| 29 Uri sdkRoot; | 26 Uri sdkRoot; |
| 30 | 27 |
| 31 /// Map of `dart:*` libraries to URIs in the [fileSystem]. | 28 /// Map of `dart:*` libraries to URIs in the [fileSystem]. |
| 32 /// | 29 /// |
| 33 /// Keys in the map are the name of the library with no `dart:` prefix, for | 30 /// Keys in the map are the name of the library with no `dart:` prefix, for |
| 34 /// example: | 31 /// example: |
| 35 /// | 32 /// |
| 36 /// {'core': 'file:///sdk/lib/core/core.dart'} | 33 /// {'core': 'file:///sdk/lib/core/core.dart'} |
| 37 /// | 34 /// |
| 38 /// If `null`, the default set of libraries will be loaded from | 35 /// If `null`, the default set of libraries will be loaded from |
| 39 /// `sdkRoot/lib/libraries.json`. | 36 /// `sdkRoot/lib/libraries.json`. |
| 40 // TODO(sigmund): also provide an option to specify the .json file, then | 37 // TODO(sigmund): also provide an option to specify the .json file, then |
| 41 // consider dropping this option. | 38 // consider dropping this option. |
| 42 Map<String, Uri> dartLibraries; | 39 Map<String, Uri> dartLibraries; |
| 43 | 40 |
| 44 /// Callback to which compilation errors should be delivered. | 41 /// Callback to which compilation errors should be delivered. |
| 45 /// | 42 /// |
| 46 /// By default, the first error will be reported by throwing an exception of | 43 /// By default, when no callback is provided, the compiler will report |
| 47 /// type [CompilationError]. | 44 /// messages on the console and will throw when fatal errors are discovered. |
| 48 ErrorHandler onError = defaultErrorHandler; | 45 ErrorHandler onError; |
| 46 |
| 47 /// Whether messages should be reported using the compiler's internal |
| 48 /// reporting mechanism. |
| 49 /// |
| 50 /// If no [onError] handler is provided, the default is true. If an [onError] |
| 51 /// handler is provided, the default is false. Setting this to true will |
| 52 /// ensure that error messages are printed in the console and that fatal |
| 53 /// errors cause an exception. |
| 54 // TODO(sigmund): add also an API for formatting errors and provide a default |
| 55 // formatter. This way user can configure error style in the console and in |
| 56 // generated code that contains error messages. |
| 57 bool reportMessages; |
| 49 | 58 |
| 50 /// URI of the ".packages" file (typically a "file:" URI). | 59 /// URI of the ".packages" file (typically a "file:" URI). |
| 51 /// | 60 /// |
| 52 /// If `null`, the ".packages" file will be found via the standard | 61 /// If `null`, the ".packages" file will be found via the standard |
| 53 /// package_config search algorithm. | 62 /// package_config search algorithm. |
| 54 /// | 63 /// |
| 55 /// If the URI's path component is empty (e.g. `new Uri()`), no packages file | 64 /// If the URI's path component is empty (e.g. `new Uri()`), no packages file |
| 56 /// will be used. | 65 /// will be used. |
| 57 Uri packagesFileUri; | 66 Uri packagesFileUri; |
| 58 | 67 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 199 |
| 191 /// Whether to dump generated programs in a text format (also mainly for | 200 /// Whether to dump generated programs in a text format (also mainly for |
| 192 /// debugging). | 201 /// debugging). |
| 193 /// | 202 /// |
| 194 /// Dumped data is printed in stdout. | 203 /// Dumped data is printed in stdout. |
| 195 bool debugDump = false; | 204 bool debugDump = false; |
| 196 | 205 |
| 197 /// Whether to set the exit code to non-zero if any problem (including | 206 /// Whether to set the exit code to non-zero if any problem (including |
| 198 /// warning, etc.) is encountered during compilation. | 207 /// warning, etc.) is encountered during compilation. |
| 199 bool setExitCodeOnProblem = false; | 208 bool setExitCodeOnProblem = false; |
| 209 |
| 210 /// Whether to embed the input sources in generated kernel programs. |
| 211 /// |
| 212 /// The kernel `Program` API includes a `uriToSource` map field that is used |
| 213 /// to embed the entire contents of the source files. This part of the kernel |
| 214 /// API is in flux and it is not necessary for some tools. Today it is used |
| 215 /// for translating error locations and stack traces in the VM. |
| 216 // TODO(sigmund): change the default. |
| 217 bool embedSourceText = true; |
| 218 |
| 219 /// Whether the compiler should throw as soon as it encounters a |
| 220 /// compilation error. |
| 221 // TODO(sigmund): change the default (issue #30194). |
| 222 bool throwOnErrors = true; |
| 223 |
| 224 /// Whether the compiler should throw as soon as it encounters a |
| 225 /// compilation warning. |
| 226 /// |
| 227 /// Typically used by developers to debug internals of the compiler. |
| 228 bool throwOnWarnings = false; |
| 229 |
| 230 /// Whether the compiler should throw as soon as it encounters a |
| 231 /// compilation nit. |
| 232 /// |
| 233 /// Typically used by developers to debug internals of the compiler. |
| 234 bool throwOnNits = false; |
| 200 } | 235 } |
| OLD | NEW |