Chromium Code Reviews| 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 dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| 11 import 'closure.dart' as closureMapping show ClosureTask; | 11 import 'closure.dart' as closureMapping show ClosureTask; |
| 12 import 'common.dart'; | |
| 13 import 'common/backend_api.dart' show Backend; | 12 import 'common/backend_api.dart' show Backend; |
| 14 import 'common/codegen.dart' show CodegenImpact, CodegenWorkItem; | 13 import 'common/codegen.dart' show CodegenWorkItem; |
| 14 import 'common/names.dart' show Selectors; | |
| 15 import 'common/names.dart' show Identifiers, Uris; | 15 import 'common/names.dart' show Identifiers, Uris; |
| 16 import 'common/registry.dart' show EagerRegistry, Registry; | 16 import 'common/registry.dart' show EagerRegistry, Registry; |
| 17 import 'common/resolution.dart' | 17 import 'common/resolution.dart' |
| 18 show Parsing, Resolution, ResolutionWorkItem, ResolutionImpact; | 18 show Parsing, Resolution, ResolutionWorkItem, ResolutionImpact; |
| 19 import 'common/tasks.dart' show CompilerTask, GenericTask; | 19 import 'common/tasks.dart' show CompilerTask, GenericTask; |
| 20 import 'common/work.dart' show ItemCompilationContext, WorkItem; | 20 import 'common/work.dart' show ItemCompilationContext, WorkItem; |
| 21 import 'common.dart'; | |
| 21 import 'compile_time_constants.dart'; | 22 import 'compile_time_constants.dart'; |
| 22 import 'constants/values.dart'; | 23 import 'constants/values.dart'; |
| 23 import 'core_types.dart' show CoreClasses, CoreTypes; | 24 import 'core_types.dart' show CoreClasses, CoreTypes; |
| 24 import 'dart_backend/dart_backend.dart' as dart_backend; | 25 import 'dart_backend/dart_backend.dart' as dart_backend; |
| 25 import 'dart_types.dart' show DartType, DynamicType, InterfaceType, Types; | 26 import 'dart_types.dart' show DartType, DynamicType, InterfaceType, Types; |
| 26 import 'deferred_load.dart' show DeferredLoadTask, OutputUnit; | 27 import 'deferred_load.dart' show DeferredLoadTask; |
| 27 import 'diagnostics/code_location.dart'; | 28 import 'diagnostics/code_location.dart'; |
| 28 import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter; | 29 import 'diagnostics/diagnostic_listener.dart' show DiagnosticReporter; |
| 29 import 'diagnostics/invariant.dart' show REPORT_EXCESS_RESOLUTION; | 30 import 'diagnostics/invariant.dart' show REPORT_EXCESS_RESOLUTION; |
| 30 import 'diagnostics/messages.dart' show Message, MessageTemplate; | 31 import 'diagnostics/messages.dart' show Message, MessageTemplate; |
| 31 import 'dump_info.dart' show DumpInfoTask; | 32 import 'dump_info.dart' show DumpInfoTask; |
| 32 import 'elements/elements.dart'; | 33 import 'elements/elements.dart'; |
| 33 import 'elements/modelx.dart' | 34 import 'elements/modelx.dart' show ErroneousElementX; |
| 34 show | |
| 35 ErroneousElementX, | |
| 36 ClassElementX, | |
| 37 CompilationUnitElementX, | |
| 38 DeferredLoaderGetterElementX, | |
| 39 MethodElementX, | |
| 40 LibraryElementX, | |
| 41 PrefixElementX; | |
| 42 import 'enqueue.dart' | 35 import 'enqueue.dart' |
| 43 show | 36 show |
| 44 CodegenEnqueuer, | 37 CodegenEnqueuer, |
| 45 Enqueuer, | 38 Enqueuer, |
| 46 EnqueueTask, | 39 EnqueueTask, |
| 47 ResolutionEnqueuer, | 40 ResolutionEnqueuer, |
| 48 QueueFilter; | 41 QueueFilter; |
| 49 import 'environment.dart'; | 42 import 'environment.dart'; |
| 50 import 'id_generator.dart'; | 43 import 'id_generator.dart'; |
| 51 import 'io/source_information.dart' show SourceInformation; | 44 import 'io/source_information.dart' show SourceInformation; |
| 52 import 'js_backend/backend_helpers.dart' as js_backend show BackendHelpers; | 45 import 'js_backend/backend_helpers.dart' as js_backend show BackendHelpers; |
| 53 import 'js_backend/js_backend.dart' as js_backend show JavaScriptBackend; | 46 import 'js_backend/js_backend.dart' as js_backend show JavaScriptBackend; |
| 54 import 'library_loader.dart' | 47 import 'library_loader.dart' |
| 55 show | 48 show |
| 56 ElementScanner, | 49 ElementScanner, |
| 57 LibraryLoader, | 50 LibraryLoader, |
| 58 LibraryLoaderTask, | 51 LibraryLoaderTask, |
| 59 LoadedLibraries, | 52 LoadedLibraries, |
| 60 LibraryLoaderListener, | 53 LibraryLoaderListener, |
| 61 ResolvedUriTranslator, | |
| 62 ScriptLoader; | 54 ScriptLoader; |
| 63 import 'mirrors_used.dart' show MirrorUsageAnalyzerTask; | 55 import 'mirrors_used.dart' show MirrorUsageAnalyzerTask; |
| 64 import 'common/names.dart' show Selectors; | |
| 65 import 'null_compiler_output.dart' show NullCompilerOutput, NullSink; | 56 import 'null_compiler_output.dart' show NullCompilerOutput, NullSink; |
| 66 import 'options.dart' show CompilerOptions, DiagnosticOptions, ParserOptions; | 57 import 'options.dart' show CompilerOptions, DiagnosticOptions, ParserOptions; |
| 67 import 'parser/diet_parser_task.dart' show DietParserTask; | 58 import 'parser/diet_parser_task.dart' show DietParserTask; |
| 68 import 'parser/element_listener.dart' show ScannerOptions; | 59 import 'parser/element_listener.dart' show ScannerOptions; |
| 69 import 'parser/parser_task.dart' show ParserTask; | 60 import 'parser/parser_task.dart' show ParserTask; |
| 70 import 'patch_parser.dart' show PatchParserTask; | 61 import 'patch_parser.dart' show PatchParserTask; |
| 71 import 'resolution/registry.dart' show ResolutionRegistry; | 62 import 'resolution/registry.dart' show ResolutionRegistry; |
| 72 import 'resolution/resolution.dart' show ResolverTask; | 63 import 'resolution/resolution.dart' show ResolverTask; |
| 73 import 'resolution/tree_elements.dart' show TreeElementMapping; | 64 import 'resolution/tree_elements.dart' show TreeElementMapping; |
| 65 import 'resolved_uri_translator.dart'; | |
| 74 import 'scanner/scanner_task.dart' show ScannerTask; | 66 import 'scanner/scanner_task.dart' show ScannerTask; |
| 67 import 'script.dart' show Script; | |
| 75 import 'serialization/task.dart' show SerializationTask; | 68 import 'serialization/task.dart' show SerializationTask; |
| 76 import 'script.dart' show Script; | |
| 77 import 'ssa/nodes.dart' show HInstruction; | 69 import 'ssa/nodes.dart' show HInstruction; |
| 78 import 'tracer.dart' show Tracer; | |
| 79 import 'tokens/token.dart' show StringToken, Token, TokenPair; | 70 import 'tokens/token.dart' show StringToken, Token, TokenPair; |
| 80 import 'tokens/token_map.dart' show TokenMap; | 71 import 'tokens/token_map.dart' show TokenMap; |
| 72 import 'tracer.dart' show Tracer; | |
| 81 import 'tree/tree.dart' show Node, TypeAnnotation; | 73 import 'tree/tree.dart' show Node, TypeAnnotation; |
| 82 import 'typechecker.dart' show TypeCheckerTask; | 74 import 'typechecker.dart' show TypeCheckerTask; |
| 83 import 'types/types.dart' as ti; | 75 import 'types/types.dart' as ti; |
| 84 import 'universe/call_structure.dart' show CallStructure; | 76 import 'universe/call_structure.dart' show CallStructure; |
| 85 import 'universe/selector.dart' show Selector; | 77 import 'universe/selector.dart' show Selector; |
| 86 import 'universe/universe.dart' show Universe; | 78 import 'universe/universe.dart' show Universe; |
| 87 import 'universe/use.dart' show StaticUse; | 79 import 'universe/use.dart' show StaticUse; |
| 88 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; | 80 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; |
| 89 import 'util/util.dart' show Link, Setlet; | 81 import 'util/util.dart' show Link, Setlet; |
| 90 import 'world.dart' show World; | 82 import 'world.dart' show World; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 * If true, stop compilation after type inference is complete. Used for | 126 * If true, stop compilation after type inference is complete. Used for |
| 135 * debugging and testing purposes only. | 127 * debugging and testing purposes only. |
| 136 */ | 128 */ |
| 137 bool stopAfterTypeInference = false; | 129 bool stopAfterTypeInference = false; |
| 138 | 130 |
| 139 /// Output provider from user of Compiler API. | 131 /// Output provider from user of Compiler API. |
| 140 api.CompilerOutput userOutputProvider; | 132 api.CompilerOutput userOutputProvider; |
| 141 | 133 |
| 142 List<Uri> librariesToAnalyzeWhenRun; | 134 List<Uri> librariesToAnalyzeWhenRun; |
| 143 | 135 |
| 144 /// The set of platform libraries reported as unsupported. | 136 ResolvedUriTranslator get resolvedUriTranslator; |
| 145 /// | |
| 146 /// For instance when importing 'dart:io' without '--categories=Server'. | |
| 147 Set<Uri> disallowedLibraryUris = new Setlet<Uri>(); | |
| 148 | 137 |
| 149 Tracer tracer; | 138 Tracer tracer; |
| 150 | 139 |
| 151 CompilerTask measuredTask; | 140 CompilerTask measuredTask; |
| 152 LibraryElement coreLibrary; | 141 LibraryElement coreLibrary; |
| 153 LibraryElement asyncLibrary; | 142 LibraryElement asyncLibrary; |
| 154 | 143 |
| 155 LibraryElement mainApp; | 144 LibraryElement mainApp; |
| 156 FunctionElement mainFunction; | 145 FunctionElement mainFunction; |
| 157 | 146 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 throw new ArgumentError('--dump-info is not supported for dart2dart.'); | 322 throw new ArgumentError('--dump-info is not supported for dart2dart.'); |
| 334 } | 323 } |
| 335 } | 324 } |
| 336 | 325 |
| 337 if (options.dumpInfo && options.useStartupEmitter) { | 326 if (options.dumpInfo && options.useStartupEmitter) { |
| 338 throw new ArgumentError( | 327 throw new ArgumentError( |
| 339 '--dump-info is not supported with the fast startup emitter'); | 328 '--dump-info is not supported with the fast startup emitter'); |
| 340 } | 329 } |
| 341 | 330 |
| 342 tasks = [ | 331 tasks = [ |
| 343 dietParser = new DietParserTask(this, parsing.parserOptions, idGenerator), | 332 dietParser = new DietParserTask( |
| 333 this, parsing.parserOptions, idGenerator, backend, reporter), | |
| 344 scanner = createScannerTask(), | 334 scanner = createScannerTask(), |
| 345 serialization = new SerializationTask(this), | 335 serialization = new SerializationTask(this), |
| 346 libraryLoader = new LibraryLoaderTask( | 336 libraryLoader = new LibraryLoaderTask( |
| 347 this, | 337 this, |
| 348 new _ResolvedUriTranslator(this), | 338 new _ResolvedUriTranslator(this), |
| 349 new _ScriptLoader(this), | 339 new _ScriptLoader(this), |
| 350 new _ElementScanner(scanner), | 340 new _ElementScanner(scanner), |
| 351 this.serialization, | 341 this.serialization, |
| 352 this, | 342 this, |
| 353 environment), | 343 environment), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 @deprecated | 385 @deprecated |
| 396 int getNextFreeId() => idGenerator.getNextFreeId(); | 386 int getNextFreeId() => idGenerator.getNextFreeId(); |
| 397 | 387 |
| 398 void unimplemented(Spannable spannable, String methodName) { | 388 void unimplemented(Spannable spannable, String methodName) { |
| 399 reporter.internalError(spannable, "$methodName not implemented."); | 389 reporter.internalError(spannable, "$methodName not implemented."); |
| 400 } | 390 } |
| 401 | 391 |
| 402 // Compiles the dart script at [uri]. | 392 // Compiles the dart script at [uri]. |
| 403 // | 393 // |
| 404 // The resulting future will complete with true if the compilation | 394 // The resulting future will complete with true if the compilation |
| 405 // succeded. | 395 // succeeded. |
| 406 Future<bool> run(Uri uri) { | 396 Future<bool> run(Uri uri) { |
| 407 totalCompileTime.start(); | 397 totalCompileTime.start(); |
| 408 | 398 |
| 409 return new Future.sync(() => runInternal(uri)) | 399 return new Future.sync(() => runInternal(uri)) |
| 410 .catchError((error) => _reporter.onError(uri, error)) | 400 .catchError((error) => _reporter.onError(uri, error)) |
| 411 .whenComplete(() { | 401 .whenComplete(() { |
| 412 tracer.close(); | 402 tracer.close(); |
| 413 totalCompileTime.stop(); | 403 totalCompileTime.stop(); |
| 414 }).then((_) { | 404 }).then((_) { |
| 415 return !compilationFailed; | 405 return !compilationFailed; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 if (chainCount > chainLimit) { | 507 if (chainCount > chainLimit) { |
| 518 // Assume there are more import chains. | 508 // Assume there are more import chains. |
| 519 importChains.add('...'); | 509 importChains.add('...'); |
| 520 return false; | 510 return false; |
| 521 } | 511 } |
| 522 return true; | 512 return true; |
| 523 }); | 513 }); |
| 524 return importChains; | 514 return importChains; |
| 525 } | 515 } |
| 526 | 516 |
| 527 /// Register that [uri] was recognized but disallowed as a dependency. | |
| 528 /// | |
| 529 /// For instance import of 'dart:io' without '--categories=Server'. | |
| 530 void registerDisallowedLibraryUse(Uri uri) { | |
| 531 disallowedLibraryUris.add(uri); | |
| 532 } | |
| 533 | |
| 534 /// This method is called when all new libraries loaded through | 517 /// This method is called when all new libraries loaded through |
| 535 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports | 518 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports |
| 536 /// have been computed. | 519 /// have been computed. |
| 537 /// | 520 /// |
| 538 /// [loadedLibraries] contains the newly loaded libraries. | 521 /// [loadedLibraries] contains the newly loaded libraries. |
| 539 /// | 522 /// |
| 540 /// The method returns a [Future] allowing for the loading of additional | 523 /// The method returns a [Future] allowing for the loading of additional |
| 541 /// libraries. | 524 /// libraries. |
| 542 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 525 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 543 return new Future.sync(() { | 526 return new Future.sync(() { |
| 544 for (Uri uri in disallowedLibraryUris) { | 527 var disallowedLibraries = |
| 528 resolvedUriTranslator?.disallowedLibraryUris ?? const <Uri>[]; | |
| 529 for (Uri uri in disallowedLibraries) { | |
| 545 if (loadedLibraries.containsLibrary(uri)) { | 530 if (loadedLibraries.containsLibrary(uri)) { |
| 546 Set<String> importChains = | 531 Set<String> importChains = |
| 547 computeImportChainsFor(loadedLibraries, uri); | 532 computeImportChainsFor(loadedLibraries, uri); |
| 548 reporter.reportInfo( | 533 reporter.reportInfo( |
| 549 NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { | 534 NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { |
| 550 'uri': uri, | 535 'uri': uri, |
| 551 'importChain': importChains | 536 'importChain': importChains |
| 552 .join(MessageTemplate.DISALLOWED_LIBRARY_IMPORT_PADDING) | 537 .join(MessageTemplate.DISALLOWED_LIBRARY_IMPORT_PADDING) |
| 553 }); | 538 }); |
| 554 } | 539 } |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1105 return !BENIGN_ERRORS.contains(message.message.kind); | 1090 return !BENIGN_ERRORS.contains(message.message.kind); |
| 1106 } | 1091 } |
| 1107 | 1092 |
| 1108 void fatalDiagnosticReported(DiagnosticMessage message, | 1093 void fatalDiagnosticReported(DiagnosticMessage message, |
| 1109 List<DiagnosticMessage> infos, api.Diagnostic kind) { | 1094 List<DiagnosticMessage> infos, api.Diagnostic kind) { |
| 1110 if (markCompilationAsFailed(message, kind)) { | 1095 if (markCompilationAsFailed(message, kind)) { |
| 1111 compilationFailed = true; | 1096 compilationFailed = true; |
| 1112 } | 1097 } |
| 1113 } | 1098 } |
| 1114 | 1099 |
| 1115 // TODO(sigmund): move this dart doc somewhere else too. | |
| 1116 /** | |
| 1117 * Translates the [resolvedUri] into a readable URI. | |
| 1118 * | |
| 1119 * The [importingLibrary] holds the library importing [resolvedUri] or | |
| 1120 * [:null:] if [resolvedUri] is loaded as the main library. The | |
| 1121 * [importingLibrary] is used to grant access to internal libraries from | |
| 1122 * platform libraries and patch libraries. | |
| 1123 * | |
| 1124 * If the [resolvedUri] is not accessible from [importingLibrary], this method | |
| 1125 * is responsible for reporting errors. | |
| 1126 * | |
| 1127 * See [LibraryLoader] for terminology on URIs. | |
| 1128 */ | |
| 1129 Uri translateResolvedUri( | |
| 1130 LibraryElement importingLibrary, Uri resolvedUri, Spannable spannable) { | |
| 1131 unimplemented(importingLibrary, 'Compiler.translateResolvedUri'); | |
| 1132 return null; | |
| 1133 } | |
| 1134 | |
| 1135 /** | 1100 /** |
| 1136 * Reads the script specified by the [readableUri]. | 1101 * Reads the script specified by the [readableUri]. |
| 1137 * | 1102 * |
| 1138 * See [LibraryLoader] for terminology on URIs. | 1103 * See [LibraryLoader] for terminology on URIs. |
| 1139 */ | 1104 */ |
| 1140 Future<Script> readScript(Uri readableUri, [Spannable node]) { | 1105 Future<Script> readScript(Uri readableUri, [Spannable node]) { |
| 1141 unimplemented(node, 'Compiler.readScript'); | 1106 unimplemented(node, 'Compiler.readScript'); |
| 1142 return null; | 1107 return null; |
| 1143 } | 1108 } |
| 1144 | 1109 |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1904 ResolvedAst getResolvedAst(Element element) { | 1869 ResolvedAst getResolvedAst(Element element) { |
| 1905 if (hasResolvedAst(element)) { | 1870 if (hasResolvedAst(element)) { |
| 1906 AstElement astElement = element; | 1871 AstElement astElement = element; |
| 1907 return astElement.resolvedAst; | 1872 return astElement.resolvedAst; |
| 1908 } | 1873 } |
| 1909 assert(invariant(element, hasResolvedAst(element), | 1874 assert(invariant(element, hasResolvedAst(element), |
| 1910 message: "ResolvedAst not available for $element.")); | 1875 message: "ResolvedAst not available for $element.")); |
| 1911 return null; | 1876 return null; |
| 1912 } | 1877 } |
| 1913 | 1878 |
| 1914 | |
| 1915 @override | 1879 @override |
| 1916 bool hasResolutionImpact(Element element) { | 1880 bool hasResolutionImpact(Element element) { |
| 1917 return _resolutionImpactCache.containsKey(element); | 1881 return _resolutionImpactCache.containsKey(element); |
| 1918 } | 1882 } |
| 1919 | 1883 |
| 1920 @override | 1884 @override |
| 1921 ResolutionImpact getResolutionImpact(Element element) { | 1885 ResolutionImpact getResolutionImpact(Element element) { |
| 1922 ResolutionImpact resolutionImpact = _resolutionImpactCache[element]; | 1886 ResolutionImpact resolutionImpact = _resolutionImpactCache[element]; |
| 1923 assert(invariant(element, resolutionImpact != null, | 1887 assert(invariant(element, resolutionImpact != null, |
| 1924 message: "ResolutionImpact not available for $element.")); | 1888 message: "ResolutionImpact not available for $element.")); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2012 | 1976 |
| 2013 @override | 1977 @override |
| 2014 void parsePatchClass(ClassElement cls) { | 1978 void parsePatchClass(ClassElement cls) { |
| 2015 compiler.patchParser.measure(() { | 1979 compiler.patchParser.measure(() { |
| 2016 if (cls.isPatch) { | 1980 if (cls.isPatch) { |
| 2017 compiler.patchParser.parsePatchClassNode(cls); | 1981 compiler.patchParser.parsePatchClassNode(cls); |
| 2018 } | 1982 } |
| 2019 }); | 1983 }); |
| 2020 } | 1984 } |
| 2021 | 1985 |
| 2022 ScannerOptions getScannerOptionsFor(Element element) => | 1986 ScannerOptions getScannerOptionsFor(Element element) => new ScannerOptions( |
| 2023 new ScannerOptions.from(compiler, element.library); | 1987 canUseNative: compiler.backend.canLibraryUseNative(element.library)); |
| 2024 | 1988 |
| 2025 ParserOptions get parserOptions => compiler.options; | 1989 ParserOptions get parserOptions => compiler.options; |
| 2026 } | 1990 } |
| 2027 | 1991 |
| 2028 class GlobalDependencyRegistry extends EagerRegistry { | 1992 class GlobalDependencyRegistry extends EagerRegistry { |
| 2029 final Compiler compiler; | 1993 final Compiler compiler; |
| 2030 Setlet<Element> _otherDependencies; | 1994 Setlet<Element> _otherDependencies; |
| 2031 | 1995 |
| 2032 GlobalDependencyRegistry(this.compiler) : super('GlobalDependencies', null); | 1996 GlobalDependencyRegistry(this.compiler) : super('GlobalDependencies', null); |
| 2033 | 1997 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2044 _otherDependencies.add(element.implementation); | 2008 _otherDependencies.add(element.implementation); |
| 2045 } | 2009 } |
| 2046 | 2010 |
| 2047 Iterable<Element> get otherDependencies { | 2011 Iterable<Element> get otherDependencies { |
| 2048 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2012 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2049 } | 2013 } |
| 2050 } | 2014 } |
| 2051 | 2015 |
| 2052 // TODO(sigmund): in the future, each of these classes should be self contained | 2016 // TODO(sigmund): in the future, each of these classes should be self contained |
| 2053 // and not use references to `compiler`. | 2017 // and not use references to `compiler`. |
| 2018 // TODO(het): This class is an ugly hack because we need a | |
| 2019 // [ResolvedUriTranslator] at compiler construction time, but the actual | |
| 2020 // translator isn't set until the compiler actually starts running. | |
|
Siggi Cherem (dart-lang)
2016/04/13 15:53:35
Some ideas to make it more self explanatory:
- re
Harry Terkelsen
2016/04/13 20:23:40
Done.
| |
| 2054 class _ResolvedUriTranslator implements ResolvedUriTranslator { | 2021 class _ResolvedUriTranslator implements ResolvedUriTranslator { |
| 2055 Compiler compiler; | 2022 Compiler compiler; |
| 2056 _ResolvedUriTranslator(this.compiler); | 2023 _ResolvedUriTranslator(this.compiler); |
| 2057 | 2024 |
| 2025 @override | |
| 2058 Uri translate(LibraryElement importingLibrary, Uri resolvedUri, | 2026 Uri translate(LibraryElement importingLibrary, Uri resolvedUri, |
| 2059 [Spannable spannable]) => | 2027 [Spannable spannable]) => |
| 2060 compiler.translateResolvedUri(importingLibrary, resolvedUri, spannable); | 2028 compiler.resolvedUriTranslator |
| 2029 .translate(importingLibrary, resolvedUri, spannable); | |
| 2030 | |
| 2031 @override | |
| 2032 Set<Uri> get disallowedLibraryUris => | |
| 2033 compiler.resolvedUriTranslator.disallowedLibraryUris; | |
| 2034 | |
| 2035 @override | |
| 2036 bool get mockableLibraryUsed => | |
| 2037 compiler.resolvedUriTranslator.mockableLibraryUsed; | |
| 2038 | |
| 2039 @override | |
| 2040 Map<String, Uri> get sdkLibraries => | |
| 2041 compiler.resolvedUriTranslator.sdkLibraries; | |
| 2061 } | 2042 } |
| 2062 | 2043 |
| 2063 class _ScriptLoader implements ScriptLoader { | 2044 class _ScriptLoader implements ScriptLoader { |
| 2064 Compiler compiler; | 2045 Compiler compiler; |
| 2065 _ScriptLoader(this.compiler); | 2046 _ScriptLoader(this.compiler); |
| 2066 | 2047 |
| 2067 Future<Script> readScript(Uri uri, [Spannable spannable]) => | 2048 Future<Script> readScript(Uri uri, [Spannable spannable]) => |
| 2068 compiler.readScript(uri, spannable); | 2049 compiler.readScript(uri, spannable); |
| 2069 } | 2050 } |
| 2070 | 2051 |
| 2071 class _ElementScanner implements ElementScanner { | 2052 class _ElementScanner implements ElementScanner { |
| 2072 ScannerTask scanner; | 2053 ScannerTask scanner; |
| 2073 _ElementScanner(this.scanner); | 2054 _ElementScanner(this.scanner); |
| 2074 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2055 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2075 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2056 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2076 } | 2057 } |
| 2077 | 2058 |
| 2078 class _EmptyEnvironment implements Environment { | 2059 class _EmptyEnvironment implements Environment { |
| 2079 const _EmptyEnvironment(); | 2060 const _EmptyEnvironment(); |
| 2080 | 2061 |
| 2081 String valueOf(String key) => null; | 2062 String valueOf(String key) => null; |
| 2082 } | 2063 } |
| OLD | NEW |