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..60754fe913511da6b9bf9615737ffa593d151a22 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")); |
| + |
| + if (environment.containsKey(name)) return environment[name]; |
|
Lasse Reichstein Nielsen
2016/01/11 13:58:35
Could this be:
String result = environment[name];
floitsch
2016/01/11 14:18:29
Tbh I don't think it's that costly to look into th
|
| + if (!name.startsWith(dartLibraryEnvironmentPrefix)) return null; |
| + |
| + 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 null; |
| + } |
| Uri lookupLibraryUri(String libraryName) { |
| assert(invariant(NO_LOCATION_SPANNABLE, |