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

Unified Diff: lib/compiler/implementation/universe/function_set.dart

Issue 10911181: Collect getters in a FunctionSet while resolving. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | lib/compiler/implementation/world.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/universe/function_set.dart
===================================================================
--- lib/compiler/implementation/universe/function_set.dart (revision 12169)
+++ lib/compiler/implementation/universe/function_set.dart (working copy)
@@ -46,6 +46,18 @@
: filterHierarchyBySelector(selector);
}
+ /**
+ * Returns whether the set has any element matching the given
+ * [selector].
+ */
+ bool hasAnyElementMatchingSelector(Selector selector) {
+ // TODO(kasperl): For now, we use a different implementation for
+ // filtering if the tree contains interface subtypes.
+ return containsInterfaceSubtypes
+ ? hasAnyInAll(selector)
+ : hasAnyInHierarchy(selector);
+ }
+
Set<Element> filterAllBySelector(Selector selector) {
Set<Element> result = new Set<Element>();
if (root === null) return result;
@@ -74,6 +86,38 @@
return result;
}
+ bool hasAnyInAll(Selector selector) {
+ bool result = false;
+ if (root === null) return result;
+ root.visitRecursively((FunctionSetNode node) {
+ Element member = node.membersByName[selector.name];
+ // Since we're running through the entire tree we have to use
+ // the applies method that takes types into account.
+ if (member !== null && selector.applies(member, compiler)) {
+ result = true;
+ // End the traversal.
+ return false;
+ }
+ return true;
+ });
+ return result;
+ }
+
+ bool hasAnyInHierarchy(Selector selector) {
+ bool result = false;
+ if (root === null) return result;
+ visitHierarchy(selectorType(selector), (FunctionSetNode node) {
+ Element member = node.membersByName[selector.name];
+ if (member !== null && selector.appliesUntyped(member, compiler)) {
+ result = true;
+ // End the traversal.
+ return false;
+ }
+ return true;
+ });
+ return result;
+ }
+
}
class FunctionSetNode extends PartialTypeTreeNode {
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | lib/compiler/implementation/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698