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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
9 * compiled. | 9 * compiled. |
10 */ | 10 */ |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 static final Uri DART_FOREIGN_HELPER = | 501 static final Uri DART_FOREIGN_HELPER = |
502 new Uri(scheme: 'dart', path: '_foreign_helper'); | 502 new Uri(scheme: 'dart', path: '_foreign_helper'); |
503 static final Uri DART_ISOLATE_HELPER = | 503 static final Uri DART_ISOLATE_HELPER = |
504 new Uri(scheme: 'dart', path: '_isolate_helper'); | 504 new Uri(scheme: 'dart', path: '_isolate_helper'); |
505 static final Uri DART_MIRRORS = new Uri(scheme: 'dart', path: 'mirrors'); | 505 static final Uri DART_MIRRORS = new Uri(scheme: 'dart', path: 'mirrors'); |
506 static final Uri DART_NATIVE_TYPED_DATA = | 506 static final Uri DART_NATIVE_TYPED_DATA = |
507 new Uri(scheme: 'dart', path: '_native_typed_data'); | 507 new Uri(scheme: 'dart', path: '_native_typed_data'); |
508 static final Uri DART_INTERNAL = new Uri(scheme: 'dart', path: '_internal'); | 508 static final Uri DART_INTERNAL = new Uri(scheme: 'dart', path: '_internal'); |
509 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); | 509 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); |
510 | 510 |
511 // TODO(johnniwinther): Move this to [LibraryLoaderTask] and hange to map from | |
512 // [Uri] to [LibraryElement]. | |
513 final Map<String, LibraryElement> libraries = | |
514 new Map<String, LibraryElement>(); | |
515 final Stopwatch totalCompileTime = new Stopwatch(); | 511 final Stopwatch totalCompileTime = new Stopwatch(); |
516 int nextFreeClassId = 0; | 512 int nextFreeClassId = 0; |
517 World world; | 513 World world; |
518 String assembledCode; | 514 String assembledCode; |
519 Types types; | 515 Types types; |
520 | 516 |
521 final CacheStrategy cacheStrategy; | 517 final CacheStrategy cacheStrategy; |
522 | 518 |
523 /** | 519 /** |
524 * Map from token to the first preceeding comment token. | 520 * Map from token to the first preceeding comment token. |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 | 1305 |
1310 // In order to see if a library is deferred, we must compute the | 1306 // In order to see if a library is deferred, we must compute the |
1311 // compile-time constants that are metadata. This means adding | 1307 // compile-time constants that are metadata. This means adding |
1312 // something to the resolution queue. So we cannot wait with | 1308 // something to the resolution queue. So we cannot wait with |
1313 // this until after the resolution queue is processed. | 1309 // this until after the resolution queue is processed. |
1314 deferredLoadTask.ensureMetadataResolved(this); | 1310 deferredLoadTask.ensureMetadataResolved(this); |
1315 } | 1311 } |
1316 | 1312 |
1317 phase = PHASE_RESOLVING; | 1313 phase = PHASE_RESOLVING; |
1318 if (analyzeAll) { | 1314 if (analyzeAll) { |
1319 libraries.forEach((uri, lib) { | 1315 libraryLoader.libraries.forEach((LibraryElement library) { |
1320 log('Enqueuing $uri'); | 1316 log('Enqueuing ${library.canonicalUri}'); |
1321 fullyEnqueueLibrary(lib, enqueuer.resolution); | 1317 fullyEnqueueLibrary(library, enqueuer.resolution); |
1322 }); | 1318 }); |
1323 } else if (analyzeMain && mainApp != null) { | 1319 } else if (analyzeMain && mainApp != null) { |
1324 fullyEnqueueLibrary(mainApp, enqueuer.resolution); | 1320 fullyEnqueueLibrary(mainApp, enqueuer.resolution); |
1325 } | 1321 } |
1326 // Elements required by enqueueHelpers are global dependencies | 1322 // Elements required by enqueueHelpers are global dependencies |
1327 // that are not pulled in by a particular element. | 1323 // that are not pulled in by a particular element. |
1328 backend.enqueueHelpers(enqueuer.resolution, globalDependencies); | 1324 backend.enqueueHelpers(enqueuer.resolution, globalDependencies); |
1329 resolveLibraryMetadata(); | 1325 resolveLibraryMetadata(); |
1330 log('Resolving...'); | 1326 log('Resolving...'); |
1331 processQueue(enqueuer.resolution, main); | 1327 processQueue(enqueuer.resolution, main); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. | 1377 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. |
1382 if (hasIsolateSupport()) { | 1378 if (hasIsolateSupport()) { |
1383 enqueuer.codegen.addToWorkList( | 1379 enqueuer.codegen.addToWorkList( |
1384 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); | 1380 isolateHelperLibrary.find(Compiler.START_ROOT_ISOLATE)); |
1385 enqueuer.codegen.registerGetOfStaticFunction(main); | 1381 enqueuer.codegen.registerGetOfStaticFunction(main); |
1386 } | 1382 } |
1387 if (enabledNoSuchMethod) { | 1383 if (enabledNoSuchMethod) { |
1388 backend.enableNoSuchMethod(enqueuer.codegen); | 1384 backend.enableNoSuchMethod(enqueuer.codegen); |
1389 } | 1385 } |
1390 if (compileAll) { | 1386 if (compileAll) { |
1391 libraries.forEach((_, lib) => fullyEnqueueLibrary(lib, | 1387 libraryLoader.libraries.forEach((LibraryElement library) { |
1392 enqueuer.codegen)); | 1388 fullyEnqueueLibrary(library, enqueuer.codegen); |
| 1389 }); |
1393 } | 1390 } |
1394 processQueue(enqueuer.codegen, main); | 1391 processQueue(enqueuer.codegen, main); |
1395 enqueuer.codegen.logSummary(log); | 1392 enqueuer.codegen.logSummary(log); |
1396 | 1393 |
1397 if (compilationFailed) return; | 1394 if (compilationFailed) return; |
1398 | 1395 |
1399 backend.assembleProgram(); | 1396 backend.assembleProgram(); |
1400 | 1397 |
1401 if (dumpInfo) { | 1398 if (dumpInfo) { |
1402 dumpInfoTask.dumpInfo(); | 1399 dumpInfoTask.dumpInfo(); |
(...skipping 21 matching lines...) Expand all Loading... |
1424 world.registerInstantiatedClass(element, globalDependencies); | 1421 world.registerInstantiatedClass(element, globalDependencies); |
1425 } else { | 1422 } else { |
1426 world.addToWorkList(element); | 1423 world.addToWorkList(element); |
1427 } | 1424 } |
1428 } | 1425 } |
1429 | 1426 |
1430 // Resolves metadata on library elements. This is necessary in order to | 1427 // Resolves metadata on library elements. This is necessary in order to |
1431 // resolve metadata classes referenced only from metadata on library tags. | 1428 // resolve metadata classes referenced only from metadata on library tags. |
1432 // TODO(ahe): Figure out how to do this lazily. | 1429 // TODO(ahe): Figure out how to do this lazily. |
1433 void resolveLibraryMetadata() { | 1430 void resolveLibraryMetadata() { |
1434 for (LibraryElement library in libraries.values) { | 1431 for (LibraryElement library in libraryLoader.libraries) { |
1435 if (library.metadata != null) { | 1432 if (library.metadata != null) { |
1436 for (MetadataAnnotation metadata in library.metadata) { | 1433 for (MetadataAnnotation metadata in library.metadata) { |
1437 metadata.ensureResolved(this); | 1434 metadata.ensureResolved(this); |
1438 } | 1435 } |
1439 } | 1436 } |
1440 } | 1437 } |
1441 } | 1438 } |
1442 | 1439 |
1443 void processQueue(Enqueuer world, Element main) { | 1440 void processQueue(Enqueuer world, Element main) { |
1444 world.nativeEnqueuer.processNativeClasses(libraries.values); | 1441 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); |
1445 if (main != null) { | 1442 if (main != null) { |
1446 FunctionElement mainMethod = main; | 1443 FunctionElement mainMethod = main; |
1447 if (mainMethod.computeSignature(this).parameterCount != 0) { | 1444 if (mainMethod.computeSignature(this).parameterCount != 0) { |
1448 // TODO(ngeoffray, floitsch): we should also ensure that the | 1445 // TODO(ngeoffray, floitsch): we should also ensure that the |
1449 // class IsolateMessage is instantiated. Currently, just enabling | 1446 // class IsolateMessage is instantiated. Currently, just enabling |
1450 // isolate support works. | 1447 // isolate support works. |
1451 world.enableIsolateSupport(main.library); | 1448 world.enableIsolateSupport(main.library); |
1452 world.registerInstantiatedClass(listClass, globalDependencies); | 1449 world.registerInstantiatedClass(listClass, globalDependencies); |
1453 world.registerInstantiatedClass(stringClass, globalDependencies); | 1450 world.registerInstantiatedClass(stringClass, globalDependencies); |
1454 } | 1451 } |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 } else { | 1789 } else { |
1793 member.forEachLocalMember(checkLive); | 1790 member.forEachLocalMember(checkLive); |
1794 } | 1791 } |
1795 } else if (member.isTypedef) { | 1792 } else if (member.isTypedef) { |
1796 if (!member.isResolved) { | 1793 if (!member.isResolved) { |
1797 reportHint(member, MessageKind.UNUSED_TYPEDEF, | 1794 reportHint(member, MessageKind.UNUSED_TYPEDEF, |
1798 {'name': member.name}); | 1795 {'name': member.name}); |
1799 } | 1796 } |
1800 } | 1797 } |
1801 } | 1798 } |
1802 libraries.forEach((_, library) { | 1799 libraryLoader.libraries.forEach((LibraryElement library) { |
1803 // TODO(ahe): Implement better heuristics to discover entry points of | 1800 // TODO(ahe): Implement better heuristics to discover entry points of |
1804 // packages and use that to discover unused implementation details in | 1801 // packages and use that to discover unused implementation details in |
1805 // packages. | 1802 // packages. |
1806 if (library.isPlatformLibrary || library.isPackageLibrary) return; | 1803 if (library.isPlatformLibrary || library.isPackageLibrary) return; |
1807 library.compilationUnits.forEach((unit) { | 1804 library.compilationUnits.forEach((unit) { |
1808 unit.forEachLocalMember(checkLive); | 1805 unit.forEachLocalMember(checkLive); |
1809 }); | 1806 }); |
1810 }); | 1807 }); |
1811 } | 1808 } |
1812 | 1809 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 static NullSink outputProvider(String name, String extension) { | 2016 static NullSink outputProvider(String name, String extension) { |
2020 return new NullSink('$name.$extension'); | 2017 return new NullSink('$name.$extension'); |
2021 } | 2018 } |
2022 } | 2019 } |
2023 | 2020 |
2024 /// Information about suppressed warnings and hints for a given library. | 2021 /// Information about suppressed warnings and hints for a given library. |
2025 class SuppressionInfo { | 2022 class SuppressionInfo { |
2026 int warnings = 0; | 2023 int warnings = 0; |
2027 int hints = 0; | 2024 int hints = 0; |
2028 } | 2025 } |
OLD | NEW |