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

Unified Diff: sdk/lib/_internal/compiler/implementation/dependency_info.dart

Issue 430913002: Better dependency tracking (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix self critiques Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698