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

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
Index: lib/compiler/implementation/universe/function_set.dart
===================================================================
--- lib/compiler/implementation/universe/function_set.dart (revision 12117)
+++ lib/compiler/implementation/universe/function_set.dart (working copy)
@@ -46,6 +46,17 @@
: filterHierarchyBySelector(selector);
}
+ /**
+ * Returns whether the set has an element matching this selector.
kasperl 2012/09/11 07:39:11 has any elements matching the given [selector].
ngeoffray 2012/09/11 08:51:08 Done.
+ */
+ bool hasOneElementMatchingSelector(Selector selector) {
kasperl 2012/09/11 07:39:11 hasAnyElementsMatchingSelector would be more corre
ngeoffray 2012/09/11 08:51:08 Done.
+ // TODO(kasperl): For now, we use a different implementation for
+ // filtering if the tree contains interface subtypes.
+ return containsInterfaceSubtypes
+ ? hasOneInAll(selector)
+ : hasOneInHierarchy(selector);
+ }
+
Set<Element> filterAllBySelector(Selector selector) {
Set<Element> result = new Set<Element>();
if (root === null) return result;
@@ -74,6 +85,38 @@
return result;
}
+ bool hasOneInAll(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 hasOneInHierarchy(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 {

Powered by Google App Engine
This is Rietveld 408576698