OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:package_config/packages.dart'; | 9 import 'package:package_config/packages.dart'; |
10 import 'package:package_config/packages_file.dart' as pkgs; | 10 import 'package:package_config/packages_file.dart' as pkgs; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 var result = definitions[name]; | 375 var result = definitions[name]; |
376 if (result != null || definitions.containsKey(name)) return result; | 376 if (result != null || definitions.containsKey(name)) return result; |
377 if (!name.startsWith(_dartLibraryEnvironmentPrefix)) return null; | 377 if (!name.startsWith(_dartLibraryEnvironmentPrefix)) return null; |
378 | 378 |
379 String libraryName = name.substring(_dartLibraryEnvironmentPrefix.length); | 379 String libraryName = name.substring(_dartLibraryEnvironmentPrefix.length); |
380 | 380 |
381 // Private libraries are not exposed to the users. | 381 // Private libraries are not exposed to the users. |
382 if (libraryName.startsWith("_")) return null; | 382 if (libraryName.startsWith("_")) return null; |
383 | 383 |
384 if (compiler.resolvedUriTranslator.sdkLibraries.containsKey(libraryName)) { | 384 Uri libraryUri = |
| 385 compiler.resolvedUriTranslator.sdkLibraries[libraryName]; |
| 386 if (libraryUri != null && libraryUri.scheme != "unsupported") { |
385 // Dart2js always "supports" importing 'dart:mirrors' but will abort | 387 // Dart2js always "supports" importing 'dart:mirrors' but will abort |
386 // the compilation at a later point if the backend doesn't support | 388 // the compilation at a later point if the backend doesn't support |
387 // mirrors. In this case 'mirrors' should not be in the environment. | 389 // mirrors. In this case 'mirrors' should not be in the environment. |
388 if (libraryName == 'mirrors') { | 390 if (libraryName == 'mirrors') { |
389 return compiler.backend.supportsReflection ? "true" : null; | 391 return compiler.backend.supportsReflection ? "true" : null; |
390 } | 392 } |
391 return "true"; | 393 return "true"; |
392 } | 394 } |
393 return null; | 395 return null; |
394 } | 396 } |
395 } | 397 } |
396 | 398 |
397 /// For every 'dart:' library, a corresponding environment variable is set | 399 /// For every 'dart:' library, a corresponding environment variable is set |
398 /// to "true". The environment variable's name is the concatenation of | 400 /// to "true". The environment variable's name is the concatenation of |
399 /// this prefix and the name (without the 'dart:'. | 401 /// this prefix and the name (without the 'dart:'. |
400 /// | 402 /// |
401 /// For example 'dart:html' has the environment variable 'dart.library.html' set | 403 /// For example 'dart:html' has the environment variable 'dart.library.html' set |
402 /// to "true". | 404 /// to "true". |
403 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; | 405 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; |
OLD | NEW |