| 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 Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'closure.dart' as closureMapping show ClosureTask; | 10 import 'closure.dart' as closureMapping show ClosureTask; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 show | 37 show |
| 38 ResolutionDartType, | 38 ResolutionDartType, |
| 39 ResolutionDynamicType, | 39 ResolutionDynamicType, |
| 40 ResolutionInterfaceType, | 40 ResolutionInterfaceType, |
| 41 Types; | 41 Types; |
| 42 import 'enqueue.dart' show Enqueuer, EnqueueTask, ResolutionEnqueuer; | 42 import 'enqueue.dart' show Enqueuer, EnqueueTask, ResolutionEnqueuer; |
| 43 import 'environment.dart'; | 43 import 'environment.dart'; |
| 44 import 'id_generator.dart'; | 44 import 'id_generator.dart'; |
| 45 import 'io/source_information.dart' show SourceInformation; | 45 import 'io/source_information.dart' show SourceInformation; |
| 46 import 'js_backend/backend.dart' show JavaScriptBackend; | 46 import 'js_backend/backend.dart' show JavaScriptBackend; |
| 47 import 'kernel/world_builder.dart' show KernelWorldBuilder; |
| 47 import 'library_loader.dart' | 48 import 'library_loader.dart' |
| 48 show | 49 show |
| 49 ElementScanner, | 50 ElementScanner, |
| 50 LibraryLoader, | 51 LibraryLoader, |
| 51 LibraryLoaderTask, | 52 LibraryLoaderTask, |
| 52 LoadedLibraries, | 53 LoadedLibraries, |
| 53 LibraryProvider, | 54 LibraryProvider, |
| 54 ScriptLoader; | 55 ScriptLoader; |
| 55 import 'mirrors_used.dart' show MirrorUsageAnalyzerTask; | 56 import 'mirrors_used.dart' show MirrorUsageAnalyzerTask; |
| 56 import 'null_compiler_output.dart' show NullCompilerOutput, NullSink; | 57 import 'null_compiler_output.dart' show NullCompilerOutput, NullSink; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 * If true, stop compilation after type inference is complete. Used for | 108 * If true, stop compilation after type inference is complete. Used for |
| 108 * debugging and testing purposes only. | 109 * debugging and testing purposes only. |
| 109 */ | 110 */ |
| 110 bool stopAfterTypeInference = false; | 111 bool stopAfterTypeInference = false; |
| 111 | 112 |
| 112 /// Output provider from user of Compiler API. | 113 /// Output provider from user of Compiler API. |
| 113 api.CompilerOutput userOutputProvider; | 114 api.CompilerOutput userOutputProvider; |
| 114 | 115 |
| 115 List<Uri> librariesToAnalyzeWhenRun; | 116 List<Uri> librariesToAnalyzeWhenRun; |
| 116 | 117 |
| 118 /// Object holding the correspondence between Kernel IR and their |
| 119 /// corresponding K/JElements. Only (currently) used when used in conjunction |
| 120 /// with --use-kernel and --read-dill flags. |
| 121 KernelWorldBuilder kernelWorldBuilder; |
| 122 |
| 117 ResolvedUriTranslator get resolvedUriTranslator; | 123 ResolvedUriTranslator get resolvedUriTranslator; |
| 118 | 124 |
| 119 LibraryElement mainApp; | 125 LibraryElement mainApp; |
| 120 MethodElement mainFunction; | 126 MethodElement mainFunction; |
| 121 | 127 |
| 122 DiagnosticReporter get reporter => _reporter; | 128 DiagnosticReporter get reporter => _reporter; |
| 123 ElementEnvironment get elementEnvironment => _elementEnvironment; | 129 ElementEnvironment get elementEnvironment => _elementEnvironment; |
| 124 CommonElements get commonElements => _commonElements; | 130 CommonElements get commonElements => _commonElements; |
| 125 Resolution get resolution => _resolution; | 131 Resolution get resolution => _resolution; |
| 126 ParsingContext get parsingContext => _parsingContext; | 132 ParsingContext get parsingContext => _parsingContext; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 211 |
| 206 backend = createBackend(); | 212 backend = createBackend(); |
| 207 enqueuer = backend.makeEnqueuer(); | 213 enqueuer = backend.makeEnqueuer(); |
| 208 | 214 |
| 209 tasks = [ | 215 tasks = [ |
| 210 dietParser = new DietParserTask(idGenerator, backend, reporter, measurer), | 216 dietParser = new DietParserTask(idGenerator, backend, reporter, measurer), |
| 211 scanner = createScannerTask(), | 217 scanner = createScannerTask(), |
| 212 serialization = new SerializationTask(this), | 218 serialization = new SerializationTask(this), |
| 213 patchParser = new PatchParserTask(this), | 219 patchParser = new PatchParserTask(this), |
| 214 libraryLoader = new LibraryLoaderTask( | 220 libraryLoader = new LibraryLoaderTask( |
| 221 options.loadFromDill, |
| 215 resolvedUriTranslator, | 222 resolvedUriTranslator, |
| 216 options.compileOnly | 223 options.compileOnly |
| 217 ? new _NoScriptLoader(this) | 224 ? new _NoScriptLoader(this) |
| 218 : new _ScriptLoader(this), | 225 : new _ScriptLoader(this), |
| 219 new _ElementScanner(scanner), | 226 new _ElementScanner(scanner), |
| 220 serialization, | 227 serialization, |
| 221 resolvePatchUri, | 228 resolvePatchUri, |
| 222 patchParser, | 229 patchParser, |
| 223 environment, | 230 environment, |
| 224 reporter, | 231 reporter, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 !link.isEmpty; | 348 !link.isEmpty; |
| 342 link = link.tail) { | 349 link = link.tail) { |
| 343 Uri uri = link.head; | 350 Uri uri = link.head; |
| 344 if (!currentCodeLocation.inSameLocation(uri)) { | 351 if (!currentCodeLocation.inSameLocation(uri)) { |
| 345 currentCodeLocation = | 352 currentCodeLocation = |
| 346 options.verbose ? new UriLocation(uri) : new CodeLocation(uri); | 353 options.verbose ? new UriLocation(uri) : new CodeLocation(uri); |
| 347 compactImportChain = compactImportChain.prepend(currentCodeLocation); | 354 compactImportChain = compactImportChain.prepend(currentCodeLocation); |
| 348 } | 355 } |
| 349 } | 356 } |
| 350 String importChain = compactImportChain.map((CodeLocation codeLocation) { | 357 String importChain = compactImportChain.map((CodeLocation codeLocation) { |
| 351 return codeLocation | 358 return codeLocation.relativize( |
| 352 .relativize(loadedLibraries.rootLibrary.canonicalUri); | 359 (loadedLibraries.rootLibrary as LibraryElement).canonicalUri); |
| 353 }).join(' => '); | 360 }).join(' => '); |
| 354 | 361 |
| 355 if (!importChains.contains(importChain)) { | 362 if (!importChains.contains(importChain)) { |
| 356 if (importChains.length > compactChainLimit) { | 363 if (importChains.length > compactChainLimit) { |
| 357 importChains.add('...'); | 364 importChains.add('...'); |
| 358 return false; | 365 return false; |
| 359 } else { | 366 } else { |
| 360 importChains.add(importChain); | 367 importChains.add(importChain); |
| 361 } | 368 } |
| 362 } | 369 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 374 | 381 |
| 375 /// This method is called when all new libraries loaded through | 382 /// This method is called when all new libraries loaded through |
| 376 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports | 383 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports |
| 377 /// have been computed. | 384 /// have been computed. |
| 378 /// | 385 /// |
| 379 /// [loadedLibraries] contains the newly loaded libraries. | 386 /// [loadedLibraries] contains the newly loaded libraries. |
| 380 /// | 387 /// |
| 381 /// The method returns a [Future] allowing for the loading of additional | 388 /// The method returns a [Future] allowing for the loading of additional |
| 382 /// libraries. | 389 /// libraries. |
| 383 LoadedLibraries processLoadedLibraries(LoadedLibraries loadedLibraries) { | 390 LoadedLibraries processLoadedLibraries(LoadedLibraries loadedLibraries) { |
| 384 loadedLibraries.forEachLibrary((LibraryElement library) { | 391 kernelWorldBuilder = libraryLoader.worldBuilder; |
| 392 loadedLibraries.forEachLibrary((LibraryEntity library) { |
| 385 backend.setAnnotations(library); | 393 backend.setAnnotations(library); |
| 386 }); | 394 }); |
| 387 | 395 |
| 388 for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) { | 396 for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) { |
| 389 if (loadedLibraries.containsLibrary(uri)) { | 397 if (loadedLibraries.containsLibrary(uri)) { |
| 390 Set<String> importChains = computeImportChainsFor(loadedLibraries, uri); | 398 Set<String> importChains = computeImportChainsFor(loadedLibraries, uri); |
| 391 reporter.reportInfo( | 399 reporter.reportInfo( |
| 392 NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { | 400 NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { |
| 393 'uri': uri, | 401 'uri': uri, |
| 394 'importChain': importChains | 402 'importChain': importChains |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 if (library != null && library.isSynthesized) { | 1974 if (library != null && library.isSynthesized) { |
| 1967 return null; | 1975 return null; |
| 1968 } | 1976 } |
| 1969 if (library == null && required) { | 1977 if (library == null && required) { |
| 1970 throw new SpannableAssertionFailure( | 1978 throw new SpannableAssertionFailure( |
| 1971 library, "The library '${uri}' was not found."); | 1979 library, "The library '${uri}' was not found."); |
| 1972 } | 1980 } |
| 1973 return library; | 1981 return library; |
| 1974 } | 1982 } |
| 1975 } | 1983 } |
| OLD | NEW |