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 Uri libraryUri = | 384 Uri libraryUri = compiler.resolvedUriTranslator.sdkLibraries[libraryName]; |
385 compiler.resolvedUriTranslator.sdkLibraries[libraryName]; | |
386 if (libraryUri != null && libraryUri.scheme != "unsupported") { | 385 if (libraryUri != null && libraryUri.scheme != "unsupported") { |
387 // Dart2js always "supports" importing 'dart:mirrors' but will abort | 386 // Dart2js always "supports" importing 'dart:mirrors' but will abort |
388 // the compilation at a later point if the backend doesn't support | 387 // the compilation at a later point if the backend doesn't support |
389 // mirrors. In this case 'mirrors' should not be in the environment. | 388 // mirrors. In this case 'mirrors' should not be in the environment. |
390 if (libraryName == 'mirrors') { | 389 if (libraryName == 'mirrors') { |
391 return compiler.backend.supportsReflection ? "true" : null; | 390 return compiler.backend.supportsReflection ? "true" : null; |
392 } | 391 } |
393 return "true"; | 392 return "true"; |
394 } | 393 } |
395 return null; | 394 return null; |
396 } | 395 } |
397 } | 396 } |
398 | 397 |
399 /// For every 'dart:' library, a corresponding environment variable is set | 398 /// For every 'dart:' library, a corresponding environment variable is set |
400 /// to "true". The environment variable's name is the concatenation of | 399 /// to "true". The environment variable's name is the concatenation of |
401 /// this prefix and the name (without the 'dart:'. | 400 /// this prefix and the name (without the 'dart:'. |
402 /// | 401 /// |
403 /// For example 'dart:html' has the environment variable 'dart.library.html' set | 402 /// For example 'dart:html' has the environment variable 'dart.library.html' set |
404 /// to "true". | 403 /// to "true". |
405 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; | 404 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; |
OLD | NEW |