Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: pkg/compiler/lib/src/library_loader.dart

Issue 2009773004: Remove reference to compiler from libary loader, fix analyzer warning (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_backend/no_such_method_registry.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.library_loader; 5 library dart2js.library_loader;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'common/names.dart' show Uris; 9 import 'common/names.dart' show Uris;
10 import 'common/tasks.dart' show CompilerTask, GenericTask; 10 import 'common/tasks.dart' show CompilerTask, Measurer;
11 import 'common.dart'; 11 import 'common.dart';
12 import 'compiler.dart' show Compiler;
13 import 'elements/elements.dart' 12 import 'elements/elements.dart'
14 show 13 show
15 CompilationUnitElement, 14 CompilationUnitElement,
16 Element, 15 Element,
17 ImportElement, 16 ImportElement,
18 ExportElement, 17 ExportElement,
19 LibraryElement; 18 LibraryElement;
20 import 'elements/modelx.dart' 19 import 'elements/modelx.dart'
21 show 20 show
22 CompilationUnitElementX, 21 CompilationUnitElementX,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 * 'sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart'. This is done 107 * 'sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart'. This is done
109 * through a [ResolvedUriTranslator] provided from the compiler. The translator 108 * through a [ResolvedUriTranslator] provided from the compiler. The translator
110 * checks whether a library by that name exists and in case of internal 109 * checks whether a library by that name exists and in case of internal
111 * libraries whether access is granted. 110 * libraries whether access is granted.
112 * 111 *
113 * ## Resource URI ## 112 * ## Resource URI ##
114 * 113 *
115 * A 'resource URI' is an absolute URI with a scheme supported by the input 114 * A 'resource URI' is an absolute URI with a scheme supported by the input
116 * provider. For the standard implementation this means a URI with the 'file' 115 * provider. For the standard implementation this means a URI with the 'file'
117 * scheme. Readable URIs are converted into resource URIs as part of the 116 * scheme. Readable URIs are converted into resource URIs as part of the
118 * [Compiler.readScript] method. In the standard implementation the package URIs 117 * [ScriptLoader.readScript] method. In the standard implementation the package
119 * are converted to file URIs using the package root URI provided on the 118 * URIs are converted to file URIs using the package root URI provided on the
120 * command line as base. If the package root URI is 119 * command line as base. If the package root URI is
121 * 'file:///current/working/dir/' then the package URI 'package:foo/bar.dart' 120 * 'file:///current/working/dir/' then the package URI 'package:foo/bar.dart'
122 * will be resolved to the resource URI 121 * will be resolved to the resource URI
123 * 'file:///current/working/dir/foo/bar.dart'. 122 * 'file:///current/working/dir/foo/bar.dart'.
124 * 123 *
125 * The distinction between readable URI and resource URI is necessary to ensure 124 * The distinction between readable URI and resource URI is necessary to ensure
126 * that these imports 125 * that these imports
127 * 126 *
128 * import 'package:foo.dart' as a; 127 * import 'package:foo.dart' as a;
129 * import 'packages/foo.dart' as b; 128 * import 'packages/foo.dart' as b;
130 * 129 *
131 * do _not_ resolve to the same library when the package root URI happens to 130 * do _not_ resolve to the same library when the package root URI happens to
132 * point to the 'packages' folder. 131 * point to the 'packages' folder.
133 * 132 *
134 */ 133 */
135 abstract class LibraryLoaderTask implements CompilerTask { 134 abstract class LibraryLoaderTask implements CompilerTask {
136 factory LibraryLoaderTask( 135 factory LibraryLoaderTask(
137 Compiler compiler,
138 ResolvedUriTranslator uriTranslator, 136 ResolvedUriTranslator uriTranslator,
139 ScriptLoader scriptLoader, 137 ScriptLoader scriptLoader,
140 ElementScanner scriptScanner, 138 ElementScanner scriptScanner,
141 LibraryDeserializer deserializer, 139 LibraryDeserializer deserializer,
142 LibraryLoaderListener listener, 140 LibraryLoaderListener listener,
143 Environment environment) = _LibraryLoaderTask; 141 Environment environment,
142 DiagnosticReporter reporter,
143 Measurer measurer) = _LibraryLoaderTask;
144 144
145 /// Returns all libraries that have been loaded. 145 /// Returns all libraries that have been loaded.
146 Iterable<LibraryElement> get libraries; 146 Iterable<LibraryElement> get libraries;
147 147
148 /// Looks up the library with the [canonicalUri]. 148 /// Looks up the library with the [canonicalUri].
149 LibraryElement lookupLibrary(Uri canonicalUri); 149 LibraryElement lookupLibrary(Uri canonicalUri);
150 150
151 /// Loads the library specified by the [resolvedUri] and returns its 151 /// Loads the library specified by the [resolvedUri] and returns its
152 /// [LibraryElement]. 152 /// [LibraryElement].
153 /// 153 ///
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 final LibraryDeserializer deserializer; 290 final LibraryDeserializer deserializer;
291 291
292 /// Hooks to inform others about progress done by this loader. 292 /// Hooks to inform others about progress done by this loader.
293 // TODO(sigmund): move away from this. 293 // TODO(sigmund): move away from this.
294 final LibraryLoaderListener listener; 294 final LibraryLoaderListener listener;
295 295
296 /// Definitions provided via the `-D` command line flags. Used to resolve 296 /// Definitions provided via the `-D` command line flags. Used to resolve
297 /// conditional imports. 297 /// conditional imports.
298 final Environment environment; 298 final Environment environment;
299 299
300 final Compiler compiler; 300 final DiagnosticReporter reporter;
301 DiagnosticReporter get reporter => compiler.reporter;
302 301
303 _LibraryLoaderTask(Compiler compiler, this.uriTranslator, this.scriptLoader, 302 _LibraryLoaderTask(this.uriTranslator, this.scriptLoader,
304 this.scanner, this.deserializer, this.listener, this.environment) 303 this.scanner, this.deserializer, this.listener, this.environment,
305 : compiler = compiler, 304 this.reporter, Measurer measurer)
306 super(compiler.measurer); 305 : super(measurer);
307 306
308 String get name => 'LibraryLoader'; 307 String get name => 'LibraryLoader';
309 308
310 final Map<Uri, LibraryElement> libraryCanonicalUriMap = 309 final Map<Uri, LibraryElement> libraryCanonicalUriMap =
311 new Map<Uri, LibraryElement>(); 310 new Map<Uri, LibraryElement>();
312 final Map<Uri, LibraryElement> libraryResourceUriMap = 311 final Map<Uri, LibraryElement> libraryResourceUriMap =
313 new Map<Uri, LibraryElement>(); 312 new Map<Uri, LibraryElement>();
314 final Map<String, LibraryElement> libraryNames = 313 final Map<String, LibraryElement> libraryNames =
315 new Map<String, LibraryElement>(); 314 new Map<String, LibraryElement>();
316 315
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 378
380 Future<Null> resetLibraries( 379 Future<Null> resetLibraries(
381 Future<Iterable<LibraryElement>> reuseLibraries( 380 Future<Iterable<LibraryElement>> reuseLibraries(
382 Iterable<LibraryElement> libraries)) { 381 Iterable<LibraryElement> libraries)) {
383 assert(currentHandler == null); 382 assert(currentHandler == null);
384 return measureSubtask(_reuseLibrarySubtaskName, () { 383 return measureSubtask(_reuseLibrarySubtaskName, () {
385 return new Future<Iterable<LibraryElement>>(() { 384 return new Future<Iterable<LibraryElement>>(() {
386 // Wrap in Future to shield against errors in user code. 385 // Wrap in Future to shield against errors in user code.
387 return reuseLibraries(libraryCanonicalUriMap.values); 386 return reuseLibraries(libraryCanonicalUriMap.values);
388 }).catchError((exception, StackTrace trace) { 387 }).catchError((exception, StackTrace trace) {
389 compiler.reportCrashInUserCode( 388 reporter.onCrashInUserCode(
390 'Uncaught exception in reuseLibraries', exception, trace); 389 'Uncaught exception in reuseLibraries', exception, trace);
391 throw exception; // Async rethrow. 390 throw exception; // Async rethrow.
392 }).then((Iterable<LibraryElement> reusedLibraries) { 391 }).then((Iterable<LibraryElement> reusedLibraries) {
393 measure(() { 392 measure(() {
394 resetImplementation(reusedLibraries); 393 resetImplementation(reusedLibraries);
395 }); 394 });
396 }); 395 });
397 }); 396 });
398 } 397 }
399 398
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 Future onLibrariesLoaded(LoadedLibraries results); 1503 Future onLibrariesLoaded(LoadedLibraries results);
1505 1504
1506 /// Called whenever a library element is created. 1505 /// Called whenever a library element is created.
1507 void onLibraryCreated(LibraryElement library); 1506 void onLibraryCreated(LibraryElement library);
1508 1507
1509 /// Called whenever a library is scanned from a script file. 1508 /// Called whenever a library is scanned from a script file.
1510 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); 1509 Future onLibraryScanned(LibraryElement library, LibraryLoader loader);
1511 } 1510 }
1512 1511
1513 const _reuseLibrarySubtaskName = "Reuse library"; 1512 const _reuseLibrarySubtaskName = "Reuse library";
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/no_such_method_registry.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698