Chromium Code Reviews| Index: pkg/compiler/lib/src/apiimpl.dart |
| diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart |
| index 8f81d151dcce9e238914c8b690bb1013e1e5b3d2..75280af1dc4fcccf11a203cd5297fd151f9db1c6 100644 |
| --- a/pkg/compiler/lib/src/apiimpl.dart |
| +++ b/pkg/compiler/lib/src/apiimpl.dart |
| @@ -33,6 +33,14 @@ import 'script.dart'; |
| const bool forceIncrementalSupport = |
| const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
| +/// For every 'dart:' library, a corresponding environment variable is set |
| +/// to "true". The environment variable's name is the concatenation of |
| +/// this prefix and the name (without the 'dart:'. |
| +/// |
| +/// For example 'dart:html' has the environment variable 'dart.library.html' set |
| +/// to "true". |
| +const String dartLibraryEnvironmentPrefix = 'dart.library.'; |
| + |
| /// Locations of the platform descriptor files relative to the library root. |
| const String _clientPlatform = "lib/dart_client.platform"; |
| const String _serverPlatform = "lib/dart_server.platform"; |
| @@ -580,7 +588,25 @@ class CompilerImpl extends Compiler { |
| } |
| } |
| - fromEnvironment(String name) => environment[name]; |
| + fromEnvironment(String name) { |
| + assert(invariant(NO_LOCATION_SPANNABLE, |
| + sdkLibraries != null, message: "setupSdk() has not been run")); |
| + var result = environment[name]; |
| + if (result == null && !environment.containsKey(name) && |
|
sigurdm
2016/01/08 09:45:11
The logic is a bit convoluted.
It might be easier
floitsch
2016/01/08 15:51:01
Refactored so that we have early returns.
|
| + name.startsWith(dartLibraryEnvironmentPrefix)) { |
| + String libraryName = name.substring(dartLibraryEnvironmentPrefix.length); |
| + if (sdkLibraries.containsKey(libraryName)) { |
| + // Dart2js always "supports" importing 'dart:mirrors' but will abort |
| + // the compilation at a later point if the backend doesn't support |
| + // mirrors. In this case 'mirrors' should not be in the environment. |
| + if (name == dartLibraryEnvironmentPrefix + 'mirrors') { |
| + return backend.supportsReflection ? "true" : null; |
| + } |
| + return "true"; |
| + } |
| + } |
| + return result; |
| + } |
| Uri lookupLibraryUri(String libraryName) { |
| assert(invariant(NO_LOCATION_SPANNABLE, |