| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 deferred_load; | 5 library deferred_load; |
| 6 | 6 |
| 7 import 'common/backend_api.dart' show Backend; | 7 import 'common/backend_api.dart' show Backend; |
| 8 import 'common/tasks.dart' show CompilerTask; | 8 import 'common/tasks.dart' show CompilerTask; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 if (element.isClass) { | 397 if (element.isClass) { |
| 398 // If we see a class, add everything its live instance members refer | 398 // If we see a class, add everything its live instance members refer |
| 399 // to. Static members are not relevant, unless we are processing | 399 // to. Static members are not relevant, unless we are processing |
| 400 // extra dependencies due to mirrors. | 400 // extra dependencies due to mirrors. |
| 401 void addLiveInstanceMember(Element element) { | 401 void addLiveInstanceMember(Element element) { |
| 402 if (!compiler.enqueuer.resolution.hasBeenProcessed(element)) return; | 402 if (!compiler.enqueuer.resolution.hasBeenProcessed(element)) return; |
| 403 if (!isMirrorUsage && !element.isInstanceMember) return; | 403 if (!isMirrorUsage && !element.isInstanceMember) return; |
| 404 elements.add(element); | 404 elements.add(element); |
| 405 collectDependencies(element); | 405 collectDependencies(element); |
| 406 } | 406 } |
| 407 |
| 407 ClassElement cls = element.declaration; | 408 ClassElement cls = element.declaration; |
| 408 cls.forEachLocalMember(addLiveInstanceMember); | 409 cls.forEachLocalMember(addLiveInstanceMember); |
| 409 if (cls.implementation != cls) { | 410 if (cls.implementation != cls) { |
| 410 // TODO(ahe): Why doesn't ClassElement.forEachLocalMember do this? | 411 // TODO(ahe): Why doesn't ClassElement.forEachLocalMember do this? |
| 411 cls.implementation.forEachLocalMember(addLiveInstanceMember); | 412 cls.implementation.forEachLocalMember(addLiveInstanceMember); |
| 412 } | 413 } |
| 413 for (var type in cls.implementation.allSupertypes) { | 414 for (var type in cls.implementation.allSupertypes) { |
| 414 elements.add(type.element.implementation); | 415 elements.add(type.element.implementation); |
| 415 } | 416 } |
| 416 elements.add(cls.implementation); | 417 elements.add(cls.implementation); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 LibraryElement exportedLibrary = export.exportedLibrary; | 454 LibraryElement exportedLibrary = export.exportedLibrary; |
| 454 traverseLibrary(exportedLibrary); | 455 traverseLibrary(exportedLibrary); |
| 455 } | 456 } |
| 456 } | 457 } |
| 457 | 458 |
| 458 iterateTags(library); | 459 iterateTags(library); |
| 459 if (library.isPatched) { | 460 if (library.isPatched) { |
| 460 iterateTags(library.implementation); | 461 iterateTags(library.implementation); |
| 461 } | 462 } |
| 462 } | 463 } |
| 464 |
| 463 traverseLibrary(root); | 465 traverseLibrary(root); |
| 464 result.add(compiler.coreLibrary); | 466 result.add(compiler.coreLibrary); |
| 465 return result; | 467 return result; |
| 466 } | 468 } |
| 467 | 469 |
| 468 /// Add all dependencies of [constant] to the mapping of [import]. | 470 /// Add all dependencies of [constant] to the mapping of [import]. |
| 469 void _mapConstantDependencies( | 471 void _mapConstantDependencies( |
| 470 ConstantValue constant, _DeferredImport import) { | 472 ConstantValue constant, _DeferredImport import) { |
| 471 Set<ConstantValue> constants = _constantsDeferredBy.putIfAbsent( | 473 Set<ConstantValue> constants = _constantsDeferredBy.putIfAbsent( |
| 472 import, () => new Set<ConstantValue>()); | 474 import, () => new Set<ConstantValue>()); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 ast.Send send = node; | 867 ast.Send send = node; |
| 866 ast.Node receiver = send.receiver; | 868 ast.Node receiver = send.receiver; |
| 867 ast.Node receiverFirst = firstNode(receiver); | 869 ast.Node receiverFirst = firstNode(receiver); |
| 868 if (receiverFirst != null) { | 870 if (receiverFirst != null) { |
| 869 return receiverFirst; | 871 return receiverFirst; |
| 870 } else { | 872 } else { |
| 871 return firstNode(send.selector); | 873 return firstNode(send.selector); |
| 872 } | 874 } |
| 873 } | 875 } |
| 874 } | 876 } |
| 877 |
| 875 ast.Node first = firstNode(send); | 878 ast.Node first = firstNode(send); |
| 876 ast.Node identifier = first.asIdentifier(); | 879 ast.Node identifier = first.asIdentifier(); |
| 877 if (identifier == null) return null; | 880 if (identifier == null) return null; |
| 878 Element maybePrefix = elements[identifier]; | 881 Element maybePrefix = elements[identifier]; |
| 879 if (maybePrefix != null && maybePrefix.isPrefix) { | 882 if (maybePrefix != null && maybePrefix.isPrefix) { |
| 880 PrefixElement prefixElement = maybePrefix; | 883 PrefixElement prefixElement = maybePrefix; |
| 881 if (prefixElement.isDeferred) { | 884 if (prefixElement.isDeferred) { |
| 882 return prefixElement; | 885 return prefixElement; |
| 883 } | 886 } |
| 884 } | 887 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 | 1035 |
| 1033 bool operator ==(other) { | 1036 bool operator ==(other) { |
| 1034 if (other is! _DeclaredDeferredImport) return false; | 1037 if (other is! _DeclaredDeferredImport) return false; |
| 1035 return declaration == other.declaration; | 1038 return declaration == other.declaration; |
| 1036 } | 1039 } |
| 1037 | 1040 |
| 1038 int get hashCode => declaration.hashCode * 17; | 1041 int get hashCode => declaration.hashCode * 17; |
| 1039 | 1042 |
| 1040 String toString() => '$declaration'; | 1043 String toString() => '$declaration'; |
| 1041 } | 1044 } |
| OLD | NEW |