Index: sdk/lib/_internal/compiler/implementation/dependency_info.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/dependency_info.dart b/sdk/lib/_internal/compiler/implementation/dependency_info.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..29f7bb43426db639efaf15f1954a30d3f0538650 |
--- /dev/null |
+++ b/sdk/lib/_internal/compiler/implementation/dependency_info.dart |
@@ -0,0 +1,53 @@ |
+library dart2js.dependency_information; |
+ |
+import 'dart2jslib.dart'; |
+import 'elements/elements.dart'; |
+import 'tree/tree.dart'; |
+ |
+ |
+abstract class DependencyInformation { |
+ factory DependencyInformation(Enqueuer enqueuer, bool dumpInfoEnabled) { |
+ if (dumpInfoEnabled) { |
+ return new _DependencyInformation(enqueuer); |
+ } else { |
+ return new _EmptyDependencyInformation(); |
+ } |
+ } |
+ |
+ void elementUsesSelector(Element element, Selector selector) {} |
sra1
2014/07/30 21:43:48
abstract methods are declared without a body:
voi
Ty Overby (Google)
2014/08/01 16:39:37
This class is gone.
Done.
|
+ Iterable<Element> getRetaining(Element element, Compiler compiler) {} |
+} |
+ |
+class _EmptyDependencyInformation implements DependencyInformation { |
+ _EmptyDependencyInformation(); |
+ |
+ void elementUsesSelector(Element element, Selector selector) {} |
+ Iterable<Element> getRetaining(Element element, Compiler compiler) { |
+ return const <Element>[]; |
+ } |
+} |
+ |
+ |
+class _DependencyInformation implements DependencyInformation { |
+ _DependencyInformation(Enqueuer enqueuer); |
+ |
+ /// An [Element] uses [Selector]s |
+ final Map<Element, Set<Selector>> selectorsFromElement = {}; |
+ |
+ /// Returns a group of [Element]s that [element] is retaining. |
+ Iterable<Element> getRetaining(Element element, Compiler compiler) { |
+ if (!selectorsFromElement.containsKey(element)) { |
+ return []; |
+ } else { |
+ return selectorsFromElement[element].expand( |
+ (s) => compiler.world.allFunctions.filter(s)); |
+ } |
+ } |
+ |
+ // The Element may or may not actually be emitted. |
+ void elementUsesSelector(Element element, Selector selector) { |
+ selectorsFromElement |
+ .putIfAbsent(element, () => new Set<Selector>()) |
+ .add(selector); |
+ } |
+} |