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 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
(...skipping 15 matching lines...) Expand all Loading... | |
26 import 'diagnostics/messages.dart' show | 26 import 'diagnostics/messages.dart' show |
27 Message; | 27 Message; |
28 import 'elements/elements.dart' as elements; | 28 import 'elements/elements.dart' as elements; |
29 import 'io/source_file.dart'; | 29 import 'io/source_file.dart'; |
30 import 'platform_configuration.dart' as platform_configuration; | 30 import 'platform_configuration.dart' as platform_configuration; |
31 import 'script.dart'; | 31 import 'script.dart'; |
32 | 32 |
33 const bool forceIncrementalSupport = | 33 const bool forceIncrementalSupport = |
34 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); | 34 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
35 | 35 |
36 /// For every 'dart:' library, a corresponding environment variable is set | |
37 /// to "true". The environment variable's name is the concatenation of | |
38 /// this prefix and the name (without the 'dart:'. | |
39 /// | |
40 /// For example 'dart:html' has the environment variable 'dart.library.html' set | |
41 /// to "true". | |
42 const String dartLibraryEnvironmentPrefix = 'dart.library.'; | |
43 | |
36 /// Locations of the platform descriptor files relative to the library root. | 44 /// Locations of the platform descriptor files relative to the library root. |
37 const String _clientPlatform = "lib/dart_client.platform"; | 45 const String _clientPlatform = "lib/dart_client.platform"; |
38 const String _serverPlatform = "lib/dart_server.platform"; | 46 const String _serverPlatform = "lib/dart_server.platform"; |
39 const String _sharedPlatform = "lib/dart_shared.platform"; | 47 const String _sharedPlatform = "lib/dart_shared.platform"; |
40 const String _dart2dartPlatform = "lib/dart2dart.platform"; | 48 const String _dart2dartPlatform = "lib/dart2dart.platform"; |
41 | 49 |
42 /// Implements the [Compiler] using a [api.CompilerInput] for supplying the | 50 /// Implements the [Compiler] using a [api.CompilerInput] for supplying the |
43 /// sources. | 51 /// sources. |
44 class CompilerImpl extends Compiler { | 52 class CompilerImpl extends Compiler { |
45 api.CompilerInput provider; | 53 api.CompilerInput provider; |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 Future<Packages> callUserPackagesDiscovery(Uri uri) { | 581 Future<Packages> callUserPackagesDiscovery(Uri uri) { |
574 try { | 582 try { |
575 return userPackagesDiscoveryTask.measure( | 583 return userPackagesDiscoveryTask.measure( |
576 () => packagesDiscoveryProvider(uri)); | 584 () => packagesDiscoveryProvider(uri)); |
577 } catch (ex, s) { | 585 } catch (ex, s) { |
578 diagnoseCrashInUserCode('Uncaught exception in package discovery', ex, s); | 586 diagnoseCrashInUserCode('Uncaught exception in package discovery', ex, s); |
579 rethrow; | 587 rethrow; |
580 } | 588 } |
581 } | 589 } |
582 | 590 |
583 fromEnvironment(String name) => environment[name]; | 591 fromEnvironment(String name) { |
592 assert(invariant(NO_LOCATION_SPANNABLE, | |
593 sdkLibraries != null, message: "setupSdk() has not been run")); | |
594 | |
595 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
| |
596 if (!name.startsWith(dartLibraryEnvironmentPrefix)) return null; | |
597 | |
598 String libraryName = name.substring(dartLibraryEnvironmentPrefix.length); | |
599 if (sdkLibraries.containsKey(libraryName)) { | |
600 // Dart2js always "supports" importing 'dart:mirrors' but will abort | |
601 // the compilation at a later point if the backend doesn't support | |
602 // mirrors. In this case 'mirrors' should not be in the environment. | |
603 if (name == dartLibraryEnvironmentPrefix + 'mirrors') { | |
604 return backend.supportsReflection ? "true" : null; | |
605 } | |
606 return "true"; | |
607 } | |
608 return null; | |
609 } | |
584 | 610 |
585 Uri lookupLibraryUri(String libraryName) { | 611 Uri lookupLibraryUri(String libraryName) { |
586 assert(invariant(NO_LOCATION_SPANNABLE, | 612 assert(invariant(NO_LOCATION_SPANNABLE, |
587 sdkLibraries != null, message: "setupSdk() has not been run")); | 613 sdkLibraries != null, message: "setupSdk() has not been run")); |
588 return sdkLibraries[libraryName]; | 614 return sdkLibraries[libraryName]; |
589 } | 615 } |
590 | 616 |
591 Uri resolvePatchUri(String libraryName) { | 617 Uri resolvePatchUri(String libraryName) { |
592 return backend.resolvePatchUri(libraryName, platformConfigUri); | 618 return backend.resolvePatchUri(libraryName, platformConfigUri); |
593 } | 619 } |
594 } | 620 } |
OLD | NEW |