| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 final Map<String, String> definitions; | 370 final Map<String, String> definitions; |
| 371 | 371 |
| 372 // TODO(sigmund): break the circularity here: Compiler needs an environment to | 372 // TODO(sigmund): break the circularity here: Compiler needs an environment to |
| 373 // initialize the library loader, but the environment here needs to know about | 373 // initialize the library loader, but the environment here needs to know about |
| 374 // how the sdk is set up and about whether the backend supports mirrors. | 374 // how the sdk is set up and about whether the backend supports mirrors. |
| 375 CompilerImpl compiler; | 375 CompilerImpl compiler; |
| 376 | 376 |
| 377 _Environment(this.definitions); | 377 _Environment(this.definitions); |
| 378 | 378 |
| 379 String valueOf(String name) { | 379 String valueOf(String name) { |
| 380 assert(invariant( | 380 assert(compiler.resolvedUriTranslator != null, |
| 381 NO_LOCATION_SPANNABLE, compiler.resolvedUriTranslator != null, | 381 failedAt(NO_LOCATION_SPANNABLE, "setupSdk() has not been run")); |
| 382 message: "setupSdk() has not been run")); | |
| 383 | 382 |
| 384 var result = definitions[name]; | 383 var result = definitions[name]; |
| 385 if (result != null || definitions.containsKey(name)) return result; | 384 if (result != null || definitions.containsKey(name)) return result; |
| 386 if (!name.startsWith(_dartLibraryEnvironmentPrefix)) return null; | 385 if (!name.startsWith(_dartLibraryEnvironmentPrefix)) return null; |
| 387 | 386 |
| 388 String libraryName = name.substring(_dartLibraryEnvironmentPrefix.length); | 387 String libraryName = name.substring(_dartLibraryEnvironmentPrefix.length); |
| 389 | 388 |
| 390 // Private libraries are not exposed to the users. | 389 // Private libraries are not exposed to the users. |
| 391 if (libraryName.startsWith("_")) return null; | 390 if (libraryName.startsWith("_")) return null; |
| 392 | 391 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 417 } | 416 } |
| 418 } | 417 } |
| 419 | 418 |
| 420 /// For every 'dart:' library, a corresponding environment variable is set | 419 /// For every 'dart:' library, a corresponding environment variable is set |
| 421 /// to "true". The environment variable's name is the concatenation of | 420 /// to "true". The environment variable's name is the concatenation of |
| 422 /// this prefix and the name (without the 'dart:'. | 421 /// this prefix and the name (without the 'dart:'. |
| 423 /// | 422 /// |
| 424 /// For example 'dart:html' has the environment variable 'dart.library.html' set | 423 /// For example 'dart:html' has the environment variable 'dart.library.html' set |
| 425 /// to "true". | 424 /// to "true". |
| 426 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; | 425 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; |
| OLD | NEW |