Chromium Code Reviews| 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 { |